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); }
public object ExecuteFunction(string funcName, object[] args, bool immediate) { if (RTSUtil.isGoodName(funcName)) { IRTSThread t = null; if (immediate) { t = mImmediateT; } else { int p = 0; for (int i = 1; i <= mThreads.Length; i++) { p = i % mThreads.Length; if (mThreads[p].isFinished()) { t = mThreads[p]; break; } } } if (t == null || !t.isFinished()) { return(false); } IRTSFunction func = mEngine.getFunction(funcName, args == null ? 0 : args.Length); if (func == null) { return(false); } bool ret = t.loadRunner(func.createRunner(args)); if (immediate) { while (!t.isFinished()) { t.run(mEngine); } return(t.getOutput()); } else { mExecUpdate |= ret; return(ret); } } else { return(null); } }