コード例 #1
0
            public ProtoCore.Mirror.RuntimeMirror LookupName(string name, int blockID)
            {
                // TODO Jun: The expression interpreter must be integrated into the mirror
                core.Rmem.PushConstructBlockId(blockID);
                core.DebugProps.CurrentBlockId = blockID;
                ProtoScript.Runners.ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core);

                List <ProtoCore.Core.CodeBlockCompilationSnapshot> snapShots = null;

                if (core.Options.IsDeltaExecution)
                {
                    snapShots = ProtoCore.Core.CodeBlockCompilationSnapshot.CaptureCoreCompileState(core);
                }
                ProtoCore.DSASM.Mirror.ExecutionMirror mirror = watchRunner.Execute(name);
                if (core.Options.IsDeltaExecution && snapShots != null)
                {
                    core.ResetDeltaCompileFromSnapshot(snapShots);
                }
                ProtoCore.Lang.Obj objExecVal = mirror.GetWatchValue();

                ProtoCore.Mirror.RuntimeMirror runtimeMirror = new ProtoCore.Mirror.RuntimeMirror(new ProtoCore.Mirror.MirrorData(core, objExecVal.DsasmValue), core, core);
                Validity.Assert(runtimeMirror != null);

                return(runtimeMirror);
            }
コード例 #2
0
 public NodeValueReadyEventArgs(ProtoCore.Mirror.RuntimeMirror mirror, uint nodeId, EventStatus resultStatus, String errorString)
 {
     this.RuntimeMirror = mirror;
     this.NodeId        = nodeId;
     ResultStatus       = resultStatus;
     ErrorString        = errorString;
 }
コード例 #3
0
ファイル: CompareMirrors.cs プロジェクト: RobertiF/Dynamo
        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));
                                }

                            }
                           
                    }
                }
            }

        }
コード例 #4
0
        public void TestInstructionStreamMemory_FunctionRedefinition01()
        {
            List <string> codes = new List <string>()
            {
                "def f() {return = 1;}",
                "a = f();",
                "def f() {return = 2;}"
            };

            Guid guid1 = System.Guid.NewGuid();
            Guid guid2 = System.Guid.NewGuid();

            // First run
            List <Subtree> added = new List <Subtree>();
            Subtree        st    = ProtoTestFx.TD.TestFrameWork.CreateSubTreeFromCode(guid1, codes[0]);

            added.Add(st);

            st = ProtoTestFx.TD.TestFrameWork.CreateSubTreeFromCode(guid2, codes[1]);
            added.Add(st);

            var syncData = new GraphSyncData(null, added, null);

            liverunner.UpdateGraph(syncData);

            ProtoCore.Mirror.RuntimeMirror mirror = liverunner.InspectNodeValue("a");
            Assert.IsTrue((Int64)mirror.GetData().Data == 1);

            // Modify function
            List <Subtree> modified = new List <Subtree>();

            st = ProtoTestFx.TD.TestFrameWork.CreateSubTreeFromCode(guid1, codes[2]);
            modified.Add(st);
            syncData = new GraphSyncData(null, null, modified);
            liverunner.UpdateGraph(syncData);

            mirror = liverunner.InspectNodeValue("a");
            Assert.IsTrue((Int64)mirror.GetData().Data == 2);

            Assert.AreEqual(instrStreamStart, instrStreamEnd);
        }
コード例 #5
0
ファイル: CompareMirrors.cs プロジェクト: zjloscar/Dynamo
        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));
                            }
                        }
                    }
                }
            }
        }
コード例 #6
0
        public void TestPeriodicUpdate01()
        {
            int    rhs  = 0;
            string code = String.Format("a = {0};", rhs.ToString());

            Guid guid = System.Guid.NewGuid();

            // First run
            // a = 1
            List <Subtree> added = new List <Subtree>();
            Subtree        st    = ProtoTestFx.TD.TestFrameWork.CreateSubTreeFromCode(guid, code);

            added.Add(st);
            var syncData = new GraphSyncData(null, added, null);

            liverunner.UpdateGraph(syncData);

            ProtoCore.Mirror.RuntimeMirror mirror = liverunner.InspectNodeValue("a");
            Assert.IsTrue((Int64)mirror.GetData().Data == 0);

            List <Subtree> modified = null;

            const int maxUpdate = 100;

            for (int n = 1; n <= maxUpdate; ++n)
            {
                // Modify a
                code     = String.Format("a = {0};", n.ToString());
                modified = new List <Subtree>();
                st       = ProtoTestFx.TD.TestFrameWork.CreateSubTreeFromCode(guid, code);
                modified.Add(st);
                syncData = new GraphSyncData(null, null, modified);
                liverunner.UpdateGraph(syncData);
            }

            mirror = liverunner.InspectNodeValue("a");
            Assert.IsTrue((Int64)mirror.GetData().Data == 100);

            // instruction stream not increaed.
        }
