/// <summary> /// Compile and execute the source that is stored in the static context /// </summary> /// <param name="staticContext"></param> /// <param name="runtimeContext"></param> /// <param name="core"></param> /// <param name="isTest"></param> /// <returns></returns> public ExecutionMirror Execute(ProtoCore.CompileTime.Context staticContext, ProtoCore.Runtime.Context runtimeContext, ProtoCore.Core core, bool isTest = true) { Validity.Assert(null != staticContext.SourceCode && String.Empty != staticContext.SourceCode); core.AddContextData(staticContext.GlobalVarList); int blockId = ProtoCore.DSASM.Constants.kInvalidIndex; bool succeeded = Compile(staticContext, core, out blockId); if (succeeded) { core.GenerateExecutable(); Validity.Assert(null != runtimeContext); Execute(core, blockId, staticContext, runtimeContext); if (!isTest) { core.Heap.Free(); } } else { throw new ProtoCore.Exceptions.CompileErrorsOccured(); } if (isTest && !core.Options.CompileToLib) { return(new ExecutionMirror(core.CurrentExecutive.CurrentDSASMExec, core)); } return(null); }
/// <summary> /// Compile and execute the source that is stored in the static context /// </summary> /// <param name="staticContext"></param> /// <param name="runtimeContext"></param> /// <param name="core"></param> /// <param name="isTest"></param> /// <returns></returns> public ExecutionMirror Execute( ProtoCore.CompileTime.Context staticContext, ProtoCore.Core core, out ProtoCore.RuntimeCore runtimeCoreOut, bool isTest = true) { Validity.Assert(null != staticContext.SourceCode && String.Empty != staticContext.SourceCode); ProtoCore.RuntimeCore runtimeCore = null; core.AddContextData(staticContext.GlobalVarList); string code = staticContext.SourceCode; bool succeeded = CompileAndGenerateExe(code, core, staticContext); if (succeeded) { runtimeCore = ExecuteVM(core); if (!isTest) { runtimeCore.RuntimeMemory.Heap.Free(); } } else { throw new ProtoCore.Exceptions.CompileErrorsOccured(); } runtimeCoreOut = runtimeCore; if (isTest) { return(new ExecutionMirror(runtimeCore.CurrentExecutive.CurrentDSASMExec, runtimeCore)); } return(null); }
public ExecutionMirror Execute(string code, ProtoCore.Core core, Dictionary <string, Object> values, bool isTest = true) { //Inject the context data values from external source. core.AddContextData(values); int blockId = ProtoCore.DSASM.Constants.kInvalidIndex; bool succeeded = Compile(code, core, out blockId); if (succeeded) { core.GenerateExecutable(); core.Rmem.PushGlobFrame(core.GlobOffset); core.RunningBlock = blockId; Execute(core, new ProtoCore.Runtime.Context()); if (!isTest) { core.Heap.Free(); } } else { throw new ProtoCore.Exceptions.CompileErrorsOccured(); } if (isTest && !core.Options.CompileToLib) { return(new ExecutionMirror(core.CurrentExecutive.CurrentDSASMExec, core)); } return(null); }