Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        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.GCTempVarsOnDebug = false;

            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 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);
        }
Ejemplo n.º 3
0
        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);
Ejemplo n.º 4
0
        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);
        }
        private void SetupCommonRunner(bool inDebugMode)
        {
            var options = new ProtoCore.Options();

            options.Verbose             = GetDisplayOutput();
            options.ExecutionMode       = ProtoCore.ExecutionMode.Serial;
            options.SuppressBuildOutput = false;
            options.IDEDebugMode        = inDebugMode;
            AppendSearchPaths(options);

            this.core = new ProtoCore.Core(options);
            this.core.CurrentDSFileName = options.RootModulePathName;
            this.core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(this.core));
            this.core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(this.core));

            // Get configuration from host app
            var configurations = Solution.Current.ExecutionSession.HostApplication.Configurations;

            if (configurations != null)
            {
                foreach (var item in configurations)
                {
                    this.core.Configurations[item.Key] = item.Value;
                }
            }

            IOutputStream messageList = Solution.Current.GetMessage(false);

            this.core.RuntimeStatus.MessageHandler = messageList;

            workerParams.RegularRunMirror = null;
            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
            asynchronousExecution = Solution.Current.Asynchronous;
        }
        private void AppendSearchPaths(ProtoCore.Options options)
        {
            string assemblyPath = Assembly.GetAssembly(typeof(ExecutionSession)).Location;

            options.IncludeDirectories.Add(Path.GetDirectoryName(assemblyPath));

            ITextEditorSettings editorSettings = TextEditorCore.Instance.TextEditorSettings;

            if (Directory.Exists(editorSettings.IncludePath))
            {
                options.IncludeDirectories.Add(editorSettings.IncludePath);
            }

            IScriptObject entryPointScript = Solution.Current.ActiveScript;

            if (null != entryPointScript)
            {
                IParsedScript parsedScript = entryPointScript.GetParsedScript();
                if (null != parsedScript)
                {
                    string scriptPath = parsedScript.GetScriptPath();
                    options.RootModulePathName = parsedScript.GetScriptPath();

                    if (string.IsNullOrEmpty(scriptPath) == false)
                    {
                        string directoryName = Path.GetDirectoryName(scriptPath);
                        options.IncludeDirectories.Add(directoryName);
                    }
                }
            }
        }
Ejemplo n.º 7
0
        internal static ProtoCore.Core DebugRunnerRunOnly(string code)
        {
            ProtoCore.Core core;
            DebugRunner    fsr;

            ProtoScript.Config.RunConfiguration runnerConfig;
            string testPath = @"..\..\..\Scripts\Debugger\";

            // Specify some of the requirements of IDE.
            var options = new ProtoCore.Options();

            options.ExecutionMode       = ProtoCore.ExecutionMode.Serial;
            options.SuppressBuildOutput = false;

            core = new ProtoCore.Core(options);
            core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
            core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));

            runnerConfig             = new ProtoScript.Config.RunConfiguration();
            runnerConfig.IsParrallel = false;
            fsr = new DebugRunner(core);

            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
            CLRModuleType.ClearTypes();

            //Run

            fsr.PreStart(code, runnerConfig);
            DebugRunner.VMState vms = null;

            vms = fsr.Run();

            return(core);
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
        internal static ProtoCore.Core TestRunnerRunOnly(string code)
        {
            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;

            string testPath = @"..\..\..\test\Engine\ProtoTest\ImportFiles\";

            options.IncludeDirectories.Add(testPath);

            core = new ProtoCore.Core(options);
            core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
            core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));

            runnerConfig             = new ProtoScript.Config.RunConfiguration();
            runnerConfig.IsParrallel = false;
            fsr = new ProtoScriptTestRunner();

            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
            CLRModuleType.ClearTypes();

            //Run

            fsr.Execute(code, core);

            return(core);
        }
Ejemplo n.º 10
0
        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;
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        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();
        }
Ejemplo n.º 13
0
        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");
Ejemplo n.º 14
0
        internal static ProtoCore.Core TestRunnerRunOnly(string includePath, string code,
                                                         Dictionary <int, List <string> > map, string geometryFactory,
                                                         string persistentManager, out ExecutionMirror mirror)
        {
            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);

            //sw.Close();

            return(core);
        }
