Beispiel #1
0
        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;
        }
Beispiel #2
0
        // 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>();
        }
Beispiel #3
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);
        }
        public void SetUp()
        {
            testCore = thisTest.SetupTestCore();

            testRuntimeCore = new RuntimeCore(testCore.Heap, testCore.Options);
            testExecutive = new TestExecutive(testRuntimeCore);
        }
Beispiel #5
0
        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;
        }
Beispiel #6
0
        public override void Setup()
        {
            base.Setup();

            libraryCore = new ProtoCore.Core(new Options());
            libraryCore.Compilers.Add(Language.Associative, new ProtoAssociative.Compiler(libraryCore));
            libraryCore.Compilers.Add(Language.Imperative, new ProtoImperative.Compiler(libraryCore));
            libraryCore.ParsingMode = ParseMode.AllowNonAssignment;

            var pathResolver = new TestPathResolver();

            pathResolver.AddPreloadLibraryPath("Builtin.dll");
            pathResolver.AddPreloadLibraryPath("DSCoreNodes.dll");

            var pathManager = new PathManager(new PathManagerParams
            {
                PathResolver = pathResolver
            });

            var settings = new PreferenceSettings();

            libraryServices = new LibraryServices(libraryCore, pathManager, settings);

            RegisterEvents();
        }
        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;
        }
Beispiel #8
0
        /// <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;
        }
Beispiel #9
0
        public void Setup()
        {
            var opts = new Options();

            opts.ExecutionMode = ExecutionMode.Serial;
            core = thisTest.CreateTestCore();
        }
Beispiel #10
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();
        }
Beispiel #11
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");
        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;
        }
Beispiel #13
0
        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;
        }
Beispiel #14
0
 public CodeBlockNode GenerateAST(string pathFilename, ProtoCore.Core core)
 {
     Imperative.Scanner s = new Imperative.Scanner(pathFilename);
     Imperative.Parser  p = new Imperative.Parser(s, core);
     p.Parse();
     return(p.codeblock as CodeBlockNode);
 }
        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);
        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);
        }
Beispiel #17
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);
        }
Beispiel #18
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);
        }
Beispiel #19
0
        //  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);
            }
        }
Beispiel #20
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();
        }
Beispiel #21
0
        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);
        }
Beispiel #22
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);
        }
Beispiel #23
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);
        }
Beispiel #24
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;
        }
Beispiel #25
0
        internal static void CompareCores(Core c1, Core c2)
        {
            Assert.AreEqual(c1.DSExecutable.runtimeSymbols.Length, c2.DSExecutable.runtimeSymbols.Length);

            for (int symTableIndex = 0; symTableIndex < c1.DSExecutable.runtimeSymbols.Length; symTableIndex++)
            {
                foreach (SymbolNode symNode in c1.DSExecutable.runtimeSymbols[symTableIndex].symbolList.Values)
                {

                    ExecutionMirror runExecMirror = new ExecutionMirror(c1.CurrentExecutive.CurrentDSASMExec,
                                                                        c1);
                    ExecutionMirror debugExecMirror =
                        new ExecutionMirror(c2.CurrentExecutive.CurrentDSASMExec, c2);

                    bool lookupOk = false;
                    StackValue runValue = new StackValue();

                    if (symNode.name.StartsWith("%") || symNode.functionIndex != Constants.kInvalidIndex)
                        continue; //Don't care about internal variables

                    try
                    {
                        runValue = runExecMirror.GetGlobalValue(symNode.name);
                        Console.WriteLine(symNode.name + ": " + runValue);
                        lookupOk = true;

                    }
                    catch (NotImplementedException)
                    {

                    }
                    catch (Exception ex)
                    {
                        if ((ex is ArgumentOutOfRangeException || ex is IndexOutOfRangeException) &&
                            (c1.RunningBlock != symNode.runtimeTableIndex))
                        {
                            // Quite possible that variables defined in the inner
                            // language block have been garbage collected and
                            // stack frame pointer has been adjusted when return
                            // to the outer block.
                        }
                        else
                        {
                            throw ex;
                        }
                    }

                    if (lookupOk)
                    {
                        StackValue debugValue = debugExecMirror.GetGlobalValue(symNode.name);
                        if (!StackUtils.CompareStackValues(debugValue, runValue, c2, c1))
                        {
                            Assert.Fail(string.Format("\tThe value of variable \"{0}\" doesn't match in run mode and in debug mode.\n", symNode.name));
                        }
                    }
                }
            }
        }
