public void loadedOnThread()
 {
     mValue      = null;
     mChildCount = 0;
     mLeft       = null;
     mRight      = null;
 }
Beispiel #2
0
        public bool loadRunner(IRTSRunner cal)
        {
            if (cal == null)
            {
                return(false);
            }
            if (cal.isConst())
            {
                mOutput = cal.getOutput();
                return(false);
            }
            int len = mRunners.length();

            if (len >= mStackSize)
            {
                return(false);
            }
            mRunners.add(cal);
            IRTSDefine.Stack sco = cal.applyStack();
            if ((sco & IRTSDefine.Stack.ACTION_RETURN) != 0)
            {
                IRTSStack scope = mStack.makeChild(len);
                if (scope != null)
                {
                    mStack = scope;
                }
            }
            cal.loadedOnThread();
            return(true);
        }
 public IRTSDefine.Stack run(IRTSStack stack)
 {
     if (mChildCount == 0)
     {
         mChildCount++;
         if (!skipLeft())
         {
             mLeft = mLeftL == null ? null : mLeftL.createRunner();
             if (stack.getThread().loadRunner(mLeft))
             {
                 return(0);
             }
         }
     }
     if (mChildCount == 1)
     {
         mChildCount++;
         if (!skipRight())
         {
             mRight = mRightL == null ? null : mRightL.createRunner();
             if (stack.getThread().loadRunner(mRight))
             {
                 return(0);
             }
         }
     }
     if (mChildCount == 2)
     {
         mChildCount++;
         onFinalRun(stack, mLeft == null ? null : mLeft.getOutput(), mRight == null ? null : mRight.getOutput());
     }
     return(0);
 }
 public IRTSDefine.Stack run(IRTSStack stack)
 {
     if (mChild == null && mPlugin != null)
     {
         object o = mPlugin.pluginFunction(mArgs);
         mChild = o as IRTSRunner;
         if (stack.getThread().loadRunner(mChild))
         {
             return(0);
         }
         else
         {
             mChild = null;
             setValue(o);
             return(0);
         }
     }
     if (mChild != null)
     {
         object o = mChild.getOutput();
         mChild = o as IRTSRunner;
         if (stack.getThread().loadRunner(mChild))
         {
             return(0);
         }
         else
         {
             mChild = null;
             setValue(o);
             return(0);
         }
     }
     return(0);
 }
Beispiel #5
0
        override public IRTSRunner createRunner()
        {
            IRTSRunner           r   = null;
            RTSList <IRTSRunner> lrs = null;

            if (mArg != null)
            {
                RTSList <IRTSLinker> lins = ((RTSBracketL)mArg).getChildAsList();
                if (lins != null)
                {
                    lrs = new RTSList <IRTSRunner>(lins.length());
                    for (int i = 0; i < lins.length(); i++)
                    {
                        IRTSLinker l = lins.get(i);
                        if (l == null)
                        {
                            lrs.add(null);
                        }
                        else
                        {
                            lrs.add(l.createRunner());
                        }
                    }
                }
            }
            r = new RTSFuncR(mCastType, mSrc, lrs);
            return(r);
        }
Beispiel #6
0
 /**
  * 在运行线程(RTSThread)中计算,返回值为表示return的类型,有return,break,continue
  *
  * @param thread
  * @return returnType
  */
 public IRTSDefine.Stack run(IRTSStack stack)
 {
     if (doCompile)
     {
         doCompile = false;
         compiler.loadSource(source);
         while (compiler.isCompiling())
         {
             IRTSDefine.Error err = compiler.onCompile(stack.getThread().getEngine());
             if (err != 0)
             {
                 IRTSLog log = stack.getThread().getEngine().getLogger();
                 if (log != null)
                 {
                     log.logError("无法解析内容 \"" + source + "\"");
                 }
                 return(0);
             }
         }
         IRTSLinker l = compiler.getRootLinker();
         child = l.createRunner();
         if (stack.getThread().loadRunner(child))
         {
             return(0);
         }
     }
     return(0);
 }