Ejemplo n.º 15
0
        /// <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(GraphNode graphNode,
                                    int classScope,
                                    string methodName,
                                    Executable executable,
                                    int runningBlock,
                                    Options options,
                                    RuntimeStatus runtimeStatus
             )
        {
            Validity.Assert(null != executable.FunctionTable);
            CallSite csInstance = null;

            // 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[runningBlock].language;
            bool isImperative = language == Language.kImperative;
            bool isInternalFunction = CoreUtils.IsInternalFunction(methodName);

            if (isInternalFunction || isImperative)
            {
                csInstance = new CallSite(classScope,
                                          methodName,
                                          executable.FunctionTable,
                                          options.ExecutionMode);
            }
            else if (!CallsiteCache.TryGetValue(graphNode.CallsiteIdentifier, out csInstance))
            {
                // Attempt to retrieve a preloaded callsite data (optional).
                var traceData = GetAndRemoveTraceDataForNode(graphNode.guid);

                csInstance = new CallSite(classScope,
                                          methodName,
                                          executable.FunctionTable,
                                          options.ExecutionMode,
                                          traceData);

                CallsiteCache[graphNode.CallsiteIdentifier] = csInstance;
                CallSiteToNodeMap[csInstance.CallSiteID] = graphNode.guid;
                ASTToCallSiteMap[graphNode.AstID] = csInstance;

            }

            if (graphNode != null && !CoreUtils.IsDisposeMethod(methodName))
            {
                csInstance.UpdateCallSite(classScope, methodName);
                if (options.IsDeltaExecution)
                {
                    runtimeStatus.ClearWarningForExpression(graphNode.exprUID);
                }
            }

            return csInstance;
        }
Ejemplo n.º 16
0
        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;
        }
Ejemplo n.º 17
0
        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

#if __RUN_TESTFILE
            ProtoFFI.DLLFFIHandler.Register(ProtoFFI.FFILanguage.CSharp, new ProtoFFI.CSModuleHelper());
            ProtoScriptTestRunner runner = new ProtoScriptTestRunner();
            ExecutionMirror mirror = runner.LoadAndExecute(@"D:\jun\AutodeskResearch\git\designscript\Scripts\jun.ds", core);
#else
            // Insert test cases here

            //ProtoTest.LiveRunner.MicroFeatureTests test = new ProtoTest.LiveRunner.MicroFeatureTests();
            //test.Setup();
            //test.TestPythonCodeExecution();

            ProtoTest.Associative.MicroFeatureTests test = new ProtoTest.Associative.MicroFeatureTests();
            test.Setup();
           test.TestUpdateRedefinition01();

            //IntegrationTests.IncrementingTraceTests test = new IntegrationTests.IncrementingTraceTests();
            //test.Setup();
            //test.IntermediateValueIncrementerIDTestUpdate1DReplicated();

            //ProtoFFITests.CSFFIDispose test = new ProtoFFITests.CSFFIDispose();
            //test.Setup();
            //test.IntermediateValueIncrementerIDTestUpdate1DReplicated();
           // test.Dispose_FFITarget_Overridden();

            //ProtoTest.EventTests.PropertyChangedNotifyTest test = new ProtoTest.EventTests.PropertyChangedNotifyTest();
            //test.Setup();
            //test.RunPropertyChangedNegative();
            

#endif

            long ms = sw.ElapsedMilliseconds;
            sw.Stop();
            Console.WriteLine(ms);
            Console.ReadLine();
        }
Ejemplo n.º 18
0
        internal static ProtoCore.Core DebugRunnerStepOver(string code, out RuntimeCore runtimeCore)
        {
            //Internal setup

            ProtoCore.Core core;
            DebugRunner    fsr;

            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.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));


            runnerConfig             = new ProtoScript.Config.RunConfiguration();
            runnerConfig.IsParrallel = false;
            fsr = new DebugRunner(core);

            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
            CLRModuleType.ClearTypes();

            //Run

            fsr.PreStart(code, runnerConfig);
            DebugRunner.VMState vms = null;

            while (!fsr.isEnded)
            {
                vms = fsr.StepOver();
            }

            runtimeCore = fsr.runtimeCore;
            return(core);
        }
Ejemplo n.º 19
0
        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.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
            core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));
            core.Options.DumpByteCode = verbose;
            core.Options.Verbose = verbose;
            ProtoFFI.DLLFFIHandler.Register(ProtoFFI.FFILanguage.CSharp, new ProtoFFI.CSModuleHelper());

            ProtoScriptTestRunner runner = new ProtoScriptTestRunner();
            ExecutionMirror mirror = runner.LoadAndExecute(filename, core);
        }
Ejemplo n.º 20
0
        public RuntimeCore(Heap heap, Options options = null, Executable executable = null)
        {
            // The heap is initialized by the core and is used to allocate strings
            // Use the that heap for runtime
            Validity.Assert(heap != null);
            this.Heap = heap;
            RuntimeMemory = new RuntimeMemory(Heap);

            this.Options = options;

            InterpreterProps = new Stack<InterpreterProperties>();
            ReplicationGuides = new List<List<ReplicationGuide>>();
            AtLevels = new List<AtLevel>();
            executedAstGuids = new HashSet<Guid>();

            RunningBlock = 0;
            ExecutionState = (int)ExecutionStateEventArgs.State.Invalid; //not yet started

            ContinuationStruct = new ContinuationStructure();


            watchStack = new List<StackValue>();
            watchFramePointer = Constants.kInvalidIndex;
            WatchSymbolList = new List<SymbolNode>();

            FunctionCallDepth = 0;
            cancellationPending = false;

            watchClassScope = Constants.kInvalidIndex;

            ExecutionInstance = CurrentExecutive = new Executive(this);
            ExecutiveProvider = new ExecutiveProvider();

            RuntimeStatus = new ProtoCore.RuntimeStatus(this);
            StartPC = Constants.kInvalidPC;
            RuntimeData = new ProtoCore.RuntimeData();
            DSExecutable = executable;
            Mirror = null;
        }