Beispiel #26
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);
        }
Beispiel #27
0
        public LibraryServices(ProtoCore.Core libraryManagementCore)
        {
            LibraryManagementCore = libraryManagementCore;

            PreloadLibraries();
            PopulateBuiltIns();
            PopulateOperators();
            PopulatePreloadLibraries();
        }
Beispiel #28
0
        public void SetUp()
        {
            testCore = thisTest.SetupTestCore();

            testRuntimeCore = new RuntimeCore(testCore.Heap);
            testRuntimeCore.SetProperties(testCore.Options, null);

            testExecutive = new TestExecutive(testRuntimeCore);
        }
Beispiel #29
0
        public bool RegisterExtensionApplicationType(Core core, SysType type)
        {
            if (!typeof(IExtensionApplication).IsAssignableFrom(type))
                return false;

            FFIExecutionSession session = GetSession(core, true);
            session.AddExtensionAppType(type);
            return true;
        }
Beispiel #30
0
        public CodeGen(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

            // Comment Jun: Get the codeblock to use for this codegenerator
            if (core.Options.IsDeltaExecution)
            {
                codeBlock = GetDeltaCompileCodeBlock();
                //if (core.Options.IsDeltaCompile)
                //{
                //    pc = codeBlock.instrStream.instrList.Count;
                //}
                //else
                //{
                //    pc = core.deltaCompileStartPC;
                //}
            }
            else
            {
                codeBlock = BuildNewCodeBlock();
            }
            //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;
            }
            core.CompleteCodeBlockList.Add(codeBlock);
            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);
        }
Beispiel #31
0
 static void Main()
 {
     ProtoCore.Core core = new ProtoCore.Core(new ProtoCore.Options());
     string filePath = @"C:\DSCode\autodeskresearch\branches\UIResearch\DesignScriptParser\DSParser\DSParser\scripts\test1.ds";
     DesignScript.Parser.Scanner s = new DesignScript.Parser.Scanner(filePath);
     DesignScript.Parser.Parser p = new DesignScript.Parser.Parser(s, core);
     p.Parse();
     DesignScript.Parser.Node c = p.root;
 }
Beispiel #32
0
        private static FunctionDotCallNode CreateFunctionCallNode(string className, string methodName, List<AssociativeNode> args, Core core)
        {
            FunctionCallNode fNode = new FunctionCallNode();
            fNode.Function = new IdentifierNode(methodName);
            fNode.FormalArguments = args;

            IdentifierNode inode = new IdentifierNode(className);
            return CoreUtils.GenerateCallDotNode(inode, fNode, core);
        }
Beispiel #33
0
        static void Main()
        {
            ProtoCore.Core core     = new ProtoCore.Core(new ProtoCore.Options());
            string         filePath = @"C:\DSCode\autodeskresearch\branches\UIResearch\DesignScriptParser\DSParser\DSParser\scripts\test1.ds";

            DesignScript.Parser.Scanner s = new DesignScript.Parser.Scanner(filePath);
            DesignScript.Parser.Parser  p = new DesignScript.Parser.Parser(s, core);
            p.Parse();
            DesignScript.Parser.Node c = p.root;
        }