コード例 #7
0
            public override void Execute()
            {
                lock (runner.operationsMutex)
                {
                    if (runner.NodeValueReady != null) // If an event handler is registered.
                    {
                        NodeValueReadyEventArgs retArgs = null;

                        try
                        {
                            // Now that background worker is free, get the value...
                            ProtoCore.Mirror.RuntimeMirror mirror = runner.InternalGetNodeValue(nodeId);
                            if (null != mirror)
                            {
                                retArgs = new NodeValueReadyEventArgs(mirror, nodeId);

                                System.Diagnostics.Debug.WriteLine("Node {0} => {1}",
                                                                   nodeId.ToString("x8"), mirror.GetData().GetStackValue());
                            }
                            else
                            {
                                retArgs = new NodeValueNotAvailableEventArgs(nodeId);
                            }
                        }
                        catch (Exception e)
                        {
                            retArgs = new NodeValueReadyEventArgs(null, nodeId, EventStatus.Error, e.ToString());
                        }

                        if (null != retArgs)
                        {
                            runner.NodeValueReady(this, retArgs); // Notify all listeners (e.g. UI).
                        }
                    }
                }
            }
コード例 #8
0
ファイル: ProtoRunner.cs プロジェクト: RobertiF/Dynamo
            public ProtoCore.Mirror.RuntimeMirror LookupName(string name, int blockID)
            {
                // TODO Jun: The expression interpreter must be integrated into the mirror
                core.Rmem.PushConstructBlockId(blockID);
                core.DebugProps.CurrentBlockId = blockID;
                ProtoScript.Runners.ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core);

                List<ProtoCore.Core.CodeBlockCompilationSnapshot> snapShots = null;
                if (core.Options.IsDeltaExecution)
                {
                    snapShots = ProtoCore.Core.CodeBlockCompilationSnapshot.CaptureCoreCompileState(core);
                }
                ProtoCore.DSASM.Mirror.ExecutionMirror mirror = watchRunner.Execute(name);
                if (core.Options.IsDeltaExecution && snapShots != null)
                {
                    core.ResetDeltaCompileFromSnapshot(snapShots);
                }
                ProtoCore.Lang.Obj objExecVal = mirror.GetWatchValue();

                ProtoCore.Core staticCore = GraphToDSCompiler.GraphUtilities.GetCore();
                ProtoCore.Mirror.RuntimeMirror runtimeMirror = new ProtoCore.Mirror.RuntimeMirror(new ProtoCore.Mirror.MirrorData(core, objExecVal.DsasmValue), core, staticCore);
                Validity.Assert(runtimeMirror != null);

                return runtimeMirror;
            }
コード例 #9
0
        public void TestBuildAST_01()
        {
            //==============================================
            //
            // import("ProtoGeometry.dll");
            // p = Point.Bycoordinates(0.0, 2.0, 1.0);
            // xval = p.X;
            //
            //==============================================


            //==============================================
            // Build the import Nodes
            //==============================================
            ProtoScript.Runners.ILiveRunner liveRunner = new ProtoScript.Runners.LiveRunner();

            List <string> libs = new List <string>();

            libs.Add("ProtoGeometry.dll");
            liveRunner.ResetVMAndImportLibrary(libs);

            string        type            = "Point";
            long          hostInstancePtr = 0;
            string        functionName    = "ByCoordinates";
            List <IntPtr> userDefinedArgs = null;
            List <string> primitiveArgs   = new List <string>();

            primitiveArgs.Add("0");
            primitiveArgs.Add("2");
            primitiveArgs.Add("1");
            string formatString = "ddd";
            string symbolName   = "";
            string code         = "";

            AssociativeNode assign1 = ASTCompilerUtils.BuildAST(type, hostInstancePtr, functionName, userDefinedArgs, primitiveArgs, formatString, liveRunner.Core,
                                                                ref symbolName, ref code);

            liveRunner.UpdateGraph(assign1);

            primitiveArgs.Clear();
            primitiveArgs.Add("10");
            primitiveArgs.Add("0");
            primitiveArgs.Add("0");

            functionName = "Translate";
            AssociativeNode assign2 = ASTCompilerUtils.BuildAST(symbolName, hostInstancePtr, functionName, userDefinedArgs, primitiveArgs, formatString, liveRunner.Core,
                                                                ref symbolName, ref code);

            liveRunner.UpdateGraph(assign2);

            //==============================================
            // Build a binary expression to retirieve the x property
            // xval = p.X;
            //==============================================
            List <ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List <ProtoCore.AST.AssociativeAST.AssociativeNode>();

            ProtoCore.AST.AssociativeAST.IdentifierListNode identListNode = new ProtoCore.AST.AssociativeAST.IdentifierListNode();
            identListNode.LeftNode  = new ProtoCore.AST.AssociativeAST.IdentifierNode(symbolName);
            identListNode.Optr      = ProtoCore.DSASM.Operator.dot;
            identListNode.RightNode = new ProtoCore.AST.AssociativeAST.IdentifierNode("X");
            ProtoCore.AST.AssociativeAST.BinaryExpressionNode stmt2 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
                new ProtoCore.AST.AssociativeAST.IdentifierNode("xval"),
                identListNode,
                ProtoCore.DSASM.Operator.assign);
            astList.Add(stmt2);
            //==============================================
            //
            // import("ProtoGeometry.dll");
            // p = Point.Bycoordinates(0.0, 20.0, 1.0);
            // q = p.Translate(10.0, 0.0, 0.0);
            // xval = p.X;
            //
            //==============================================

            // update graph
            CodeBlockNode cNode = new CodeBlockNode();

            cNode.Body = astList;
            liveRunner.UpdateGraph(cNode);

            ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("xval");
            Assert.IsTrue((double)mirror.GetData().Data == 10.0);
        }
コード例 #10
0
 public NodeValueReadyEventArgs(ProtoCore.Mirror.RuntimeMirror mirror, uint nodeId)
     : this(mirror, nodeId, EventStatus.OK, null)
 {
 }