public void ExecuteFibre(string FunctionName, CFibreReg[] Args = null) { CFibreReg funcDef; if (!_script.mFunctionDefs.TryGetValue(FunctionName, out funcDef)) { throw new CFibreRuntimeException("Tried to execute undefined fibre function: " + FunctionName); } int argCount = 0; if (Args != null) { argCount = Args.Length; } CFibre fibre = new CFibre(_script, funcDef, argCount, _dataStore, _globalStore, new CFibreRegStore(), _interopFuncs); for (int i = 0; i < argCount; ++i) { fibre.SetLocalRegister(i, Args[i]); } System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); CFibre.ERunResult result = fibre.Run(); sw.Stop(); //Debug.LogWarning("FibreVM: (" + FunctionName + ") " + sw.Elapsed.TotalMilliseconds + "ms"); //Debug.Log("Ret: " + fibre.GetLocalRegister(0).PrintVal()); //if (result == CFibre.ERunResult.CONTINUE) //_fibres.Add(fibre); }
public void ContinueFibre(CFibre Fibre, CFibreReg[] Args = null) { // Push args from wait result. // Can't just push arg to store since frame pointer is at caller local and not callee local. // Could stall frame pointer restore until here. CFibre.ERunResult result = Fibre.Run(); }
public void ExecuteGlobalFibre() { _globalStore = new CFibreRegStore(); CFibre globalFibre = new CFibre(_script, null, 0, _dataStore, _globalStore, _globalStore, _interopFuncs); // TODO: Merge with code below Debug.LogWarning("Executing global fibre"); System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); CFibre.ERunResult result = globalFibre.Run(); sw.Stop(); Debug.LogWarning("Global fibre completed in " + sw.Elapsed.TotalMilliseconds + "ms"); }