Ejemplo n.º 21
0
        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
#if __RUN_TESTFILE

            ProtoFFI.DLLFFIHandler.Register(ProtoFFI.FFILanguage.CSharp, new ProtoFFI.CSModuleHelper());


            ProtoScriptTestRunner runner = new ProtoScriptTestRunner();
            ExecutionMirror mirror = runner.LoadAndExecute(@"defectverify.ds", core);

#else

            ProtoTest.GraphCompiler.MicroFeatureTests test = new ProtoTest.GraphCompiler.MicroFeatureTests();
            test.Setup();
            test.GraphILTest_Assign02();
            
#endif
            long ms = sw.ElapsedMilliseconds;
            sw.Stop();
            Console.WriteLine(ms);
            Console.ReadLine();
        }
Ejemplo n.º 22
0
        internal static ProtoCore.Core TestRunnerRunOnly(string code)
        {
            ProtoCore.Core core;
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScriptTestRunner();

            ProtoScript.Config.RunConfiguration runnerConfig;
            string testPath = @"..\..\..\Scripts\Debugger\";

            // Specify some of the requirements of IDE.
            var options = new ProtoCore.Options();
            options.ExecutionMode = ProtoCore.ExecutionMode.Serial;
            options.SuppressBuildOutput = false;

            core = new ProtoCore.Core(options);
            core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
            core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));

            runnerConfig = new ProtoScript.Config.RunConfiguration();
            runnerConfig.IsParrallel = false;
            fsr = new ProtoScriptTestRunner();

            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
            CLRModuleType.ClearTypes();

            //Run

            fsr.Execute(code, core);

            return core;
        }
Ejemplo n.º 23
0
        internal static ProtoCore.Core DebugRunnerStepOver(string code)
        {
            //Internal setup

            ProtoCore.Core core;
            DebugRunner fsr;
            ProtoScript.Config.RunConfiguration runnerConfig;
            string testPath = @"..\..\..\Scripts\Debugger\";

             // Specify some of the requirements of IDE.
            var options = new ProtoCore.Options();
            options.ExecutionMode = ProtoCore.ExecutionMode.Serial;
            options.SuppressBuildOutput = false;

            core = new ProtoCore.Core(options);
            core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
            core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));

            runnerConfig = new ProtoScript.Config.RunConfiguration();
            runnerConfig.IsParrallel = false;
            fsr = new DebugRunner(core);

            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
            CLRModuleType.ClearTypes();

            //Run

            fsr.PreStart(code, runnerConfig);
            DebugRunner.VMState vms = null;

            while (!fsr.isEnded)
                vms = fsr.StepOver();

            return core;
        }
Ejemplo n.º 24
0
        internal static void DebugRunnerStepIn(string includePath, string code, /*string logFile*/Dictionary<int, List<string>> map, 
            bool watchNestedMode = false, string defectID = "")
        {
            //Internal setup
            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;
            
            // 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()"
            if (!String.IsNullOrEmpty(includePath))
            {
                includePath = Path.GetDirectoryName(includePath);
                options.IncludeDirectories.Add(includePath);
            }
            
            
            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());
            
            //Run
            fsr.PreStart(code);


            RuntimeCore runtimeCore = fsr.runtimeCore;

            //StreamReader log = new StreamReader(logFile);

            //bool isPrevBreakAtPop = false;
            int lineAtPrevBreak = -1;
            string symbolName = null;
            DebugRunner.VMState vms = null;

            while (!fsr.isEnded)
            {
                vms = fsr.LastState;

                OpCode opCode = OpCode.NONE;
                DebugInfo debug = null;
                if (vms != null)
                {
                    // check if previous break is a POP
                    // if so, get the line no. and LHS
                    opCode = fsr.CurrentInstruction.opCode;
                    debug = fsr.CurrentInstruction.debug;

                    if (opCode == ProtoCore.DSASM.OpCode.POP)
                    {
                        //isPrevBreakAtPop = true;
                        lineAtPrevBreak = vms.ExecutionCursor.StartInclusive.LineNo;                       
                    }
                }

                DebugRunner.VMState currentVms = fsr.Step();

                //if (isPrevBreakAtPop)

                if (debug != null)
                {
                    // Do not do the verification for imported DS files, for which the FilePath is non null
                    if (debug.Location.StartInclusive.SourceLocation.FilePath == null)
                    {
                        if (opCode == ProtoCore.DSASM.OpCode.POP)
                        {
                            VerifyWatch_Run(lineAtPrevBreak, runtimeCore.DebugProps.CurrentSymbolName, core, runtimeCore, map, watchNestedMode, defectID: defectID);
                        }
                        // if previous breakpoint was at a CALLR
                        else if (opCode == ProtoCore.DSASM.OpCode.CALLR)
                        {
                            if (runtimeCore.DebugProps.IsPopmCall)
                            {
                                int ci = (int)currentVms.mirror.MirrorTarget.rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexClass).opdata;
                                VerifyWatch_Run(InjectionExecutive.callrLineNo, runtimeCore.DebugProps.CurrentSymbolName, core, runtimeCore, map, watchNestedMode, ci, defectID);
                            }
                        }
                    }
                }
                //isPrevBreakAtPop = false;
            }
            runtimeCore.Cleanup();
        }
