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"); Assert.IsTrue((Int64)o.Payload == 10); }
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.kAssociative, new ProtoAssociative.Compiler(core)); core.Compilers.Add(ProtoCore.Language.kImperative, 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(); RuntimeCore runtimeCore = runner.LoadAndExecute(filename, core); long ms = sw.ElapsedMilliseconds; sw.Stop(); Console.WriteLine(ms); }
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.kAssociative, new ProtoAssociative.Compiler(core)); core.Compilers.Add(ProtoCore.Language.kImperative, 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(); }
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); Obj o = mirror.GetValue("a"); Assert.IsTrue((Int64)o.Payload == 10); }
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); }
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.ProtoScriptRunner fsr = new ProtoScriptRunner(); 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.Associative, new ProtoAssociative.Compiler(core)); core.Compilers.Add(ProtoCore.Language.Imperative, new ProtoImperative.Compiler(core)); DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper()); //Run runtimeCoreOut = fsr.Execute(code, core); mirror = runtimeCoreOut.Mirror; //sw.Close(); return(core); }
internal void TestRunnerRunOnly(string includePath, string code, Dictionary <int, List <string> > map /*, string executionLogFilePath*/) { ProtoScript.Runners.ProtoScriptRunner fsr = new ProtoScriptRunner(); // Specify some of the requirements of IDE. core.Options.ExecutionMode = ProtoCore.ExecutionMode.Serial; core.Options.SuppressBuildOutput = false; core.Options.WatchTestMode = true; core.Options.GCTempVarsOnDebug = false; // Cyclic dependency threshold is lowered from the default (2000) // as this causes the test framework to be painfully slow core.Options.kDynamicCycleThreshold = 5; // Pass the absolute path so that imported filepaths can be resolved // in "FileUtils.GetDSFullPathName()" if (!String.IsNullOrEmpty(includePath)) { includePath = Path.GetDirectoryName(includePath); core.Options.IncludeDirectories.Add(includePath); } //StreamWriter sw = File.CreateText(executionLogFilePath); TextOutputStream fs = new TextOutputStream(map); // 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.Associative, new ProtoAssociative.Compiler(core)); core.Compilers.Add(ProtoCore.Language.Imperative, new ProtoImperative.Compiler(core)); DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper()); //Run RuntimeCore runtimeCore = fsr.Execute(code, core); Mirror = runtimeCore.Mirror; //sw.Close(); runtimeCore.Cleanup(); }
static void Run(string filename, bool verbose) { if (!File.Exists(filename)) { Console.WriteLine("Cannot find file " + filename); return; } 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)); core.Options.DumpByteCode = verbose; core.Options.Verbose = verbose; ProtoFFI.DLLFFIHandler.Register(ProtoFFI.FFILanguage.CSharp, new ProtoFFI.CSModuleHelper()); ProtoScriptRunner runner = new ProtoScriptRunner(); RuntimeCore runtimeCore = null; ExecutionMirror mirror = runner.LoadAndExecute(filename, core, out runtimeCore); }
public void TestCompilerAndRuntimeComponent01() { String code = @" // DesignScript code here a = 10; " ; // Compile ProtoScriptRunner runner = new ProtoScriptRunner(); bool compileSucceeded = runner.CompileAndGenerateExe(code, core, new ProtoCore.CompileTime.Context()); Assert.IsTrue(compileSucceeded == true); // Execute runtimeCore = runner.ExecuteVM(core); // Verify ExecutionMirror mirror = new ExecutionMirror(runtimeCore.CurrentExecutive.CurrentDSASMExec, runtimeCore); Obj o = mirror.GetValue("a"); Assert.IsTrue((Int64)o.Payload == 10); }
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); }
public TestFrameWork() { runner = new ProtoScriptRunner(); }
public override void Setup() { base.Setup(); coreRunner = new ProtoScript.Runners.ProtoScriptRunner(); }