public CFibre(CFibreScript Script, CFibreReg FunctionReg, int ArgCount, CFibreRegStore Data, CFibreRegStore Global, CFibreRegStore Local, List <CFibreVM.InteropFuncDelegate> InteropFuncs) { mScript = Script; mFramePtr = 0; mData = Data; mGlobal = Global; mLocal = Local; mInteropFuncs = InteropFuncs; mStores = new CFibreRegStore[] { Data, Global, Local }; mCallFrames = new Stack <CFibreCallFrame>(); if (FunctionReg == null) { mInstructionPtr = 0; mCallFrames.Push(new CFibreCallFrame(mInstructionPtr, 0, 0)); } else { if (FunctionReg.mID < -1) { int funcIndex = -FunctionReg.mID - 10; mInteropFuncs[funcIndex](this, 0); } else { mInstructionPtr = FunctionReg.mID; mCallFrames.Push(new CFibreCallFrame(mInstructionPtr, 0, ArgCount)); } } }
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"); }
public void Compile(string ScriptFileName) { _script.CompileFile(ScriptFileName); _dataStore = new CFibreRegStore(); for (int i = 0; i < _script.mData.Count; ++i) { _dataStore.mStore[i] = _script.mData[i]; } //_script.PrintProgramListing(); }
private void _SetRegister(uint Register, CFibreReg Val) { int index = (int)(Register & 0x3FFFFFFF); int type = (int)(Register >> 30); CFibreRegStore stack = mStores[type]; if (type == 2) { stack.mStore[index + mFramePtr] = Val; } else { stack.mStore[index] = Val; } }
private CFibreReg _GetRegister(uint Register) { int index = (int)(Register & 0x3FFFFFFF); int type = (int)(Register >> 30); CFibreRegStore stack = mStores[type]; if (type == 2) { return(stack.mStore[index + mFramePtr]); } else { return(stack.mStore[index]); } }