Ejemplo n.º 25
0
 public WatchTestFx()
 {
     var options = new ProtoCore.Options();
     core = new ProtoCore.Core(options);
 }
Ejemplo n.º 26
0
        internal static void DebugRunnerStepIn(string includePath, string code, /*string logFile*/ Dictionary <int, List <string> > map, bool watchNestedMode = false)
        {
            //Internal setup
            ProtoCore.Core core;
            DebugRunner    fsr;

            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.GCTempVarsOnDebug   = false;

            // 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()"
            if (!String.IsNullOrEmpty(includePath))
            {
                includePath = Path.GetDirectoryName(includePath);
                options.IncludeDirectories.Add(includePath);
            }


            core = new ProtoCore.Core(options);

            // Use the InjectionExecutive to overload POP and POPM
            // as we still need the symbol names and line nos. in debug mode for comparisons
            core.ExecutiveProvider = new InjectionExecutiveProvider();

            core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
            core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));

            runnerConfig             = new ProtoScript.Config.RunConfiguration();
            runnerConfig.IsParrallel = false;
            fsr = new DebugRunner(core);

            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());

            //Run
            fsr.PreStart(code, runnerConfig);

            //StreamReader log = new StreamReader(logFile);

            //bool isPrevBreakAtPop = false;
            int    lineAtPrevBreak = -1;
            string symbolName      = null;

            DebugRunner.VMState vms = null;

            while (!fsr.isEnded)
            {
                vms = fsr.LastState;

                OpCode    opCode = OpCode.NONE;
                DebugInfo debug  = null;
                if (vms != null)
                {
                    // check if previous break is a POP
                    // if so, get the line no. and LHS
                    opCode = fsr.CurrentInstruction.opCode;
                    debug  = fsr.CurrentInstruction.debug;

                    if (opCode == ProtoCore.DSASM.OpCode.POP)
                    {
                        //isPrevBreakAtPop = true;
                        lineAtPrevBreak = vms.ExecutionCursor.StartInclusive.LineNo;
                    }
                }

                DebugRunner.VMState currentVms = fsr.Step();

                //if (isPrevBreakAtPop)

                if (debug != null)
                {
                    // Do not do the verification for imported DS files, for which the FilePath is non null
                    if (debug.Location.StartInclusive.SourceLocation.FilePath == null)
                    {
                        if (opCode == ProtoCore.DSASM.OpCode.POP)
                        {
                            VerifyWatch_Run(lineAtPrevBreak, core.DebugProps.CurrentSymbolName, core, map, watchNestedMode);
                        }
                        // if previous breakpoint was at a CALLR
                        else if (opCode == ProtoCore.DSASM.OpCode.CALLR)
                        {
                            if (core.DebugProps.IsPopmCall)
                            {
                                int ci = (int)currentVms.mirror.MirrorTarget.rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexClass).opdata;
                                VerifyWatch_Run(InjectionExecutive.callrLineNo, core.DebugProps.CurrentSymbolName, core, map, watchNestedMode, ci);
                            }
                        }
                    }
                }
                //isPrevBreakAtPop = false;
            }
            core.Cleanup();
        }
Ejemplo n.º 27
0
        private void InitCore()
        {
            coreOptions = new Options
            {
                IsDeltaExecution = true,
                BuildOptErrorAsWarning = true,
                ExecutionMode = ExecutionMode.Serial
            };

            runnerCore = new ProtoCore.Core(coreOptions);
            runnerCore.Compilers.Add(ProtoCore.Language.Associative, new ProtoAssociative.Compiler(runnerCore));
            runnerCore.Compilers.Add(ProtoCore.Language.Imperative, new ProtoImperative.Compiler(runnerCore));

            runnerCore.Options.RootModulePathName = configuration.RootModulePathName;
            runnerCore.Options.IncludeDirectories = configuration.SearchDirectories.ToList();
            foreach (var item in configuration.PassThroughConfiguration)
            {
                runnerCore.Configurations[item.Key] = item.Value;
            }

            vmState = null;

            CreateRuntimeCore();
        }