Beispiel #34
0
        public LibraryServices(ProtoCore.Core libraryManagementCore, IPathManager pathManager)
        {
            LibraryManagementCore = libraryManagementCore;
            this.pathManager      = pathManager;

            PreloadLibraries(pathManager.PreloadedLibraries);
            PopulateBuiltIns();
            PopulateOperators();
            PopulatePreloadLibraries();
        }
Beispiel #35
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();
        }
Beispiel #36
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LibraryServices"/> class.
        /// </summary>
        /// <param name="libraryManagementCore">Core which is used for parsing code and loading libraries</param>
        /// <param name="pathManager">Instance of IPathManager containing neccessary Dynamo paths</param>
        public LibraryServices(ProtoCore.Core libraryManagementCore, IPathManager pathManager)
        {
            LibraryManagementCore = libraryManagementCore;
            this.pathManager      = pathManager;

            PreloadLibraries(pathManager.PreloadedLibraries);
            PopulateBuiltIns();
            PopulateOperators();
            PopulatePreloadLibraries();
            LibraryLoadFailed += new EventHandler <LibraryLoadFailedEventArgs>(LibraryLoadFailureHandler);
        }
Beispiel #37
0
        private static FunctionDotCallNode CreateEntityNode(long hostInstancePtr, Core core)
        {
            FunctionCallNode fNode = new FunctionCallNode();
            fNode.Function = new IdentifierNode("FromObject");
            List<ProtoCore.AST.AssociativeAST.AssociativeNode> listArgs = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
            listArgs.Add(new ProtoCore.AST.AssociativeAST.IntNode(hostInstancePtr));
            fNode.FormalArguments = listArgs;

            string className = "Geometry";
            IdentifierNode inode = new ProtoCore.AST.AssociativeAST.IdentifierNode(className);
            return ProtoCore.Utils.CoreUtils.GenerateCallDotNode(inode, fNode, core);            
        }
Beispiel #38
0
        public void Setup()
        {
            libraryCore = new ProtoCore.Core(new Options {
                RootCustomPropertyFilterPathName = string.Empty
            });
            libraryCore.Compilers.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Compiler(libraryCore));
            libraryCore.Compilers.Add(ProtoCore.Language.kImperative, new ProtoImperative.Compiler(libraryCore));
            libraryCore.ParsingMode = ParseMode.AllowNonAssignment;
            libraryServices         = new LibraryServices(libraryCore, pathManager);

            RegisterEvents();
        }
Beispiel #39
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LibraryServices"/> class.
        /// </summary>
        /// <param name="libraryManagementCore">Core which is used for parsing code and loading libraries</param>
        /// <param name="pathManager">Instance of IPathManager containing neccessary Dynamo paths</param>
        /// <param name="preferences">The preference settings of the Dynamo instance</param>
        public LibraryServices(ProtoCore.Core libraryManagementCore, IPathManager pathManager, IPreferences preferences)
        {
            LibraryManagementCore = libraryManagementCore;
            this.pathManager      = pathManager;
            preferenceSettings    = preferences;

            PreloadLibraries(pathManager.PreloadedLibraries);
            PopulateBuiltIns();
            PopulateOperators();
            PopulatePreloadLibraries();
            LibraryLoadFailed += new EventHandler <LibraryLoadFailedEventArgs>(LibraryLoadFailureHandler);

            AppDomain.CurrentDomain.AssemblyResolve += ResolveAssembly;
        }
