public bool evaluate(IRTSStack stack, object value) { if (!isConst()) { if (mCast != null) { mValue = mCast.castValue(value); } else { mValue = value; } if (mValue != RTSVoid.VOID) { if ((mProperty & IRTSDefine.Property.GLOBAL) != 0) { stack.getThread().getEngine().addVar(mVar, (mProperty & IRTSDefine.Property.DECALRE) == 0 ? value : mValue); } else { stack.addVar(mVar, (mProperty & IRTSDefine.Property.DECALRE) == 0 ? value : mValue); } } return(true); } else { stack.getThread().catchError(IRTSDefine.Error.Runtime_DenyEvaluate, mVar + " cannot be evaluated."); return(false); } }
public bool evaluate(IRTSStack stack, object value) { object obj = mVarR == null ? null : mVarR.getOutput(); object index = mIndexR == null ? null : mIndexR.getOutput(); if (obj == null) { return(false); } else if (index is int && obj is System.Collections.IList) { int n = RTSInteger.valueOf(index); ((System.Collections.IList)obj)[n] = value; mValue = value; return(true); } else if (index != null) { var eng = stack.getThread().getEngine(); var type = eng.getRTSType(obj.GetType()); mValue = type.setProperty(eng, obj, RTSString.stringOf(index), value); return(true); } else { return(false); } }
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 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 (!mVarLoaded) { mVarLoaded = true; if (stack.getThread().loadRunner(mVar)) { return(0); } } object obj = mVar.getOutput(); IRTSType tp = stack.getThread().getEngine().getRTSType(obj == null ? null : obj.GetType()); object newObj; if (mOperId == IRTSDefine.Linker.SELFADD) { newObj = tp.add(obj, 1); } else if (mOperId == IRTSDefine.Linker.SELFSUB) { newObj = tp.sub(obj, 1); } else { newObj = null; } mVar.evaluate(stack, newObj); mValue = mLeft ? obj : newObj; 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); }
public IRTSDefine.Stack run(IRTSStack stack) { IRTSEngine engine = stack.getThread().getEngine(); engine.addFunction(mFuncName, mFunction); return(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); }
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 (mVars != null) { IRTSEngine eng = stack.getThread().getEngine(); for (int i = 0; i < mVars.length(); i++) { RTSVariableL vl = mVars.get(i); if (vl == null) { continue; } bool var = vl.getId() == IRTSDefine.Linker.VARIABLE; if (!var) { eng.removeFunction(vl.getSrc(), vl.getArgc()); } else if ((vl.getProperty() & IRTSDefine.Property.GLOBAL) == 0) { stack.removeVar(vl.getSrc()); } else { eng.removeVar(vl.getSrc()); } } } return(0); }
override protected void onFinalRun(IRTSStack stack, object left, object right) { object t = left != null ? left : right; IRTSType tp = stack.getThread().getEngine().getRTSType(t == null ? null : t.GetType()); mValue = tp.xor(left, right); }
public RTSThread(int pid, int capacity) { Pid = pid; mRunners = new RTSList <IRTSRunner>(capacity); mStack = RTSStack.Factory.getStack(this, -1); mOutput = RTSVoid.VOID; mStackSize = RTSCfg.CALL_STACK_DEPTH; }
public void Interrupt() { mRunners.clear(); while (mStack.getId() >= 0) { mStack.onRemoved(); mStack = (RTSStack)mStack.getSuper(); } }
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); }
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 bool evaluate(IRTSStack stack, object value) { object domain = mLeftR == null ? null : mLeftR.getOutput(); if (domain == null) { return(false); } IRTSType tp = stack.getThread().getEngine().getRTSType(domain.GetType()); mValue = tp.setProperty(stack.getThread().getEngine(), domain, mDomain, value); return(true); }
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); }
override protected void onFinalRun(IRTSStack stack, object left, object right) { IRTSType tp; object t = left != null ? left : right; if (t != null) { tp = stack.getThread().getEngine().getRTSType(t.GetType()); } else { tp = org.vr.rts.modify.RTSGeneral.TYPE; } switch (mId) { case IRTSDefine.Linker.ADD: mValue = tp.add(left, right); break; case IRTSDefine.Linker.SUB: mValue = tp.sub(left, right); break; case IRTSDefine.Linker.MUL: mValue = tp.mul(left, right); break; case IRTSDefine.Linker.DIV: mValue = tp.div(left, right); break; case IRTSDefine.Linker.MOD: mValue = tp.mod(left, right); break; case IRTSDefine.Linker.BITAND: mValue = tp.and(left, right); break; case IRTSDefine.Linker.BITOR: mValue = tp.or(left, right); break; case IRTSDefine.Linker.XOR: mValue = tp.xor(left, right); break; default: break; } }
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(); } } }
public IRTSDefine.Stack run(IRTSStack stack) { if (!mLoaded) { mLoaded = true; if (stack.getThread().loadRunner(mChild)) { return(0); } } object o = mChild == null ? null : mChild.getOutput(); mValue = !org.vr.rts.modify.RTSBool.valueOf(o); return(0); }
public IRTSDefine.Stack run(IRTSStack stack) { if (mRuntime != null) { mRuntime.Yield(); } if (mWait) { return(IRTSDefine.Stack.ACTION_HOLD); } else { return(0); } }
public IRTSDefine.Stack run(IRTSStack stack) { if (!mChildLoaded) { mChildLoaded = true; if (stack.getThread().loadRunner(mChild)) { return(0); } } object v = mChild == null ? null : mChild.getOutput(); mValue = mCastType == null ? v : mCastType.castValue(v); return(0); }
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); }
public IRTSDefine.Stack run(IRTSStack stack) { if (mRuntime != null && mChild != null) { int ret = mRuntime.LoadRunner(mChild.createRunner(), -1); if (mCastType != null) { mResult = mCastType.castValue(ret); } else { mResult = ret; } } return(0); }
override protected void onFinalRun(IRTSStack stack, object left, object right) { IRTSType tp = null; object t = left != null ? left : right; if (t != null) { tp = stack.getThread().getEngine().getRTSType(t.GetType()); } if (tp == null) { tp = org.vr.rts.modify.RTSGeneral.TYPE; } int cp = tp.rtsCompare(left, right); setFinalV(cp); }
public bool evaluate(IRTSStack stack, object value) { object obj = mVarR == null ? null : mVarR.getOutput(); object index = mIndexR == null ? null : mIndexR.getOutput(); int n = RTSInteger.valueOf(index); if (obj != null && obj is System.Collections.IList) { ((System.Collections.IList)obj)[n] = value; mValue = value; return(true); } else { return(false); } }
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); }
public void catchError(IRTSDefine.Error error, object msg) { if (mEngine != null) { IRTSLog log = mEngine.getLogger(); if (log != null) { log.logError(RTSUtil.getEnumDescript(typeof(IRTSDefine.Error), (int)error) + ":" + msg); } mRunners.clear(); } while (mStack.getId() >= 0) { IRTSStack stack = mStack; mStack = stack.getSuper(); stack.onRemoved(); } }
public IRTSDefine.Stack run(IRTSStack stack) { if (isConst()) { return(0); } if ((mProperty & IRTSDefine.Property.GLOBAL) == 0) { mValue = stack.getVar(mVar); } else { mValue = stack.getThread().getEngine().getVar(mVar); } if (mCast != null) { mValue = mCast.castValue(mValue); } return(0); }
object setValue(object[] args) { int pid = RTSInteger.valueOf(args[0]); if (mThreads != null && pid >= 0 && pid < mThreads.Length) { RTSThread t = mThreads[pid]; if (t == null) { return(false); } IRTSStack stack = t.getStack(); if (stack == null) { return(false); } stack.addVar(RTSString.stringOf(args[1]), args[2]); return(true); } return(false); }