Ejemplo n.º 28
0
        internal  static ProtoCore.Core DebugRunnerRunOnly(string code)
        {
            ProtoCore.Core core;
            DebugRunner fsr;
            ProtoScript.Config.RunConfiguration runnerConfig;
            string testPath = @"..\..\..\test\Engine\ProtoTest\ImportFiles\";

            // Specify some of the requirements of IDE.
            var options = new ProtoCore.Options();
            options.ExecutionMode = ProtoCore.ExecutionMode.Serial;
            options.SuppressBuildOutput = false;
            options.GCTempVarsOnDebug = false;

            core = new ProtoCore.Core(options);
            core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
            core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));

            runnerConfig = new ProtoScript.Config.RunConfiguration();
            runnerConfig.IsParrallel = false;
            fsr = new DebugRunner(core);

            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
            CLRModuleType.ClearTypes();

            //Run

            fsr.PreStart(code, runnerConfig);
            DebugRunner.VMState vms = null;

            vms = fsr.Run();

            return core;
        }
Ejemplo n.º 29
0
        internal static ProtoCore.Core DebugRunerStepIn(string code, out RuntimeCore runtimeCore)
        {
            //Internal setup

            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;

            while (!fsr.isEnded)
                vms = fsr.Step();

            runtimeCore = fsr.runtimeCore;
            return core;

        }
Ejemplo n.º 30
0
        private void ResetAll(Options options)
        {
            ProtoCore.Utils.Validity.AssertExpiry();
            Options = options;
            Executives = new Dictionary<ProtoCore.Language, ProtoCore.Executive>();
            FunctionTable = new Lang.FunctionTable();
            ClassIndex = ProtoCore.DSASM.Constants.kInvalidIndex;

            Heap = new DSASM.Heap();
            Rmem = new ProtoCore.Runtime.RuntimeMemory(Heap);

            watchClassScope = ProtoCore.DSASM.Constants.kInvalidIndex;
            watchFunctionScope = ProtoCore.DSASM.Constants.kInvalidIndex;
            watchBaseOffset = 0;
            watchStack = new List<StackValue>();
            watchSymbolList = new List<SymbolNode>();
            watchFramePointer = ProtoCore.DSASM.Constants.kInvalidIndex;

            ID = FIRST_CORE_ID;

            //recurtion
            recursivePoint = new List<FunctionCounter>();
            funcCounterTable = new List<FunctionCounter>();
            calledInFunction = false;

            GlobOffset = 0;
            GlobHeapOffset = 0;
            BaseOffset = 0;
            GraphNodeUID = 0;
            RunningBlock = 0;
            CodeBlockIndex = 0;
            RuntimeTableIndex = 0;
            CodeBlockList = new List<DSASM.CodeBlock>();
            CompleteCodeBlockList = new List<DSASM.CodeBlock>();
            DSExecutable = new ProtoCore.DSASM.Executable();

            AssocNode = null;

            // TODO Jun/Luke type system refactoring
            // Initialize the globalClass table and type system
            ClassTable = new DSASM.ClassTable();
            TypeSystem = new TypeSystem();
            TypeSystem.SetClassTable(ClassTable);
            ProcNode = null;
            ProcTable = new DSASM.ProcedureTable(ProtoCore.DSASM.Constants.kGlobalScope);

            //Initialize the function pointer table
            FunctionPointerTable = new DSASM.FunctionPointerTable();

            //Initialize the dynamic string table and dynamic function table
            DynamicVariableTable = new DSASM.DynamicVariableTable();
            DynamicFunctionTable = new DSASM.DynamicFunctionTable();
            replicationGuides = new List<List<ProtoCore.ReplicationGuide>>();

            ExceptionHandlingManager = new ExceptionHandlingManager();
            startPC = ProtoCore.DSASM.Constants.kInvalidIndex;

            deltaCompileStartPC = ProtoCore.DSASM.Constants.kInvalidIndex;

            if (options.SuppressBuildOutput)
            {
                //  don't log any of the build related messages
                //  just accumulate them in relevant containers with
                //  BuildStatus object
                //
                BuildStatus = new BuildStatus(this, false, false, false);
            }
            else
            {
                BuildStatus = new BuildStatus(this, Options.BuildOptWarningAsError, null, Options.BuildOptErrorAsWarning);
            }
            RuntimeStatus = new RuntimeStatus(this);

            SSASubscript = 0;
            SSASubscript_GUID = System.Guid.NewGuid();
            ExpressionUID = 0;
            ModifierBlockUID = 0;
            ModifierStateSubscript = 0;

            ExprInterpreterExe = null;
            ExecMode = ProtoCore.DSASM.InterpreterMode.kNormal;

            assocCodegen = null;
            FunctionCallDepth = 0;

            // Default execution log is Console.Out.
            this.ExecutionLog = Console.Out;
            ExecutionState = (int)ExecutionStateEventArgs.State.kInvalid; //not yet started

            DebugProps = new DebugProperties();
            //stackNodeExecutedSameTimes = new Stack<List<AssociativeGraph.GraphNode>>();
            //stackExecutingGraphNodes = new Stack<AssociativeGraph.GraphNode>();
            InterpreterProps = new Stack<InterpreterProperties>();
            stackActiveExceptionRegistration = new Stack<ExceptionRegistration>();

            ExecutiveProvider = new ExecutiveProvider();

            Configurations = new Dictionary<string, object>();

            ContinuationStruct = new Lang.ContinuationStructure();
            ParsingMode = ProtoCore.ParseMode.Normal;
            
            IsParsingPreloadedAssembly = false;
            IsParsingCodeBlockNode = false;
            ImportHandler = null;

            deltaCompileStartPC = 0;
            builtInsLoaded = false;
            FFIPropertyChangedMonitor = new FFIPropertyChangedMonitor(this);

            csExecutionState = null;
            EnableCallsiteExecutionState = false;

            // TODO: Remove check once fully implemeted
            if (EnableCallsiteExecutionState)
            {
                csExecutionState = CallsiteExecutionState.LoadState();
            }
            else
            {
                csExecutionState = new CallsiteExecutionState();
            }
            CallsiteCache = new Dictionary<int, CallSite>();
            CachedSSANodes = new List<AssociativeNode>();
            CallSiteToNodeMap = new Dictionary<Guid, Guid>();
            ASTToCallSiteMap = new Dictionary<int, CallSite>();

            ForLoopBlockIndex = ProtoCore.DSASM.Constants.kInvalidIndex;

            GraphNodeCallList = new List<GraphNode>();

            newEntryPoint = ProtoCore.DSASM.Constants.kInvalidIndex;
        }