Beispiel #40
0
        public DependencyPass.DependencyTracker GetDemoTracker2(ProtoCore.Core core)
        {
            Associative.Scanner s = new Associative.Scanner(@"..\..\Scripts\expr.ds");
            Associative.Parser  p = new Associative.Parser(s, core);
            p.Parse();

            CodeBlockNode code = p.codeblock as CodeBlockNode;

            DependencyTracker tempTracker           = new DependencyTracker();
            Dictionary <string, List <Node> > names = new Dictionary <string, List <Node> >();

            code.ConsolidateNames(ref (names));
            tempTracker.GenerateDependencyGraph(code.Body);
            return(tempTracker);
        }
        /// <summary>
        /// Convert the parameters passed to the types specified in this fep
        /// </summary>
        /// <param name="formalParameters"></param>
        /// <returns></returns>
        public List<StackValue> CoerceParameters(List<StackValue> formalParameters, Core core)
        {
            List<StackValue> fixedUpVersions = new List<StackValue>();
            for (int i = 0; i < formalParameters.Count; i++)
            {
                StackValue formalParam = formalParameters[i];
                Type targetType = FormalParams[i];

                StackValue coercedParam = TypeSystem.Coerce(formalParam, targetType, core);
                GCUtils.GCRetain(coercedParam, core);
                fixedUpVersions.Add(coercedParam);
            }

            return fixedUpVersions;
        }
Beispiel #42
0
        public CodeGen(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), false, coreObj);

            ++core.CodeBlockIndex;
            ++core.RuntimeTableIndex;

            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;
            }
            core.CompleteCodeBlockList.Add(codeBlock);
            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);
        }
Beispiel #43
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);
        }
Beispiel #44
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);
        }
Beispiel #45
0
        public override void Setup()
        {
            base.Setup();

            libraryCore = new ProtoCore.Core(new Options { RootCustomPropertyFilterPathName = string.Empty });
            libraryCore.Compilers.Add(Language.kAssociative, new ProtoAssociative.Compiler(libraryCore));
            libraryCore.Compilers.Add(Language.kImperative, new ProtoImperative.Compiler(libraryCore));
            libraryCore.ParsingMode = ParseMode.AllowNonAssignment;

            var pathResolver = new TestPathResolver();
            pathResolver.AddPreloadLibraryPath("DSCoreNodes.dll");

            var pathManager = new PathManager(new PathManagerParams
            {
                PathResolver = pathResolver
            });

            libraryServices = new LibraryServices(libraryCore, pathManager);

            RegisterEvents();
        }
Beispiel #46
0
        public void TestCBNEngineTests()
        {
            String code =
                @"
	        
               [Associative]
                {
	                foo=5;
                }

            
            ";

            ExecutionMirror mirror = thisTest.RunScriptSource(code);

            ProtoCore.Core core = thisTest.GetTestCore();
            Guid           guid = RunDSScriptInCBN(code);

            ProtoCore.Core dynamoCore = ViewModel.Model.EngineController.LiveRunnerCore;
            CompareCores(core, dynamoCore, guid);
        }
Beispiel #47
0
        internal void CompareCores(ProtoCore.Core c1, ProtoCore.Core c2, Guid guid)
        {
            for (int symTableIndex = 0; symTableIndex < c1.DSExecutable.runtimeSymbols.Length; symTableIndex++)
            {
                foreach (SymbolNode symNode in c1.DSExecutable.runtimeSymbols[symTableIndex].symbolList.Values)
                {
                    ProtoCore.Mirror.RuntimeMirror langMirror = null;


                    ProtoCore.Mirror.RuntimeMirror dynamoMirror = null;
                    bool lookupOk = false;


                    if (CoreUtils.IsCompilerGenerated(symNode.name) || symNode.functionIndex != Constants.kInvalidIndex)
                    {
                        continue; //Don't care about internal variables
                    }

                    if (symNode.functionIndex == Constants.kGlobalScope && symNode.classScope == Constants.kInvalidIndex)
                    {
                        langMirror = new ProtoCore.Mirror.RuntimeMirror(symNode.name, 0, c1);
                        string name = symNode.name + "_" + guid.ToString();
                        name         = name.Replace("-", string.Empty);
                        dynamoMirror = ViewModel.Model.EngineController.GetMirror(name);
                        if (langMirror != null || dynamoMirror != null)
                        {
                            lookupOk = true;
                        }

                        if (lookupOk)
                        {
                            if (!langMirror.GetData().Equals(dynamoMirror.GetData()))
                            {
                                Assert.Fail(string.Format("\tThe value of variable \"{0}\" doesn't match in language mode and in Dynamo CBN mode.\n", symNode.name));
                            }
                        }
                    }
                }
            }
        }
        private void CleanUpRunners()
        {
            Logger.LogInfo("DetachFromDebugger", "Detach");

            // Clear up all watch related data members.
            this.workerParams.CurrentVmState = null;
            this.currentWatchedMirror        = null;
            this.currentWatchedStackValue    = null;

            if (null != scriptRunner)
            {
                scriptRunner = null;
            }

            if (null != debugRunner)
            {
                debugRunner.Shutdown();
                debugRunner = null;
            }

            if (null != internalWorker)
            {
                // @TODO(Ben): Perhaps cancellation is needed?
                internalWorker = null;
            }

            //Fix DG-1464973 Sprint25: rev 3444 : Multiple import issue - dispose core after execution
            //Core Cleanup should happen only after execution has finished,
            //DebugRunner is ShutDown.
            if (null != this.core)
            {
                this.core.Cleanup();
                this.core = null;
            }

            workerParams.ResetStates();
            SetExecutionState(ExecutionStateChangedEventArgs.States.None);
        }