Beispiel #7
0
 public void loadedOnThread()
 {
     mFuncR   = null;
     mFunc    = null;
     mFuncCur = 0;
     mValue   = null;
 }
 public IRTSDefine.Stack run(IRTSStack stack)
 {
     if (mCur == 0)
     {
         mCur++;
         mConditionR = mConditionL == null ? null : mConditionL.createRunner();
         if (stack.getThread().loadRunner(mConditionR))
         {
             return(0);
         }
     }
     if (mCur == 1)
     {
         mCur++;
         object     o = mConditionR == null ? null : mConditionR.getOutput();
         bool       c = org.vr.rts.modify.RTSBool.valueOf(o);
         IRTSLinker l = c ? mTrueL : mFalseL;
         mResultR = l == null ? null : l.createRunner();
         if (stack.getThread().loadRunner(mResultR))
         {
             return(0);
         }
     }
     return(0);
 }
 public int LoadRunner(IRTSRunner runner, int threadId)
 {
     if (runner != null)
     {
         return(mImmediateT.loadRunner(runner) ? 0 : -1);
     }
     return(-1);
 }
 public void loadedOnThread()
 {
     mFuncR  = null;
     mFunc   = null;
     mArgCur = 0;
     mLoaded = false;
     mValue  = null;
 }
Beispiel #11
0
 public IRTSDefine.Stack run(IRTSStack stack)
 {
     if (!mVarLoaded)
     {
         mVarLoaded = true;
         mVarR      = mVar == null ? null : mVar.createRunner();
         if (stack.getThread().loadRunner(mVarR))
         {
             return(0);
         }
     }
     if (!mIndexLoaded)
     {
         mIndexLoaded = true;
         mIndexR      = mIndex == null ? null : mIndex.createRunner();
         if (stack.getThread().loadRunner(mIndexR))
         {
             return(0);
         }
     }
     while (mArray != null && mListCur < mArray.length())
     {
         IRTSLinker l = mArray.get(mListCur);
         mArrayR[mListCur] = l == null ? null : l.createRunner();
         if (stack.getThread().loadRunner(mArrayR[mListCur++]))
         {
             return(0);
         }
     }
     if (mArrayR != null)
     {
         //org.vr.rts.typedef.RTSarray arr = new org.vr.rts.typedef.RTSarray(mArrayR.Length);
         object[] arr = new object[mArrayR.Length];
         for (int i = 0; i < mArrayR.Length; i++)
         {
             object v = mArrayR[i] == null ? null : mArrayR[i].getOutput();
             //arr.set(i, v);
             arr[i] = v;
         }
         mValue = arr;
     }
     else
     {
         object obj   = mVarR == null ? null : mVarR.getOutput();
         object index = mIndexR == null ? null : mIndexR.getOutput();
         int    n     = org.vr.rts.modify.RTSInteger.valueOf(index);
         if (obj != null && obj is System.Collections.IList)
         {
             mValue = ((System.Collections.IList)obj)[n];
         }
         else
         {
             mValue = n == 0 ? obj : null;
         }
     }
     return(0);
 }