Ejemplo n.º 31
0
        private void ResetAll(Options options)
        {
            ProtoCore.Utils.Validity.AssertExpiry();
            Options = options;
            Executives = new Dictionary<ProtoCore.Language, ProtoCore.Executive>();
            FunctionTable = new Lang.FunctionTable();
            ClassIndex = ProtoCore.DSASM.Constants.kInvalidIndex;

            Heap = new DSASM.Heap();
            Rmem = new ProtoCore.Runtime.RuntimeMemory(Heap);

            watchClassScope = ProtoCore.DSASM.Constants.kInvalidIndex;
            watchFunctionScope = ProtoCore.DSASM.Constants.kInvalidIndex;
            watchBaseOffset = 0;
            watchStack = new List<StackValue>();
            watchSymbolList = new List<SymbolNode>();
            watchFramePointer = ProtoCore.DSASM.Constants.kInvalidIndex;

            ID = FIRST_CORE_ID;

            //recurtion
            recursivePoint = new List<FunctionCounter>();
            funcCounterTable = new List<FunctionCounter>();
            calledInFunction = false;

            GlobOffset = 0;
            GlobHeapOffset = 0;
            BaseOffset = 0;
            GraphNodeUID = 0;
            RunningBlock = 0;
            CodeBlockIndex = 0;
            RuntimeTableIndex = 0;
            CodeBlockList = new List<DSASM.CodeBlock>();
            CompleteCodeBlockList = new List<DSASM.CodeBlock>();
            DSExecutable = new ProtoCore.DSASM.Executable();

            AssocNode = null;

            // TODO Jun/Luke type system refactoring
            // Initialize the globalClass table and type system
            ClassTable = new DSASM.ClassTable();
            TypeSystem = new TypeSystem();
            TypeSystem.SetClassTable(ClassTable);
            ProcNode = null;
            ProcTable = new DSASM.ProcedureTable(ProtoCore.DSASM.Constants.kGlobalScope);

            //Initialize the function pointer table
            FunctionPointerTable = new DSASM.FunctionPointerTable();

            //Initialize the dynamic string table and dynamic function table
            DynamicVariableTable = new DSASM.DynamicVariableTable();
            DynamicFunctionTable = new DSASM.DynamicFunctionTable();
            replicationGuides = new List<List<int>>();

            ExceptionHandlingManager = new ExceptionHandlingManager();
            startPC = ProtoCore.DSASM.Constants.kInvalidIndex;

            deltaCompileStartPC = ProtoCore.DSASM.Constants.kInvalidIndex;

            RuntimeStatus = new RuntimeStatus(this);

            SSASubscript = 0;
            ExpressionUID = 0;
            ModifierBlockUID = 0;
            ModifierStateSubscript = 0;

            ExprInterpreterExe = null;
            ExecMode = ProtoCore.DSASM.InterpreterMode.kNormal;

            assocCodegen = null;
            FunctionCallDepth = 0;

            // Default execution log is Console.Out.
            this.ExecutionLog = Console.Out;
            ExecutionState = (int)ExecutionStateEventArgs.State.kInvalid; //not yet started

            DebugProps = new DebugProperties();
            //stackNodeExecutedSameTimes = new Stack<List<AssociativeGraph.GraphNode>>();
            //stackExecutingGraphNodes = new Stack<AssociativeGraph.GraphNode>();
            InterpreterProps = new Stack<InterpreterProperties>();
            stackActiveExceptionRegistration = new Stack<ExceptionRegistration>();

            ExecutiveProvider = new ExecutiveProvider();

            Configurations = new Dictionary<string, object>();

            ContinuationStruct = new Lang.ContinuationStructure();
            ParsingMode = ProtoCore.ParseMode.Normal;

            IsParsingPreloadedAssembly = false;
            IsParsingCodeBlockNode = false;
            ImportHandler = null;

            deltaCompileStartPC = 0;
            builtInsLoaded = false;
            FFIPropertyChangedMonitor = new FFIPropertyChangedMonitor(this);
        }