Beispiel #49
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();
        }
        public AssociativeCodeGen(Core coreObj, ProtoCore.DSASM.CodeBlock parentBlock = null)
            : base(coreObj, parentBlock)
        {
            classOffset = 0;

            //  either of these should set the console to flood
            //
            ignoreRankCheck = false;

            astNodes = new List<AssociativeNode>();
            setConstructorStartPC = false;

            // 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.kAssociative,
                core.CodeBlockIndex,
                new ProtoCore.DSASM.SymbolTable("associative lang block", core.RuntimeTableIndex),
                new ProtoCore.DSASM.ProcedureTable(core.RuntimeTableIndex),
                false,
                core);

            ++core.CodeBlockIndex;
            ++core.RuntimeTableIndex;

            core.CodeBlockList.Add(codeBlock);
            if (null != parentBlock)
            {
                // This is a nested block
                parentBlock.children.Add(codeBlock);
                codeBlock.parent = parentBlock;
            }

            compilePass = ProtoCore.DSASM.AssociativeCompilePass.kClassName;
        }
        public override void Setup()
        {
            base.Setup();

            libraryCore = new ProtoCore.Core(new Options());
            libraryCore.Compilers.Add(Language.Associative, new ProtoAssociative.Compiler(libraryCore));
            libraryCore.Compilers.Add(Language.Imperative, new ProtoImperative.Compiler(libraryCore));
            libraryCore.ParsingMode = ParseMode.AllowNonAssignment;

            var pathResolver = new TestPathResolver();
            pathResolver.AddPreloadLibraryPath("DSCoreNodes.dll");

            var pathManager = new PathManager(new PathManagerParams
            {
                PathResolver = pathResolver
            });

            var settings = new PreferenceSettings();

            libraryServices = new LibraryServices(libraryCore, pathManager, settings);

            RegisterEvents();
        }
Beispiel #52
0
        public override void Setup()
        {
            base.Setup();

            libraryCore = new ProtoCore.Core(new Options {
                RootCustomPropertyFilterPathName = string.Empty
            });
            libraryCore.Compilers.Add(Language.kAssociative, new ProtoAssociative.Compiler(libraryCore));
            libraryCore.Compilers.Add(Language.kImperative, new ProtoImperative.Compiler(libraryCore));
            libraryCore.ParsingMode = ParseMode.AllowNonAssignment;

            var pathResolver = new TestPathResolver();

            pathResolver.AddPreloadLibraryPath("DSCoreNodes.dll");

            var pathManager = new PathManager(new PathManagerParams
            {
                PathResolver = pathResolver
            });

            libraryServices = new LibraryServices(libraryCore, pathManager);

            RegisterEvents();
        }
