public bool Execute(string cmd, int threadId) { if (!string.IsNullOrEmpty(cmd)) { int tid = FindFreeThread(threadId); IRTSThread t = tid == -1 ? null : mThreads[tid]; if (t == null) { return(false); } mCompiler.reset(); mCompiler.loadSource(cmd); while (mCompiler.isCompiling()) { IRTSDefine.Error error = mCompiler.onCompile(mEngine); if (error != 0) { logError("rts compile error:" + RTSUtil.getEnumDescript(typeof(IRTSDefine.Error), (int)error) + "-" + mCompiler.getCompilingLinker()); return(false); } } IRTSLinker root = mCompiler.getRootLinker(); if (root != null) { bool ret = t.loadRunner(root.createRunner()); mExecUpdate |= ret; return(ret); } return(false); } return(false); }
/** * 在运行线程(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 object ExecuteImmediate(string cmd) { mCompiler.reset(); mCompiler.loadSource(cmd); while (mCompiler.isCompiling()) { IRTSDefine.Error error = mCompiler.onCompile(mEngine); if (error != 0) { logError("rts compile error:" + RTSUtil.getEnumDescript(typeof(IRTSDefine.Error), (int)error) + "-" + mCompiler.getCompilingLinker()); return(null); } } IRTSLinker root = mCompiler.getRootLinker(); if (root != null) { mImmediateT.loadRunner(root.createRunner()); while (!mImmediateT.isFinished()) { try { mImmediateT.run(mEngine); } catch (System.Exception ex) { mImmediateT.catchError(IRTSDefine.Error.Runtime_IndexOutOfBounds, ex.ToString()); break; } } return(mImmediateT.getOutput()); } else { return(null); } }