Ejemplo n.º 32
0
        public static void Main(string[] args)
        {
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            bool testScript = string.Equals(args[0], "test") && args.Length == 2;
            var opts = new Options();
            if (args.Length == 0 || testScript)
            {
                opts.WebRunner = false;
            }
            else
            {
                opts.WebRunner = true;
            }
            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 (!opts.WebRunner)
            {
                string fileName;
                if (testScript)
                {
                    fileName = args[1];
                }
                else
                {
                    fileName = @"..\..\..\Scripts\defectverify.ds";
                }

                ProtoScriptTestRunner runner = new ProtoScriptTestRunner();
                DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
                ExecutionMirror mirror = runner.LoadAndExecute(fileName, core);
                string str = mirror.GetCoreDump();
                //Console.WriteLine(str);
            }
            else //if (arg)
            {
                // @TODO(Gemeng): Do set "core.ExecutionLog" to some file :)

                ProtoScriptWebRunner runner = new ProtoScriptWebRunner();
                DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
                ExecutionMirror mirror = runner.LoadAndExecute(args[0], core);
                if (null != mirror)
                {
                    string str = mirror.GetCoreDump();
                    // core.coreDumpWriter.WriteLine(str);

                }

                // @TODO(Gemeng): 'coreDumpWriter' has been removed, instead of 
                // doing that we should create an output file stream here with a
                // file name, and then write the "str" content into it.
                // 
                // core.coreDumpWriter.Close();
            }


            //runner.LoadAndExecute(@"..\..\..\Scripts\array.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\arrayargs.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\class.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\class2.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\class3.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\class4.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\class5.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\class6.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\class7.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\class8.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\class9.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\class10.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\demo.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\expr.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\fusionarray.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\replication.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\simple.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\simple2.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\functionoverload.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\classfunctionoverload.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\inheritance.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\inheritance2.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\update.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\null.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\forloop.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\blockassign_imperative.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\blockassign_associative.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\test.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\importtest.ds", core);

            //ExecutionMirror mirror = null;   



            //string str = mirror.GetCoreDump();
            long ms = sw.ElapsedMilliseconds;
            sw.Stop();

            if (!opts.WebRunner)
            {
                Console.WriteLine(ms);
                Console.ReadLine();
            }
        }
Ejemplo n.º 33
0
        private void SetupCommonRunner(bool inDebugMode)
        {
            var options = new ProtoCore.Options();
            options.Verbose = GetDisplayOutput();
            options.ExecutionMode = ProtoCore.ExecutionMode.Serial;
            options.SuppressBuildOutput = false;
            options.IDEDebugMode = inDebugMode;
            AppendSearchPaths(options);

            this.core = new ProtoCore.Core(options);
            this.core.CurrentDSFileName = options.RootModulePathName;
            this.core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(this.core));
            this.core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(this.core));

            // Get configuration from host app
            var configurations  = Solution.Current.ExecutionSession.HostApplication.Configurations;
            if (configurations != null)
            {
                foreach (var item in configurations)
                {
                    this.core.Configurations[item.Key] = item.Value;
                }
            }

            IOutputStream messageList = Solution.Current.GetMessage(false);
            this.core.BuildStatus.MessageHandler = messageList;
            this.core.RuntimeStatus.MessageHandler = messageList;

            workerParams.RegularRunMirror = null;
            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
            asynchronousExecution = Solution.Current.Asynchronous;
        }