Beispiel #53
0
        private void RevitServicesUpdater_ElementsDeleted(Document document, IEnumerable <ElementId> deleted)
        {
            if (!deleted.Any())
            {
                return;
            }

            var workspace = this.CurrentWorkspace;

            ProtoCore.Core core   = null;
            var            engine = this.EngineController;

            if (engine != null && (engine.LiveRunnerCore != null))
            {
                core = engine.LiveRunnerCore;
            }

            if (core == null) // No execution yet as of this point.
            {
                return;
            }

            // Selecting all nodes that are either a DSFunction,
            // a DSVarArgFunction or a CodeBlockNodeModel into a list.
            var nodeGuids = workspace.Nodes.Where((n) =>
            {
                return(n is DSFunction ||
                       (n is DSVarArgFunction) ||
                       (n is CodeBlockNodeModel));
            }).Select((n) => n.GUID);

            var nodeTraceDataList = core.GetCallsitesForNodes(nodeGuids);// core.GetTraceDataForNodes(nodeGuids);

            foreach (Guid guid in nodeTraceDataList.Keys)
            {
                foreach (CallSite cs in nodeTraceDataList[guid])
                {
                    foreach (CallSite.SingleRunTraceData srtd in cs.TraceData)
                    {
                        List <ISerializable> traceData = srtd.RecursiveGetNestedData();

                        foreach (ISerializable thingy in traceData)
                        {
                            SerializableId sid = thingy as SerializableId;

                            foreach (ElementId eid in deleted)
                            {
                                if (sid != null)
                                {
                                    if (sid.IntID == eid.IntegerValue)
                                    {
                                        NodeModel inm =
                                            workspace.Nodes.Where((n) => n.GUID == guid).FirstOrDefault();

                                        Validity.Assert(inm != null, "The bound node has disappeared");

                                        inm.RequiresRecalc       = true;
                                        inm.ForceReExecuteOfNode = true;

                                        //FOUND IT!
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #54
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();
        }
Beispiel #55
0
        public WatchTestFx()
        {
            var options = new ProtoCore.Options();

            core = new ProtoCore.Core(options);
        }
Beispiel #56
0
 public Executive(ProtoCore.Core core)
     : base(core)
 {
 }
Beispiel #57
0
 public void SetLiveCore(ProtoCore.Core core)
 {
     liveRunnerCore = core;
 }
Beispiel #58
0
        public DependencyPass.DependencyTracker GetDemoTracker3(out ProtoCore.DSASM.SymbolTable symbols, string pathFilename, ProtoCore.Core core)
        {
            Associative.Scanner s = new Associative.Scanner(pathFilename);
            Associative.Parser  p = new Associative.Parser(s, core);
            p.Parse();
            CodeBlockNode code = p.codeblock as CodeBlockNode;

            symbols = code.symbols;

            DependencyTracker tempTracker = new DependencyTracker();

#if TEST_DIRECT
            foreach (Node node in code.Body)
            {
                tempTracker.AllNodes.Add(node);
            }
#else
            Dictionary <string, List <Node> > names = new Dictionary <string, List <Node> >();
            code.ConsolidateNames(ref (names));
            tempTracker.GenerateDependencyGraph(code.Body);
#endif
            return(tempTracker);
        }
Beispiel #59
0
 internal void SetLiveCore(ProtoCore.Core core)
 {
     liveRunnerCore = core;
 }
Beispiel #60
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LibraryServices"/> class.
 /// </summary>
 /// <param name="libraryManagementCore">Core which is used for parsing code and loading libraries</param>
 /// <param name="pathManager">Instance of IPathManager containing neccessary Dynamo paths</param>
 public LibraryServices(ProtoCore.Core libraryManagementCore, IPathManager pathManager)
     : this(libraryManagementCore, pathManager, null)
 {
 }