Beispiel #12
0
        public RTSInnerFuncR(object[] args, IRTSFunction func)
        {
            mArgs       = args;
            mReturnType = func.returnType();
            mFunc       = func;
            IRTSLinker body = func.getBody();

            mBody = body == null ? null : body.createRunner();
        }
 public void loadedOnThread()
 {
     mChildLoaded = false;
     mEvaluate    = false;
     mLeft        = null;
     mRight       = null;
     mValue       = null;
     mOutput      = null;
 }
 public IRTSDefine.Stack run(IRTSStack stack)
 {
     if (mLeftL == null)
     {
         return(0);
     }
     if (!mChildLoaded)
     {
         mChildLoaded = true;
         bool ret = false;
         if (mPreRunner != null)
         {
             mRight = mPreRunner.createRunnerWith(mLeftL, mRightL);
         }
         else
         {
             mRight = mRightL == null ? null : mRightL.createRunner();
             mLeft  = mLeftL.createRunner();
             if (mLeftL.getId() != IRTSDefine.Linker.VARIABLE)
             {
                 ret = stack.getThread().loadRunner(mLeft);
             }
         }
         ret |= stack.getThread().loadRunner(mRight);
         if (ret)
         {
             return(0);
         }
     }
     if (!mEvaluate)
     {
         mEvaluate = true;
         if (mPreRunner != null && mRight != null)
         {
             mLeft = ((RTSBinaryR)mRight).getLeft();
         }
         mLeft.evaluate(stack, mRight == null ? null : mRight.getOutput());
         mValue  = mLeft.getOutput();
         mOutput = mValue as IRTSRunner;
         mLeft   = null;
         if (stack.getThread().loadRunner(mOutput))
         {
             return(0);
         }
     }
     if (mOutput != null)
     {
         mValue  = mOutput.getOutput();
         mOutput = mValue as IRTSRunner;
         if (stack.getThread().loadRunner(mOutput))
         {
             return(0);
         }
     }
     return(0);
 }
 public void loadedOnThread()
 {
     mVarLoaded   = false;
     mIndexLoaded = false;
     mListCur     = 0;
     mValue       = null;
     mOutput      = null;
     if (mArray != null)
     {
         mArrayR = new IRTSRunner[mArray.length()];
     }
 }
 public void loadedOnThread()
 {
     mValue = null;
     mLeftR = null;
     if (mArgRs != null)
     {
         mArgRs.clear();
     }
     mLeftRun    = mLeftL != null;
     mInvokeFunc = true;
     mArgPtr     = 0;
 }
Beispiel #17
0
 public IRTSDefine.Stack run(IRTSStack stack)
 {
     if (!mLoaded)
     {
         mLoaded = true;
         mChild  = mChildL == null ? null : mChildL.createRunner();
         if (stack.getThread().loadRunner(mChild))
         {
             return(0);
         }
     }
     return(mType);
 }
Beispiel #18
0
        public void run(IRTSEngine engine)
        {
            mTicks = System.DateTime.Now.Ticks;
            int len = mRunners.length();

            if (len > 0)
            {
                mEngine = engine;
                while (mStack.getId() >= len)
                {
                    mStack.onRemoved();
                    mStack = mStack.getSuper();
                }
                IRTSRunner       cal = mRunners.getLast();
                IRTSDefine.Stack ret = cal.run(mStack);
                mOutput = cal.getOutput();
                if (ret != IRTSDefine.Stack.ACTION_HOLD)
                {
                    if (ret != 0)
                    {
                        int off = mRunners.length();
                        for (int i = off - 1; i >= 0; i--)
                        {
                            if ((mRunners.get(i).applyStack() & ret) != 0)
                            {
                                break;
                            }
                            off = i;
                        }
                        mRunners.removeFrom(off);
                        IRTSRunner cal2 = mRunners.getLast();
                        if (cal2 != null && cal2.onReturnAndSkip(ret, mOutput))
                        {
                            mRunners.removeLast();
                        }
                    }
                    else if (len == mRunners.length())
                    {
                        mRunners.removeLast();
                    }
                }
                mEngine = null;
                len     = mRunners.length();
                while (mStack.getId() >= len)
                {
                    mStack.onRemoved();
                    mStack = (RTSStack)mStack.getSuper();
                }
            }
        }
