本文整理汇总了C#中ProtoCore.RuntimeCore类的典型用法代码示例。如果您正苦于以下问题:C# RuntimeCore类的具体用法?C# RuntimeCore怎么用?C# RuntimeCore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RuntimeCore类属于ProtoCore命名空间,在下文中一共展示了RuntimeCore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DebugRunnerRunOnly
internal static ProtoCore.Core DebugRunnerRunOnly(string code, out RuntimeCore runtimeCore)
{
ProtoCore.Core core;
DebugRunner fsr;
// Specify some of the requirements of IDE.
var options = new ProtoCore.Options();
options.ExecutionMode = ProtoCore.ExecutionMode.Serial;
options.SuppressBuildOutput = false;
options.GCTempVarsOnDebug = false;
string testPath = @"..\..\..\test\Engine\ProtoTest\ImportFiles\";
options.IncludeDirectories.Add(testPath);
core = new ProtoCore.Core(options);
core.Compilers.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Compiler(core));
core.Compilers.Add(ProtoCore.Language.kImperative, new ProtoImperative.Compiler(core));
fsr = new DebugRunner(core);
DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
CLRModuleType.ClearTypes();
//Run
fsr.PreStart(code);
DebugRunner.VMState vms = null;
vms = fsr.Run();
runtimeCore = fsr.runtimeCore;
return core;
}
示例2: TestRunnerRunOnly
internal static ProtoCore.Core TestRunnerRunOnly(string code, out RuntimeCore runtimeCore)
{
ProtoCore.Core core;
ProtoScript.Runners.ProtoScriptRunner fsr = new ProtoScriptRunner();
// Specify some of the requirements of IDE.
var options = new ProtoCore.Options();
options.ExecutionMode = ProtoCore.ExecutionMode.Serial;
string testPath = @"..\..\..\test\Engine\ProtoTest\ImportFiles\";
options.IncludeDirectories.Add(testPath);
core = new ProtoCore.Core(options);
core.Compilers.Add(ProtoCore.Language.Associative, new ProtoAssociative.Compiler(core));
core.Compilers.Add(ProtoCore.Language.Imperative, new ProtoImperative.Compiler(core));
fsr = new ProtoScriptRunner();
DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
CLRModuleType.ClearTypes();
//Run
runtimeCore = fsr.Execute(code, core);
return core;
}
示例3: Setup
public override void Setup()
{
// Create a dummy runtimeCore because these tests dont really need to execute
// The base class will expect to cleanup the runtimeCore
base.Setup();
runtimeCore = new RuntimeCore(new Heap());
}
示例4: SetUp
public void SetUp()
{
testCore = thisTest.SetupTestCore();
testRuntimeCore = new RuntimeCore(testCore.Heap, testCore.Options);
testExecutive = new TestExecutive(testRuntimeCore);
}
示例5: TestCompilerAndRuntimeComponent01
public void TestCompilerAndRuntimeComponent01()
{
String code =
@"
a = 10;
";
// Compile core
var opts = new Options();
opts.ExecutionMode = ExecutionMode.Serial;
ProtoCore.Core core = new Core(opts);
core.Compilers.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Compiler(core));
core.Compilers.Add(ProtoCore.Language.kImperative, new ProtoImperative.Compiler(core));
ProtoScriptRunner runner = new ProtoScriptRunner();
// Compiler instance
ProtoCore.DSASM.Executable dsExecutable;
bool compileSucceeded = runner.CompileMe(code, core, out dsExecutable);
Assert.IsTrue(compileSucceeded == true);
// Pass compile data to the runtime
RuntimeCore runtimeCore = new RuntimeCore(core.Heap);
runtimeCore.SetProperties(core.Options, dsExecutable);
// Runtime
ExecutionMirror mirror = runner.ExecuteMe(runtimeCore);
Obj o = mirror.GetValue("a");
示例6: GetExactMatchStatistics
/// <summary>
/// For a given list of formal parameters, get the function end points that resolve
/// </summary>
/// <param name="context"></param>
/// <param name="formalParams"></param>
/// <param name="replicationInstructions"></param>
/// <param name="stackFrame"></param>
/// <param name="core"></param>
/// <param name="unresolvable">The number of argument sets that couldn't be resolved</param>
/// <returns></returns>
public Dictionary<FunctionEndPoint, int> GetExactMatchStatistics(
Runtime.Context context,
List<List<StackValue>> reducedFormalParams, StackFrame stackFrame, RuntimeCore runtimeCore, out int unresolvable)
{
List<ReplicationInstruction> replicationInstructions = new List<ReplicationInstruction>(); //We've already done the reduction before calling this
unresolvable = 0;
Dictionary<FunctionEndPoint, int> ret = new Dictionary<FunctionEndPoint, int>();
foreach (List<StackValue> formalParamSet in reducedFormalParams)
{
List<FunctionEndPoint> feps = GetExactTypeMatches(context,
formalParamSet, replicationInstructions, stackFrame,
runtimeCore);
if (feps.Count == 0)
{
//We have an arugment set that couldn't be resolved
unresolvable++;
}
foreach (FunctionEndPoint fep in feps)
{
if (ret.ContainsKey(fep))
ret[fep]++;
else
ret.Add(fep, 1);
}
}
return ret;
}
示例7: RegisterExtensionApplicationType
public bool RegisterExtensionApplicationType(RuntimeCore runtimeCore, SysType type)
{
if (!typeof(IExtensionApplication).IsAssignableFrom(type))
return false;
FFIExecutionSession session = GetSession(runtimeCore, true);
session.AddExtensionAppType(type);
return true;
}
示例8: SetUp
public void SetUp()
{
testCore = thisTest.SetupTestCore();
testRuntimeCore = new RuntimeCore(testCore.Heap);
testRuntimeCore.SetProperties(testCore.Options, null);
testExecutive = new TestExecutive(testRuntimeCore);
}
示例9: TestRunnerRunOnly
internal static ProtoCore.Core TestRunnerRunOnly(string includePath, string code,
Dictionary<int, List<string>> map, string geometryFactory,
string persistentManager, out ExecutionMirror mirror, out RuntimeCore runtimeCoreOut)
{
ProtoCore.Core core;
ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScriptTestRunner();
ProtoScript.Config.RunConfiguration runnerConfig;
// Specify some of the requirements of IDE.
var options = new ProtoCore.Options();
options.ExecutionMode = ProtoCore.ExecutionMode.Serial;
options.SuppressBuildOutput = false;
options.WatchTestMode = true;
// Cyclic dependency threshold is lowered from the default (2000)
// as this causes the test framework to be painfully slow
options.kDynamicCycleThreshold = 5;
// Pass the absolute path so that imported filepaths can be resolved
// in "FileUtils.GetDSFullPathName()"
includePath = Path.GetDirectoryName(includePath);
options.IncludeDirectories.Add(includePath);
//StreamWriter sw = File.CreateText(executionLogFilePath);
TextOutputStream fs = new TextOutputStream(map);
core = new ProtoCore.Core(options);
core.Configurations.Add(ConfigurationKeys.GeometryXmlProperties, true);
//core.Configurations.Add(ConfigurationKeys.GeometryFactory, geometryFactory);
//core.Configurations.Add(ConfigurationKeys.PersistentManager, persistentManager);
// By specifying this option we inject a mock Executive ('InjectionExecutive')
// that prints stackvalues at every assignment statement
// by overriding the POP_handler instruction - pratapa
//core.ExecutiveProvider = new InjectionExecutiveProvider();
core.BuildStatus.MessageHandler = fs;
core.Compilers.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Compiler(core));
core.Compilers.Add(ProtoCore.Language.kImperative, new ProtoImperative.Compiler(core));
runnerConfig = new ProtoScript.Config.RunConfiguration();
runnerConfig.IsParrallel = false;
DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
//Run
mirror = fsr.Execute(code, core, out runtimeCoreOut);
//sw.Close();
return core;
}
示例10: GetSession
private FFIExecutionSession GetSession(RuntimeCore runtimeCore, bool createIfNone)
{
FFIExecutionSession session = null;
lock (mSessions)
{
if (!mSessions.TryGetValue(runtimeCore, out session) && createIfNone)
{
session = new FFIExecutionSession(runtimeCore);
runtimeCore.ExecutionEvent += OnExecutionEvent;
runtimeCore.Dispose += OnDispose;
mSessions.Add(runtimeCore, session);
}
}
return session;
}
示例11: OnDispose
private void OnDispose(RuntimeCore sender)
{
if (mSessions == null)
return;
FFIExecutionSession session = null;
lock (mSessions)
{
if (mSessions.TryGetValue(sender, out session))
{
mSessions.Remove(sender);
session.Dispose();
sender.Dispose -= OnDispose;
sender.ExecutionEvent -= OnExecutionEvent;
}
mSelf = null;
}
}
示例12: CanGetExactMatchStatics
/// <summary>
/// For a given list of formal parameters, get the function end points that resolve
/// </summary>
/// <param name="context"></param>
/// <param name="formalParams"></param>
/// <param name="replicationInstructions"></param>
/// <param name="stackFrame"></param>
/// <param name="core"></param>
/// <param name="unresolvable">The number of argument sets that couldn't be resolved</param>
/// <returns></returns>
public bool CanGetExactMatchStatics(
Runtime.Context context,
List<List<StackValue>> reducedFormalParams,
StackFrame stackFrame,
RuntimeCore runtimeCore,
out HashSet<FunctionEndPoint> lookup)
{
lookup = new HashSet<FunctionEndPoint>();
foreach (List<StackValue> formalParamSet in reducedFormalParams)
{
List<FunctionEndPoint> feps = GetExactTypeMatches(context, formalParamSet, new List<ReplicationInstruction>(), stackFrame, runtimeCore);
if (feps.Count == 0)
{
return false;
}
foreach (FunctionEndPoint fep in feps)
{
lookup.Add(fep);
}
}
return true;
}
示例13: Apply
public void Apply(ProtoCore.Core core, RuntimeCore runtimeCore, ChangeSetData changeSet)
{
Validity.Assert(null != changeSet);
this.core = core;
this.runtimeCore = runtimeCore;
ApplyChangeSetDeleted(changeSet);
ApplyChangeSetModified(changeSet);
ApplyChangeSetForceExecute(changeSet);
}
示例14: CreateRuntimeCore
/// <summary>
/// Cretes a new instance of the RuntimeCore object
/// </summary>
private void CreateRuntimeCore()
{
runtimeCore = new ProtoCore.RuntimeCore(runnerCore.Heap, runnerCore.Options);
}
示例15: GetCallSite
/// <summary>
/// Retrieves an existing instance of a callsite associated with a UID
/// It creates a new callsite if non was found
/// </summary>
/// <param name="core"></param>
/// <param name="uid"></param>
/// <returns></returns>
public CallSite GetCallSite(int classScope, string methodName, Executable executable, RuntimeCore runtimeCore)
{
Validity.Assert(null != executable.FunctionTable);
CallSite csInstance = null;
var graphNode = executable.ExecutingGraphnode;
var topGraphNode = graphNode;
// If it is a nested function call, append all callsite ids
List<string> callsiteIdentifiers = new List<string>();
foreach (var prop in runtimeCore.InterpreterProps)
{
if (prop != null && prop.executingGraphNode != null && graphNode != prop.executingGraphNode)
{
topGraphNode = prop.executingGraphNode;
if (!string.IsNullOrEmpty(topGraphNode.CallsiteIdentifier))
{
callsiteIdentifiers.Add(topGraphNode.CallsiteIdentifier);
}
}
}
if (graphNode != null)
{
callsiteIdentifiers.Add(graphNode.CallsiteIdentifier);
}
var callsiteID = string.Join(";", callsiteIdentifiers.ToArray());
// TODO Jun: Currently generates a new callsite for imperative and
// internally generated functions.
// Fix the issues that cause the cache to go out of sync when
// attempting to cache internal functions. This may require a
// secondary callsite cache for internal functions so they dont
// clash with the graphNode UID key
var language = executable.instrStreamList[runtimeCore.RunningBlock].language;
bool isImperative = language == Language.Imperative;
bool isInternalFunction = CoreUtils.IsInternalFunction(methodName);
if (isInternalFunction || isImperative)
{
csInstance = new CallSite(classScope,
methodName,
executable.FunctionTable,
runtimeCore.Options.ExecutionMode);
}
else if (!CallsiteCache.TryGetValue(callsiteID, out csInstance))
{
// Attempt to retrieve a preloaded callsite data (optional).
var traceData = GetAndRemoveTraceDataForNode(topGraphNode.guid, callsiteID);
csInstance = new CallSite(classScope,
methodName,
executable.FunctionTable,
runtimeCore.Options.ExecutionMode,
traceData);
CallsiteCache[callsiteID] = csInstance;
CallSiteToNodeMap[csInstance.CallSiteID] = topGraphNode.guid;
}
if (graphNode != null && !CoreUtils.IsDisposeMethod(methodName))
{
csInstance.UpdateCallSite(classScope, methodName);
if (runtimeCore.Options.IsDeltaExecution)
{
runtimeCore.RuntimeStatus.ClearWarningForExpression(graphNode.exprUID);
}
}
return csInstance;
}