本文整理汇总了C#中ProtoCore.AddContextData方法的典型用法代码示例。如果您正苦于以下问题:C# ProtoCore.AddContextData方法的具体用法?C# ProtoCore.AddContextData怎么用?C# ProtoCore.AddContextData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProtoCore
的用法示例。
在下文中一共展示了ProtoCore.AddContextData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
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;
}
示例2: Execute
/// <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;
}
示例3: Execute
/// <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);
int blockId = ProtoCore.DSASM.Constants.kInvalidIndex;
bool succeeded = Compile(staticContext, core, out blockId);
if (succeeded)
{
core.GenerateExecutable();
runtimeCore = Execute(core, blockId, staticContext);
if (!isTest)
{
runtimeCore.RuntimeMemory.Heap.Free();
}
}
else
{
throw new ProtoCore.Exceptions.CompileErrorsOccured();
}
runtimeCoreOut = runtimeCore;
if (isTest && !core.Options.CompileToLib)
{
return new ExecutionMirror(runtimeCore.CurrentExecutive.CurrentDSASMExec, runtimeCore);
}
return null;
}