Beispiel #19
0
 public int LoadRunner(IRTSRunner runner, int threadId)
 {
     if (runner != null)
     {
         int t = FindFreeThread(threadId);
         if (t == -1)
         {
             return(-1);
         }
         bool ret = mThreads[t].loadRunner(runner);
         mExecUpdate |= ret;
         return(t);
     }
     return(-1);
 }
 public IRTSDefine.Stack run(IRTSStack stack)
 {
     if (mFunc == null)
     {
         mFunc = stack.getThread().getEngine().getFunction(mFuncName, mArgC);
         if (mFunc == null)
         {
             stack.getThread().catchError(IRTSDefine.Error.Runtime_NoFunctionDefine,
                                          "Don't find function defined:" + RTSUtil.keyOfFunc(mFuncName, mArgC));
             return(0);
         }
     }
     while (mArgs != null && mArgCur < mArgs.length())
     {
         IRTSRunner r = mArgs.get(mArgCur++);
         if (stack.getThread().loadRunner(r))
         {
             return(0);
         }
     }
     if (!mLoaded)
     {
         mLoaded = true;
         object[] args = mArgC > 0 ? new object[mArgC] : null;
         if (args != null)
         {
             for (int i = 0; i < mArgC; i++)
             {
                 IRTSRunner r = mArgs.get(i);
                 if (r != null)
                 {
                     args[i] = r.getOutput();
                 }
             }
         }
         mFuncR = mFunc.createRunner(args);
         if (stack.getThread().loadRunner(mFuncR))
         {
             return(0);
         }
     }
     mValue = mFuncR == null ? null : mFuncR.getOutput();
     if (mCast != null)
     {
         mValue = mCast.castValue(mValue);
     }
     return(0);
 }
Beispiel #21
0
 public IRTSDefine.Stack run(IRTSStack stack)
 {
     while (mFuncNames != null && mFuncCur < mFuncNames.Length)
     {
         mFunc  = stack.getThread().getEngine().getFunction(mFuncNames[mFuncCur++], mArgC);
         mFuncR = mFunc == null ? null : mFunc.createRunner(mArgs);
         if (stack.getThread().loadRunner(mFuncR))
         {
             return(0);
         }
     }
     mValue = mFuncR == null ? null : mFuncR.getOutput();
     if (mCast != null)
     {
         mValue = mCast.castValue(mValue);
     }
     return(0);
 }
Beispiel #22
0
        override public IRTSRunner createRunner()
        {
            IRTSRunner r = null;

            if (mId == IRTSDefine.Linker.VARIABLE)
            {
                if (mConst == null && !mBeConst)
                {
                    r = new RTSVariableR(mProperty, mCastType, mSrc);
                }
                else
                {
                    r = new RTSVariableR(mCastType, mConst);
                }
                return(r);
            }
            else if (mId == IRTSDefine.Linker.FUNCTION)
            {
                RTSList <IRTSLinker> lins = ((RTSBracketL)mArg).getChildAsList();
                RTSList <IRTSRunner> lrs  = null;
                if (lins != null)
                {
                    lrs = new RTSList <IRTSRunner>(lins.length());
                    for (int i = 0; i < lins.length(); i++)
                    {
                        IRTSLinker l = lins.get(i);
                        if (l == null)
                        {
                            lrs.add(null);
                        }
                        else
                        {
                            lrs.add(l.createRunner());
                        }
                    }
                }
                r = new RTSFuncR(mCastType, mSrc, lrs);
                return(r);
            }
            else
            {
                return(null);
            }
        }
 override public IRTSRunner createRunner()
 {
     if (mChild != null)
     {
         IRTSRunner r = mChild.createRunner();
         if (mCastType == null || r == null)
         {
             return(r);
         }
         else
         {
             return(new RTSCastR(mCastType, r));
         }
     }
     else
     {
         return(null);
     }
 }
 public IRTSDefine.Stack run(IRTSStack stack)
 {
     while (mRunners != null && mCur < mRunners.length())
     {
         IRTSLinker l = mRunners.get(mCur++);
         IRTSRunner r = l == null ? null : l.createRunner();
         if (r != null)
         {
             mLastRunner = r;
         }
         if (stack.getThread().loadRunner(r))
         {
             return(0);
         }
     }
     if (mLastRunner != null)
     {
         mValue = mLastRunner.getOutput();
     }
     return(0);
 }