Ejemplo n.º 34
0
        private void ResetAll(Options options)
        {
            Heap = new Heap();
            //Rmem = new RuntimeMemory(Heap);
            Configurations = new Dictionary<string, object>();
            DllTypesToLoad = new List<System.Type>();

            Options = options;
            
            Compilers = new Dictionary<Language, Compiler>();
            ClassIndex = Constants.kInvalidIndex;

            FunctionTable = new FunctionTable(); 


            watchFunctionScope = Constants.kInvalidIndex;
            watchSymbolList = new List<SymbolNode>();
            watchBaseOffset = 0;


            GlobOffset = 0;
            GlobHeapOffset = 0;
            BaseOffset = 0;
            GraphNodeUID = 0;
            CodeBlockIndex = 0;
            RuntimeTableIndex = 0;
            CodeBlockList = new List<CodeBlock>();
            CompleteCodeBlockList = new List<CodeBlock>();
            CallsiteGuidMap = new Dictionary<Guid, int>();

            AssocNode = null;

            // TODO Jun/Luke type system refactoring
            // Initialize the globalClass table and type system
            ClassTable = new ClassTable();
            TypeSystem = new TypeSystem();
            TypeSystem.SetClassTable(ClassTable);
            ProcNode = null;
            ProcTable = new ProcedureTable(Constants.kGlobalScope);

            // Initialize internal attributes
            internalAttributes = new InternalAttributes(ClassTable);

            //Initialize the function pointer table
            FunctionPointerTable = new FunctionPointerTable();

            //Initialize the dynamic string table and dynamic function table
            DynamicVariableTable = new DynamicVariableTable();
            DynamicFunctionTable = new DynamicFunctionTable();

            watchStartPC = Constants.kInvalidIndex;

            deltaCompileStartPC = Constants.kInvalidIndex;

            BuildStatus = new BuildStatus(this, Options.BuildOptWarningAsError, null, Options.BuildOptErrorAsWarning);

            SSAExpressionUID = 0;
            SSASubscript = 0;
            SSASubscript_GUID = Guid.NewGuid();
            SSAExprUID = 0;
            ExpressionUID = 0;
            ModifierBlockUID = 0;
            ModifierStateSubscript = 0;

            ExprInterpreterExe = null;
            Options.RunMode = InterpreterMode.Normal;

            assocCodegen = null;

            // Default execution log is Console.Out.
            ExecutionLog = Console.Out;

            DebuggerProperties = new DebugProperties();


            ParsingMode = ParseMode.Normal;
            
            IsParsingPreloadedAssembly = false;
            IsParsingCodeBlockNode = false;
            ImportHandler = null;

            deltaCompileStartPC = 0;
            builtInsLoaded = false;


            ForLoopBlockIndex = Constants.kInvalidIndex;

            GraphNodeCallList = new List<GraphNode>();
            InlineConditionalBodyGraphNodes = new Stack<List<GraphNode>>();

            newEntryPoint = Constants.kInvalidIndex;
        }
Ejemplo n.º 35
0
 public Core(Options options)
 {
     ResetAll(options);
 }
Ejemplo n.º 36
0
 public void Setup()
 {
     var opts = new Options();
     opts.ExecutionMode = ExecutionMode.Serial;
     ProtoCore.Core core = thisTest.SetupTestCore();
 }
Ejemplo n.º 37
0
        public WatchTestFx()
        {
            var options = new ProtoCore.Options();

            core = new ProtoCore.Core(options);
        }
Ejemplo n.º 38
0
 public void SetProperties(Options runtimeOptions, Executable executable, DebugProperties debugProps = null, ProtoCore.Runtime.Context context = null, Executable exprInterpreterExe = null)
 {
     this.Context = context;
     this.DSExecutable = executable;
     this.Options = runtimeOptions;
     this.DebugProps = debugProps;
     this.ExprInterpreterExe = exprInterpreterExe;
 }
Ejemplo n.º 39
0
 public void Setup()
 {
     var opts = new Options();
     opts.ExecutionMode = ExecutionMode.Serial;
     core = thisTest.SetupEmptyTestCore();
 }
Ejemplo n.º 40
0
        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
            
#if __RUN_TEST_FILE
            
            ProtoFFI.DLLFFIHandler.Register(ProtoFFI.FFILanguage.CSharp, new ProtoFFI.CSModuleHelper());

            ProtoScriptTestRunner runner = new ProtoScriptTestRunner();
            ExecutionMirror mirror = runner.LoadAndExecute(@"c:\jun\AutodeskResearch\git\designscript\Scripts\jun.ds", core);
          
#else
            /*
            var runnerConfig = new ProtoScript.Config.RunConfiguration();
            runnerConfig.IsParrallel = false;
            var fsr = new ProtoScript.Runners.DebugRunner(core);
            fsr.LoadAndPreStart(@"c:\project\designscript\test.ds", runnerConfig);
            fsr.Run();
            */


            
            //ProtoTest.TD.OtherMiscTests.MiscTest test = new ProtoTest.TD.OtherMiscTests.MiscTest();
            //test.TestDynamicSetValueAfterExecution();
            


            //ProtoTest.DebugTests.RunEqualityTests test = new ProtoTest.DebugTests.RunEqualityTests();
            //test.DebugTest_Jun_ReplicationGuide();

            //ProtoTest.Associative.MicroFeatureTests test = new ProtoTest.Associative.MicroFeatureTests();
            //test.Setup();
            //test.TestContextInject01();


            ProtoFFITests.ContextInjectionTests test = new ProtoFFITests.ContextInjectionTests();
            test.Setup();
            test.TestContextInjectDummy();



            //ProtoTest.Associative.MethodsFocusTeam test = new ProtoTest.Associative.MethodsFocusTeam();
            //test.Setup();
            //test.T014_DotOp_UserDefinedClass_03();
            
#endif

            long ms = sw.ElapsedMilliseconds;
            sw.Stop();
            Console.WriteLine(ms);
            Console.ReadLine();
        }