本文整理汇总了C#中ProtoCore.Core类的典型用法代码示例。如果您正苦于以下问题:C# Core类的具体用法?C# Core怎么用?C# Core使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Core类属于ProtoCore命名空间,在下文中一共展示了Core类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildStatus
// logs all errors and warnings by default
//
public BuildStatus(Core core,bool warningAsError, System.IO.TextWriter writer = null, bool errorAsWarning = false)
{
this.core = core;
//this.errorCount = 0;
//this.warningCount = 0;
warnings = new List<BuildData.WarningEntry>();
errors = new List<BuildData.ErrorEntry>();
this.warningAsError = warningAsError;
this.errorAsWarning = errorAsWarning;
if (writer != null)
{
consoleOut = System.Console.Out;
System.Console.SetOut(writer);
}
// Create a default console output stream, and this can
// be overwritten in IDE by assigning it a different value.
this.MessageHandler = new ConsoleOutputStream();
if (core.Options.WebRunner)
{
this.WebMsgHandler = new WebOutputStream(core);
}
}
示例2: SetUp
public void SetUp()
{
testCore = thisTest.SetupTestCore();
testRuntimeCore = new RuntimeCore(testCore.Heap, testCore.Options);
testExecutive = new TestExecutive(testRuntimeCore);
}
示例3: Run
static void Run(string filename, bool verbose)
{
if (!File.Exists(filename))
{
Console.WriteLine("Cannot find file " + filename);
return;
}
var profilingThread = new Thread(new ThreadStart(CollectingMemory));
profilingThread.Start();
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
var opts = new Options();
opts.ExecutionMode = ExecutionMode.Serial;
ProtoCore.Core core = new Core(opts);
core.Compilers.Add(ProtoCore.Language.Associative, new ProtoAssociative.Compiler(core));
core.Compilers.Add(ProtoCore.Language.Imperative, new ProtoImperative.Compiler(core));
core.Options.DumpByteCode = verbose;
core.Options.Verbose = verbose;
ProtoFFI.DLLFFIHandler.Register(ProtoFFI.FFILanguage.CSharp, new ProtoFFI.CSModuleHelper());
ProtoScriptRunner runner = new ProtoScriptRunner();
runner.LoadAndExecute(filename, core);
long ms = sw.ElapsedMilliseconds;
sw.Stop();
done = true;
profilingThread.Join();
Console.WriteLine("{0},{1},{2}", ms, maxNetMemory, maxPrivateWorkingSet);
}
示例4: CoreCodeGen
public CoreCodeGen(Core coreObj, ProtoCore.DSASM.CodeBlock parentBlock = null)
{
Debug.Assert(coreObj != null);
this.core = coreObj;
argOffset = 0;
globalClassIndex = core.ClassIndex;
if (null == CoreCodeGen.CodeRangeTable)
CoreCodeGen.CodeRangeTable = new CodeRangeTable();
if (null == CoreCodeGen.IdentLocation)
CoreCodeGen.IdentLocation = new IdentLocationTable();
if (null == CoreCodeGen.ImportTable)
CoreCodeGen.ImportTable = new ImportTable();
context = new ProtoCore.CompileTime.Context();
opKwData = new ProtoCore.DSASM.OpKeywordData();
targetLangBlock = ProtoCore.DSASM.Constants.kInvalidIndex;
enforceTypeCheck = true;
localProcedure = core.ProcNode;
globalProcIndex = null != localProcedure ? localProcedure.procId : ProtoCore.DSASM.Constants.kGlobalScope;
tryLevel = 0;
}
示例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: DevRun
static void DevRun()
{
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
var opts = new Options();
opts.ExecutionMode = ExecutionMode.Serial;
ProtoCore.Core core = new Core(opts);
core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));
#if DEBUG
core.Options.DumpByteCode = true;
core.Options.Verbose = true;
#else
core.Options.DumpByteCode = false;
core.Options.Verbose = false;
#endif
ProtoFFI.DLLFFIHandler.Register(ProtoFFI.FFILanguage.CSharp, new ProtoFFI.CSModuleHelper());
ProtoScriptTestRunner runner = new ProtoScriptTestRunner();
ExecutionMirror mirror = runner.LoadAndExecute(@"C:\Users\Yu\dev\github\test.ds", core);
long ms = sw.ElapsedMilliseconds;
sw.Stop();
Console.WriteLine(ms);
Console.ReadLine();
}
示例7: DevRun
static void DevRun()
{
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
var opts = new Options();
opts.ExecutionMode = ExecutionMode.Serial;
ProtoCore.Core core = new Core(opts);
core.Compilers.Add(ProtoCore.Language.Associative, new ProtoAssociative.Compiler(core));
core.Compilers.Add(ProtoCore.Language.Imperative, new ProtoImperative.Compiler(core));
#if DEBUG
core.Options.DumpByteCode = true;
core.Options.Verbose = true;
#else
core.Options.DumpByteCode = false;
core.Options.Verbose = false;
#endif
ProtoFFI.DLLFFIHandler.Register(ProtoFFI.FFILanguage.CSharp, new ProtoFFI.CSModuleHelper());
ProtoScriptRunner runner = new ProtoScriptRunner();
// Assuming current directory in test/debug mode is "...\Dynamo\bin\AnyCPU\Debug"
runner.LoadAndExecute(@"..\..\..\test\core\dsevaluation\DSFiles\test.ds", core);
long ms = sw.ElapsedMilliseconds;
sw.Stop();
Console.WriteLine(ms);
Console.ReadLine();
}
示例8: CodeGen
// This constructor is only called for Preloading of assemblies and
// precompilation of CodeBlockNode nodes in GraphUI for global language blocks - pratapa
public CodeGen(Core coreObj) : base(coreObj)
{
Validity.Assert(core.IsParsingPreloadedAssembly || core.IsParsingCodeBlockNode);
classOffset = 0;
// either of these should set the console to flood
//
emitReplicationGuide = false;
setConstructorStartPC = false;
// Re-use the existing procedureTable and symbolTable to access the built-in and predefined functions
ProcedureTable procTable = core.CodeBlockList[0].procedureTable;
codeBlock = BuildNewCodeBlock(procTable);
// Remove global symbols from existing symbol table for subsequent run in Graph UI
//SymbolTable sTable = core.CodeBlockList[0].symbolTable;
//sTable.RemoveGlobalSymbols();
//codeBlock = core.CodeBlockList[0];
compilePass = ProtoCore.CompilerDefinitions.Associative.CompilePass.kClassName;
// Bouncing to this language codeblock from a function should immediately set the first instruction as the entry point
if (ProtoCore.DSASM.Constants.kGlobalScope != globalProcIndex)
{
isEntrySet = true;
codeBlock.instrStream.entrypoint = 0;
}
unPopulatedClasses = new Dictionary<int, ClassDeclNode>();
}
示例9: CodeGen
public CodeGen(Core coreObj, ProtoCore.CompileTime.Context callContext, ProtoCore.DSASM.CodeBlock parentBlock = null) : base(coreObj, parentBlock)
{
context = callContext;
codeBlock = BuildNewCodeBlock();
if (null == parentBlock)
{
// This is a top level block
core.CodeBlockList.Add(codeBlock);
}
else
{
// This is a nested block
parentBlock.children.Add(codeBlock);
codeBlock.parent = parentBlock;
}
blockScope = 0;
// Bouncing to this language codeblock from a function should immediatlet se the first instruction as the entry point
if (ProtoCore.DSASM.Constants.kGlobalScope != globalProcIndex)
{
isEntrySet = true;
codeBlock.instrStream.entrypoint = 0;
}
backpatchMap = new BackpatchMap();
nodeBuilder = new NodeBuilder(core);
}
示例10: TestCompilerAndRuntimeComponent01
public void TestCompilerAndRuntimeComponent01()
{
String code =
@"
// Any DS code goes here
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();
// Compile
bool compileSucceeded = runner.CompileAndGenerateExe(code, core);
Assert.IsTrue(compileSucceeded == true);
// Execute
RuntimeCore runtimeCore = runner.ExecuteVM(core);
// Verify
ExecutionMirror mirror = new ExecutionMirror(runtimeCore.CurrentExecutive.CurrentDSASMExec, runtimeCore);
示例11: TestRunnerRunOnly
internal static ProtoCore.Core TestRunnerRunOnly(string code, out RuntimeCore runtimeCore)
{
ProtoCore.Core core;
ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScriptTestRunner();
// Specify some of the requirements of IDE.
var options = new ProtoCore.Options();
options.ExecutionMode = ProtoCore.ExecutionMode.Serial;
options.SuppressBuildOutput = 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 ProtoScriptTestRunner();
DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
CLRModuleType.ClearTypes();
//Run
fsr.Execute(code, core, out runtimeCore);
return core;
}
示例12: ImperativeCodeGen
public ImperativeCodeGen(Core coreObj, ProtoCore.DSASM.CodeBlock parentBlock = null)
: base(coreObj, parentBlock)
{
// dumpbytecode is optionally enabled
//
astNodes = new List<ImperativeNode>();
SetCompileOptions();
// Create a new symboltable for this block
// Set the new symbol table's parent
// Set the new table as a child of the parent table
codeBlock = new ProtoCore.DSASM.CodeBlock(
ProtoCore.DSASM.CodeBlockType.kLanguage,
ProtoCore.Language.kImperative,
core.CodeBlockIndex,
new ProtoCore.DSASM.SymbolTable("imperative lang block", core.RuntimeTableIndex),
new ProtoCore.DSASM.ProcedureTable(core.RuntimeTableIndex));
++core.CodeBlockIndex;
++core.RuntimeTableIndex;
core.CodeBlockList.Add(codeBlock);
if (null != parentBlock)
{
// This is a nested block
parentBlock.children.Add(codeBlock);
codeBlock.parent = parentBlock;
}
blockScope = 0;
}
示例13: EngineController
public EngineController(DynamoModel dynamoModel, string geometryFactoryFileName)
{
this.dynamoModel = dynamoModel;
// Create a core which is used for parsing code and loading libraries
libraryCore = new ProtoCore.Core(new Options()
{
RootCustomPropertyFilterPathName = string.Empty
});
libraryCore.Executives.Add(Language.kAssociative,new ProtoAssociative.Executive(libraryCore));
libraryCore.Executives.Add(Language.kImperative, new ProtoImperative.Executive(libraryCore));
libraryCore.ParsingMode = ParseMode.AllowNonAssignment;
libraryServices = new LibraryServices(libraryCore);
libraryServices.LibraryLoading += this.LibraryLoading;
libraryServices.LibraryLoadFailed += this.LibraryLoadFailed;
libraryServices.LibraryLoaded += this.LibraryLoaded;
liveRunnerServices = new LiveRunnerServices(dynamoModel, this, geometryFactoryFileName);
liveRunnerServices.ReloadAllLibraries(libraryServices.ImportedLibraries);
codeCompletionServices = new CodeCompletionServices(LiveRunnerCore);
astBuilder = new AstBuilder(dynamoModel, this);
syncDataManager = new SyncDataManager();
dynamoModel.NodeDeleted += NodeDeleted;
}
示例14: Run
static void Run(string filename, bool verbose)
{
if (!File.Exists(filename))
{
Console.WriteLine("Cannot find file " + filename);
return;
}
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
var opts = new Options();
opts.ExecutionMode = ExecutionMode.Serial;
ProtoCore.Core core = new Core(opts);
core.Compilers.Add(ProtoCore.Language.Associative, new ProtoAssociative.Compiler(core));
core.Compilers.Add(ProtoCore.Language.Imperative, new ProtoImperative.Compiler(core));
core.Options.DumpByteCode = verbose;
core.Options.Verbose = verbose;
ProtoFFI.DLLFFIHandler.Register(ProtoFFI.FFILanguage.CSharp, new ProtoFFI.CSModuleHelper());
ProtoScriptRunner runner = new ProtoScriptRunner();
runner.LoadAndExecute(filename, core);
long ms = sw.ElapsedMilliseconds;
sw.Stop();
Console.WriteLine(ms);
}
示例15: 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(
ProtoCore.Runtime.Context context,
List<List<StackValue>> reducedFormalParams, StackFrame stackFrame, Core core, 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,
core);
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;
}