Beispiel #25
0
        public override IRTSRunner createRunner()
        {
            IRTSRunner           r   = null;
            RTSList <IRTSRunner> lrs = null;

            if (mArgs.length() > 0)
            {
                lrs = new RTSList <IRTSRunner>(mArgs.length());
                for (int i = 0; i < mArgs.length(); i++)
                {
                    IRTSLinker l = mArgs.get(i);
                    if (l == null)
                    {
                        lrs.add(null);
                    }
                    else
                    {
                        lrs.add(l.createRunner());
                    }
                }
            }
            r = new RTSFuncR(null, "_" + mSrc, lrs);
            return(r);
        }
 public void loadedOnThread()
 {
     mChildLoaded = false;
     mLeft        = null;
     mRight       = null;
 }
Beispiel #27
0
 /**
  * 被运行线程(RTSThread)加载时调用,执行一些初始化操作
  */
 public void loadedOnThread()
 {
     child     = null;
     doCompile = !string.IsNullOrEmpty(source);
 }
Beispiel #28
0
 public void loadedOnThread()
 {
     mLoaded = false;
     mChild  = null;
 }
 public RTSSelfRaiseR(IRTSDefine.Linker operId, IRTSRunner var, bool varAtLeft)
 {
     mOperId = operId;
     mVar    = var;
     mLeft   = varAtLeft;
 }
 public IRTSDefine.Stack run(IRTSStack stack)
 {
     if (!mVarLoaded)
     {
         mVarLoaded = true;
         mVarR      = mVar == null ? null : mVar.createRunner();
         if (stack.getThread().loadRunner(mVarR))
         {
             return(0);
         }
     }
     if (!mIndexLoaded)
     {
         mIndexLoaded = true;
         mIndexR      = mIndex == null ? null : mIndex.createRunner();
         if (stack.getThread().loadRunner(mIndexR))
         {
             return(0);
         }
     }
     while (mArray != null && mListCur < mArray.length())
     {
         IRTSLinker l = mArray.get(mListCur);
         mArrayR[mListCur] = l == null ? null : l.createRunner();
         if (stack.getThread().loadRunner(mArrayR[mListCur++]))
         {
             return(0);
         }
     }
     if (mArrayR != null)
     {
         //org.vr.rts.typedef.RTSarray arr = new org.vr.rts.typedef.RTSarray(mArrayR.Length);
         object[] arr = new object[mArrayR.Length];
         for (int i = 0; i < mArrayR.Length; i++)
         {
             object v = mArrayR[i] == null ? null : mArrayR[i].getOutput();
             //arr.set(i, v);
             arr[i] = v;
         }
         mValue = arr;
     }
     else if (mVarR == null)
     {
         mValue = new object[0];
     }
     else
     {
         object obj   = mVarR.getOutput();
         object index = mIndexR == null ? null : mIndexR.getOutput();
         if (obj == null)
         {
             mValue = null;
         }
         else if (index is string)
         {
             var      eng = stack.getThread().getEngine();
             IRTSType tp  = eng.getRTSType(obj.GetType());
             mValue = tp.getProperty(eng, obj, RTSString.stringOf(index));
         }
         else if (obj is System.Collections.IList)
         {
             int n = RTSInteger.valueOf(index);
             mValue = ((System.Collections.IList)obj)[n];
         }
         else
         {
             int n = RTSInteger.valueOf(index);
             mValue = n == 0 ? obj : null;
         }
         mOutput = mValue as IRTSRunner;
         if (stack.getThread().loadRunner(mOutput))
         {
             return(0);
         }
     }
     if (mOutput != null)
     {
         mValue  = mOutput.getOutput();
         mOutput = mValue as IRTSRunner;
         if (stack.getThread().loadRunner(mOutput))
         {
             return(0);
         }
     }
     return(0);
 }