当前位置: 首页>>代码示例>>C#>>正文


C# AssociativeAST.IdentifierListNode类代码示例

本文整理汇总了C#中ProtoCore.AST.AssociativeAST.IdentifierListNode的典型用法代码示例。如果您正苦于以下问题:C# IdentifierListNode类的具体用法?C# IdentifierListNode怎么用?C# IdentifierListNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IdentifierListNode类属于ProtoCore.AST.AssociativeAST命名空间,在下文中一共展示了IdentifierListNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildSSAIdentListAssignmentNode

        private BinaryExpressionNode BuildSSAIdentListAssignmentNode(IdentifierListNode identList)
        {
            // Build the final binary expression 
            BinaryExpressionNode bnode = new BinaryExpressionNode();
            bnode.Optr = ProtoCore.DSASM.Operator.assign;

            // Left node
            var identNode = AstFactory.BuildIdentifier(CoreUtils.BuildSSATemp(core));
            bnode.LeftNode = identNode;

            //Right node
            bnode.RightNode = identList;
            bnode.isSSAAssignment = true;

            return bnode;
        }
开发者ID:sh4nnongoh,项目名称:Dynamo,代码行数:16,代码来源:CodeGen_SSA.cs

示例2: BuildOutputAst

        public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAstNodes)
        {
            if (HasUnconnectedInput())
            {
                var connectedInput = Enumerable.Range(0, InPortData.Count)
                                               .Where(HasConnectedInput)
                                               .Select(x => new IntNode(x) as AssociativeNode)
                                               .ToList();

                var paramNumNode = new IntNode(InPortData.Count);
                var positionNode = AstFactory.BuildExprList(connectedInput);
                var arguments = AstFactory.BuildExprList(inputAstNodes);
                var functionNode = new IdentifierListNode
                {
                    LeftNode = new IdentifierNode("DSCore.List"),
                    RightNode = new IdentifierNode("__Create")
                };
                var inputParams = new List<AssociativeNode>
                {
                    functionNode,
                    paramNumNode,
                    positionNode,
                    arguments,
                    AstFactory.BuildBooleanNode(false)
                };

                return new[]
                {
                    AstFactory.BuildAssignment(
                        GetAstIdentifierForOutputIndex(0),
                        AstFactory.BuildFunctionCall("_SingleFunctionObject", inputParams))
                };
            }
            else
            {
                return new[]
                {
                    AstFactory.BuildAssignment(
                        GetAstIdentifierForOutputIndex(0),
                        AstFactory.BuildExprList(inputAstNodes))
                };
            }
        }
开发者ID:TheChosen0ne,项目名称:Dynamo,代码行数:43,代码来源:CreateList.cs

示例3: RewriteIdentifierListNode

        private AssociativeNode RewriteIdentifierListNode(AssociativeNode identifierList)
        {
            var resolvedName = ResolveClassName(identifierList);

            if (string.IsNullOrEmpty(resolvedName))
                return identifierList;

            var identListNode = identifierList as IdentifierListNode;

            var newIdentList = CoreUtils.CreateNodeFromString(resolvedName);

            // If the original input node matches with the resolved name, simply return 
            // the identifier list constructed from the resolved name
            var symbol = new Symbol(resolvedName);
            if (symbol.Matches(identifierList.ToString()))
                return newIdentList;

            // Remove partialName from identListNode and replace with newIdentList
            AssociativeNode leftNode = identListNode != null ? identListNode.LeftNode : identifierList;
            AssociativeNode rightNode = identListNode != null ? identListNode.RightNode : identifierList;

            var intermediateNodes = new List<AssociativeNode>();
            while (leftNode is IdentifierListNode && !symbol.Matches(leftNode.ToString()))
            {
                intermediateNodes.Insert(0, ((IdentifierListNode)leftNode).RightNode);
                leftNode = ((IdentifierListNode)leftNode).LeftNode;
            }
            intermediateNodes.Insert(0, newIdentList);

            var lNode = CoreUtils.CreateNodeByCombiningIdentifiers(intermediateNodes);

            // The last ident list for the functioncall or identifier rhs
            var lastIdentList = new IdentifierListNode
            {
                LeftNode = lNode,
                RightNode = rightNode,
                Optr = Operator.dot
            };

            return lastIdentList;
        }
开发者ID:sh4nnongoh,项目名称:Dynamo,代码行数:41,代码来源:ElementRewriter.cs

示例4: TransformLHSIdentList

        /// <summary>
        /// Converts lhs ident lists to a function call
        /// a.x = 10 
        ///     -> t = a.%set_x(10)
        ///     
        /// a.x.y = b + c 
        ///     -> a.x.%set_y(b + c)
        ///     
        /// a.x[0] = 10
        ///     ->  tval = a.%get_x()
        ///         tval[0] = 10         
        ///         tmp = a.%set_x(tval)
        /// </summary>
        /// <param name="astList"></param>
        /// <returns></returns>
        private List<AssociativeNode> TransformLHSIdentList(List<AssociativeNode> astList)
        {
            List<AssociativeNode> newAstList = new List<AssociativeNode>();
            foreach (AssociativeNode node in astList)
            {
                BinaryExpressionNode bNode = node as BinaryExpressionNode;
                if (bNode == null)
                {
                    newAstList.Add(node);
                }
                else
                {
                    bool isLHSIdentList = bNode.LeftNode is IdentifierListNode;
                    if (!isLHSIdentList)
                    {
                        newAstList.Add(node);
                    }
                    else
                    {
                        IdentifierNode lhsTemp = new IdentifierNode(Constants.kTempVar);

                        IdentifierListNode identList = bNode.LeftNode as IdentifierListNode;
                        Validity.Assert(identList != null);

                        AssociativeNode argument = bNode.RightNode;

                        IdentifierNode identFunctionCall = identList.RightNode as IdentifierNode;
                        string setterName = ProtoCore.DSASM.Constants.kSetterPrefix + identList.RightNode.Name;
                        bool isArrayIndexed = identFunctionCall.ArrayDimensions != null;
                        if (isArrayIndexed)
                        {
                            // a.x[0] = 10
                            //      tval = a.%get_x()
                            string getterName = ProtoCore.DSASM.Constants.kGetterPrefix + identList.RightNode.Name;
                            ProtoCore.AST.AssociativeAST.FunctionCallNode fcall = new ProtoCore.AST.AssociativeAST.FunctionCallNode();
                            fcall.Function = new IdentifierNode(identList.RightNode.Name);
                            fcall.Function.Name = getterName;

                            IdentifierListNode identList1 = new IdentifierListNode();
                            identList1.LeftNode = identList.LeftNode;
                            identList1.RightNode = fcall;
                            BinaryExpressionNode bnodeGet = new BinaryExpressionNode(
                                lhsTemp,
                                identList1, 
                                Operator.assign
                                );
                            newAstList.Add(bnodeGet);

                            //      tval[0] = 10     
                            IdentifierNode lhsTempIndexed = new IdentifierNode(Constants.kTempVar);
                            lhsTempIndexed.ArrayDimensions = identFunctionCall.ArrayDimensions;
                            BinaryExpressionNode bnodeAssign = new BinaryExpressionNode(
                                lhsTempIndexed,
                                argument,
                                Operator.assign
                                );
                            newAstList.Add(bnodeAssign);

                            //      tmp = a.%set_x(tval)
                            ProtoCore.AST.AssociativeAST.FunctionCallNode fcallSet = new ProtoCore.AST.AssociativeAST.FunctionCallNode();
                            fcallSet.Function = identFunctionCall;
                            fcallSet.Function.Name = setterName;
                            List<AssociativeNode> args = new List<AssociativeNode>();
                            IdentifierNode lhsTempAssignBack = new IdentifierNode(Constants.kTempVar);
                            args.Add(lhsTempAssignBack);
                            fcallSet.FormalArguments = args;

                            IdentifierListNode identList2 = new IdentifierListNode();
                            identList2.LeftNode = identList.LeftNode;
                            identList2.RightNode = fcallSet;

                            IdentifierNode lhsTempAssign = new IdentifierNode(Constants.kTempPropertyVar);

                            BinaryExpressionNode bnodeSet = new BinaryExpressionNode(
                                lhsTempAssign,
                                identList2,
                                Operator.assign
                                );
                            newAstList.Add(bnodeSet);
                        }
                        else
                        {
                            List<AssociativeNode> args = new List<AssociativeNode>();
                            args.Add(argument);

//.........这里部分代码省略.........
开发者ID:AutodeskFractal,项目名称:Dynamo,代码行数:101,代码来源:CodeGen.cs

示例5: BuildIdentList

 public AssociativeNode BuildIdentList(AssociativeNode leftNode, AssociativeNode rightNode)
 {
     var identList = new IdentifierListNode();
     identList.LeftNode = leftNode;
     identList.RightNode = rightNode;
     identList.Optr = Operator.dot;
     return identList;
 }
开发者ID:samuto,项目名称:designscript,代码行数:8,代码来源:CodeGen.cs

示例6: dfs_ssa_identlist

        /*
        proc dfs_ssa_identlist(node)
            if node is not null
                dfs_ssa_identlist(node.left)
            end
            if node is functioncall
                foreach arg in functioncallArgs
                    def ssastack[]
                    def astlist[]
                    DFSEmit_SSA_AST(ref arg, ssastack, astlist)
                end
            end
        end
        */
        private BinaryExpressionNode BuildSSAIdentListAssignmentNode(IdentifierListNode identList)
        {
            // Build the final binary expression
            BinaryExpressionNode bnode = new BinaryExpressionNode();
            bnode.Optr = ProtoCore.DSASM.Operator.assign;

            // Left node
            var identNode = nodeBuilder.BuildIdentfier(ProtoCore.Utils.CoreUtils.GetSSATemp(compileStateTracker));
            bnode.LeftNode = identNode;

            //Right node
            bnode.RightNode = identList;
            bnode.isSSAAssignment = true;

            return bnode;
        }
开发者ID:samuto,项目名称:designscript,代码行数:30,代码来源:CodeGen.cs

示例7: BuildIdentifierList

        private ProtoCore.AST.AssociativeAST.IdentifierListNode BuildIdentifierList(List<ProtoCore.AST.AssociativeAST.AssociativeNode> astIdentList)
        {
            // TODO Jun: Replace this condition or handle this case prior to this call
            if (astIdentList.Count < 2)
            {
                return null;
            }

            AST.AssociativeAST.IdentifierListNode identList = null;

            // Build the first ident list
            identList = new AST.AssociativeAST.IdentifierListNode();
            identList.LeftNode = astIdentList[0];
            identList.RightNode = astIdentList[1];

            // Build the rest
            for (int n = 2; n < astIdentList.Count; ++n)
            {
                // Build a new identllist for the prev identlist
                AST.AssociativeAST.IdentifierListNode subIdentList = new AST.AssociativeAST.IdentifierListNode(identList);
                subIdentList.Optr = Operator.dot;

                // Build a new ident and assign it the prev identlist and the next identifier
                identList = new AST.AssociativeAST.IdentifierListNode();
                identList.LeftNode = subIdentList;
                identList.RightNode = astIdentList[n];
            }

            return identList;
        }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:30,代码来源:CodeGen.cs

示例8: CreateNodeFromString

        /// <summary>
        /// Given a name or string of names, this creates an IdentifierNode or IdentifierListNode
        /// e.g. Creates an IdentifierNode from A and IdentifierListNode from A.B
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static AssociativeNode CreateNodeFromString(string name)
        {
            string[] strIdentList = name.Split('.');

            if (strIdentList.Length == 1)
            {
                return new IdentifierNode(strIdentList[0]);
            }

            var newIdentList = new IdentifierListNode
            {
                LeftNode = new IdentifierNode(strIdentList[0]),
                RightNode = new IdentifierNode(strIdentList[1]),
                Optr = Operator.dot
            };
            for (var n = 2; n < strIdentList.Length; ++n)
            {
                var subIdentList = new IdentifierListNode
                {
                    LeftNode = newIdentList,
                    RightNode = new IdentifierNode(strIdentList[n]),
                    Optr = Operator.dot
                };
                newIdentList = subIdentList;
            }

            return newIdentList;
        }
开发者ID:rafatahmed,项目名称:Dynamo,代码行数:34,代码来源:CoreUtils.cs

示例9: Associative_IdentifierList

	void Associative_IdentifierList(out ProtoCore.AST.AssociativeAST.AssociativeNode node) {
		node = null;
		if (isInClass && IsIdentList())
		{
		   disableKwCheck = true;
		}
		
		Associative_NameReference(out node);
		disableKwCheck = false; 
		ProtoCore.AST.AssociativeAST.AssociativeNode inode = node; 
		
		while (la.kind == 6) {
			Get();
			ProtoCore.AST.AssociativeAST.AssociativeNode rnode = null; 
			Associative_NameReference(out rnode);
			if ((inode is ProtoCore.AST.AssociativeAST.IdentifierNode) &&
			   (inode as ProtoCore.AST.AssociativeAST.IdentifierNode).Name == ProtoCore.DSDefinitions.Keyword.This &&
			   (rnode is ProtoCore.AST.AssociativeAST.FunctionCallNode))
			{
			   node = rnode;
			   return;
			}
			
			
			ProtoCore.AST.AssociativeAST.IdentifierListNode bnode = new ProtoCore.AST.AssociativeAST.IdentifierListNode();
			bnode.LeftNode = node;
			bnode.Optr = Operator.dot;
			bnode.RightNode = rnode;
			node = bnode;
			NodeUtils.SetNodeLocation(bnode, bnode.LeftNode, bnode.RightNode);
			
			if (!core.Options.GenerateSSA)
			{
			bool isNeitherIdentOrFunctionCall = !(rnode is ProtoCore.AST.AssociativeAST.IdentifierNode || rnode is ProtoCore.AST.AssociativeAST.FunctionCallNode);
			if (isLeft || isNeitherIdentOrFunctionCall)
			{
			   node = inode;
			}
			else 
			{
			   if (rnode is ProtoCore.AST.AssociativeAST.IdentifierNode)
			   {
			       ProtoCore.AST.AssociativeAST.FunctionCallNode rcall = new ProtoCore.AST.AssociativeAST.FunctionCallNode();
			       rcall.Function = rnode;
			       rcall.Function.Name = ProtoCore.DSASM.Constants.kGetterPrefix + rcall.Function.Name;
			       bnode.RightNode = rcall;
			
			       NodeUtils.SetNodeLocation(rcall, rnode, rnode);
			       node = ProtoCore.Utils.CoreUtils.GenerateCallDotNode(bnode.LeftNode, rcall, core);
			   }
			   else
			   {
			       string rhsName = null;
			       ProtoCore.AST.AssociativeAST.ExprListNode dimList = null;
			       int dim = 0;
			       if (rnode is ProtoCore.AST.AssociativeAST.FunctionCallNode)
			       {
			           ProtoCore.AST.AssociativeAST.FunctionCallNode rhsFNode = rnode as ProtoCore.AST.AssociativeAST.FunctionCallNode;
			           node = ProtoCore.Utils.CoreUtils.GenerateCallDotNode(node, rhsFNode, core);
			       }
			   }
			}
			}
			
		}
		{
		   if (!isModifier && withinModifierCheckScope)
		   {
		       if (isLeftVarIdentList)
		       {
		           if (inode is ProtoCore.AST.AssociativeAST.IdentifierListNode)
		           {
		               isModifier = false;
		               if (node is ProtoCore.AST.AssociativeAST.FunctionDotCallNode)
		               {
		                   ProtoCore.AST.AssociativeAST.FunctionDotCallNode fdotCall = node as ProtoCore.AST.AssociativeAST.FunctionDotCallNode;
		                   string checkVar = ProtoCore.Utils.CoreUtils.GenerateIdentListNameString(fdotCall.GetIdentList());
		                   isModifier = (leftVar == checkVar);
		               }
		           }
		       }
		       else if (inode is ProtoCore.AST.AssociativeAST.IdentifierNode)
		       {
		           isModifier = (leftVar == inode.Name);
		       }   
		
		       // The LHS is an identifier
		       else
		       {
		           // It is a modifier if the lhs is:
		           //   1. the same as the current node
		           //   2. the current node starts with the lhs identifier
		           isModifier = (leftVar == inode.Name);
		           if (!isModifier)
		           {
		               string rhsString = ProtoCore.Utils.CoreUtils.GenerateIdentListNameString(inode);
		
		               isModifier = rhsString.StartsWith(leftVar);
		           }
		       }
//.........这里部分代码省略.........
开发者ID:limrzx,项目名称:Dynamo,代码行数:101,代码来源:Parser.cs

示例10: BuildAst

        internal override IEnumerable<AssociativeNode> BuildAst(List<AssociativeNode> inputAstNodes)
        {
            string function = Definition.Name;
            AssociativeNode rhs;

            switch (Definition.Type)
            {
                case FunctionType.Constructor:
                case FunctionType.StaticMethod:
                    if (IsPartiallyApplied)
                    {
                        var functionNode = new IdentifierListNode
                        {
                            LeftNode = new IdentifierNode(Definition.ClassName),
                            RightNode = new IdentifierNode(Definition.Name)
                        };
                        rhs = CreateFunctionObject(functionNode, inputAstNodes);
                    }
                    else
                    {
                        AppendReplicationGuides(inputAstNodes);
                        rhs = AstFactory.BuildFunctionCall(
                            Definition.ClassName,
                            Definition.Name,
                            inputAstNodes);
                    }
                    break;

                case FunctionType.StaticProperty:

                    var staticProp = new IdentifierListNode
                    {
                        LeftNode = new IdentifierNode(Definition.ClassName),
                        RightNode = new IdentifierNode(Definition.Name)
                    };
                    rhs = staticProp;
                    break;

                case FunctionType.InstanceProperty:

                    // Only handle getter here. Setter could be handled in CBN.
                    if (IsPartiallyApplied)
                    {
                        var functionNode = new IdentifierListNode
                        {
                            LeftNode = new IdentifierNode(Definition.ClassName),
                            RightNode = new IdentifierNode(Definition.Name)
                        };
                        rhs = CreateFunctionObject(functionNode, inputAstNodes);
                    }
                    else
                    {
                        rhs = new NullNode();
                        if (inputAstNodes != null && inputAstNodes.Count >= 1)
                        {
                            var thisNode = inputAstNodes[0];
                            if (thisNode != null && !(thisNode is NullNode))
                            {
                                var insProp = new IdentifierListNode
                                {
                                    LeftNode = inputAstNodes[0],
                                    RightNode = new IdentifierNode(Definition.Name)
                                };
                                rhs = insProp;
                            }
                        }
                    }

                    break;

                case FunctionType.InstanceMethod:
                    if (IsPartiallyApplied)
                    {
                        var functionNode = new IdentifierListNode
                        {
                            LeftNode = new IdentifierNode(Definition.ClassName),
                            RightNode = new IdentifierNode(Definition.Name)
                        };
                        rhs = CreateFunctionObject(functionNode, inputAstNodes);
                    }
                    else
                    {
                        rhs = new NullNode();
                        AppendReplicationGuides(inputAstNodes);

                        if (inputAstNodes != null && inputAstNodes.Count >= 1)
                        {
                            var thisNode = inputAstNodes[0];
                            inputAstNodes.RemoveAt(0); // remove this pointer

                            if (thisNode != null && !(thisNode is NullNode))
                            {
                                var memberFunc = new IdentifierListNode
                                {
                                    LeftNode = thisNode,
                                    RightNode = AstFactory.BuildFunctionCall(function, inputAstNodes)
                                };
                                rhs = memberFunc;
                            }
                        }
//.........这里部分代码省略.........
开发者ID:heegwon,项目名称:Dynamo,代码行数:101,代码来源:DSFunction.cs

示例11: GraphILTest_FFIClassUsage_02_astInput

        public void GraphILTest_FFIClassUsage_02_astInput()
        {
            ProtoScript.Runners.ILiveRunner liveRunner = new ProtoScript.Runners.LiveRunner();

            List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
            //==============================================
            // Build the import Nodes
            //==============================================
            List<string> libs = new List<string>();
            libs.Add("ProtoGeometry.dll");
            List<LibraryMirror> libMirrors = liveRunner.ResetVMAndImportLibrary(libs);

            //==============================================
            // Build the constructor call nodes
            // Point.ByCoordinates(10,10,10)
            //==============================================
            ProtoCore.AST.AssociativeAST.FunctionCallNode constructorCall = new ProtoCore.AST.AssociativeAST.FunctionCallNode();
            constructorCall.Function = new ProtoCore.AST.AssociativeAST.IdentifierNode("ByCoordinates");
            List<ProtoCore.AST.AssociativeAST.AssociativeNode> listArgs = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
            listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(10.0));
            listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(10.0));
            listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(10.0));
            constructorCall.FormalArguments = listArgs;

            string className = "Point";
            ProtoCore.AST.AssociativeAST.IdentifierNode inode = new ProtoCore.AST.AssociativeAST.IdentifierNode(className);

            ProtoCore.AST.AssociativeAST.FunctionDotCallNode dotCall = ProtoCore.Utils.CoreUtils.GenerateCallDotNode(inode, constructorCall, liveRunner.Core);

            //==============================================
            // Build the binary expression 
            // p = Point.ByCoordinates(10,10,10)
            //==============================================
            ProtoCore.AST.AssociativeAST.BinaryExpressionNode stmt1 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
                new ProtoCore.AST.AssociativeAST.IdentifierNode("p"),
                dotCall,
                ProtoCore.DSASM.Operator.assign);
            astList.Add(stmt1);
            //==============================================
            // Translate the point
            // newPoint = p.Translate(1,2,3);
            //==============================================
            ProtoCore.AST.AssociativeAST.FunctionCallNode functionCallTranslate = new ProtoCore.AST.AssociativeAST.FunctionCallNode();
            functionCallTranslate.Function = new ProtoCore.AST.AssociativeAST.IdentifierNode("Translate");
            listArgs = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
            listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(1.0));
            listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(2.0));
            listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(3.0));
            functionCallTranslate.FormalArguments = listArgs;

            //ProtoCore.AST.AssociativeAST.FunctionDotCallNode dotCallTranslate = new ProtoCore.AST.AssociativeAST.FunctionDotCallNode("p", functionCallTranslate);
            className = "p";
            inode = new ProtoCore.AST.AssociativeAST.IdentifierNode(className);

            ProtoCore.AST.AssociativeAST.FunctionDotCallNode dotCallTranslate = ProtoCore.Utils.CoreUtils.GenerateCallDotNode(inode, functionCallTranslate, liveRunner.Core);

            //==============================================
            // Build the binary expression 
            //==============================================
            ProtoCore.AST.AssociativeAST.BinaryExpressionNode stmt2 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
                new ProtoCore.AST.AssociativeAST.IdentifierNode("newPoint"),
                dotCallTranslate,
                ProtoCore.DSASM.Operator.assign);
            astList.Add(stmt2);

            //==============================================
            // Build a binary expression to retirieve the x property
            // xval = newPoint.X
            //==============================================
            ProtoCore.AST.AssociativeAST.IdentifierListNode identListNode = new ProtoCore.AST.AssociativeAST.IdentifierListNode();
            identListNode.LeftNode = new ProtoCore.AST.AssociativeAST.IdentifierNode("newPoint");
            identListNode.Optr = ProtoCore.DSASM.Operator.dot;
            identListNode.RightNode = new ProtoCore.AST.AssociativeAST.IdentifierNode("X");
            ProtoCore.AST.AssociativeAST.BinaryExpressionNode stmt3 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
                new ProtoCore.AST.AssociativeAST.IdentifierNode("xval"),
                identListNode,
                ProtoCore.DSASM.Operator.assign);
            astList.Add(stmt3);
            //==============================================
            // 
            // import ("ProtoGeometry.dll");
            // p = Point.Bycoordinates(10.0, 10.0, 10.0);
            // newPoint = p.Translate(1.0,2.0,3.0);
            // xval = newPoint.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 == 11.0);

        }
开发者ID:algobasket,项目名称:Dynamo,代码行数:96,代码来源:MicroFeatureTests.cs

示例12: GraphILTest_FFIClassUsage_01

        public void GraphILTest_FFIClassUsage_01()
        {
            List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
            //==============================================
            // Build the import Nodes
            //==============================================
            ProtoScript.Runners.ILiveRunner liveRunner = new ProtoScript.Runners.LiveRunner();

            List<string> libs = new List<string>();
            libs.Add("ProtoGeometry.dll");
            liveRunner.ResetVMAndResyncGraph(libs);

            //==============================================
            // Build the constructor call nodes
            // Point.ByCoordinates(10,10,10)
            //============================================== 
            astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();

            ProtoCore.AST.AssociativeAST.FunctionCallNode constructorCall = new ProtoCore.AST.AssociativeAST.FunctionCallNode();
            constructorCall.Function = new ProtoCore.AST.AssociativeAST.IdentifierNode("ByCoordinates");
            List<ProtoCore.AST.AssociativeAST.AssociativeNode> listArgs = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
            listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(10.0));
            listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(10.0));
            listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(10.0));
            constructorCall.FormalArguments = listArgs;

            string className = "Point";
            ProtoCore.AST.AssociativeAST.IdentifierNode inode = new ProtoCore.AST.AssociativeAST.IdentifierNode(className);

            ProtoCore.AST.AssociativeAST.FunctionDotCallNode dotCall = ProtoCore.Utils.CoreUtils.GenerateCallDotNode(inode, constructorCall, liveRunner.Core);
            //==============================================
            // Build the binary expression 
            // p = Point.ByCoordinates(10,10,10)
            //==============================================
            ProtoCore.AST.AssociativeAST.BinaryExpressionNode stmt1 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
                new ProtoCore.AST.AssociativeAST.IdentifierNode("p"),
                dotCall,
                ProtoCore.DSASM.Operator.assign);
            astList.Add(stmt1);
            //==============================================
            // Build a binary expression to retirieve the x property
            // xval = p.X;
            //==============================================
            ProtoCore.AST.AssociativeAST.IdentifierListNode identListNode = new ProtoCore.AST.AssociativeAST.IdentifierListNode();
            identListNode.LeftNode = new ProtoCore.AST.AssociativeAST.IdentifierNode("p");
            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);
            //==============================================
            // emit the DS code from the AST tree
            //
            // import("ProtoGeometry.dll");
            // p = Point.Bycoordinates(10.0, 10.0, 10.0);
            // xval = p.X;
            //
            //==============================================

            // Instantiate GraphSyncData
            List<Subtree> addedList = new List<Subtree>();
            addedList.Add(new Subtree(astList, System.Guid.NewGuid()));
            GraphSyncData syncData = new GraphSyncData(null, addedList, null);

            // emit the DS code from the AST tree

            liveRunner.UpdateGraph(syncData);

            ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("xval");
            Assert.IsTrue((double)mirror.GetData().Data == 10.0);


            ///////////////////////////////////////////////////////////////////////////////
            libs = new List<string>();
            libs.Add("ProtoGeometry.dll");
            liveRunner.ResetVMAndResyncGraph(libs);

            astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();

            constructorCall = new ProtoCore.AST.AssociativeAST.FunctionCallNode();
            constructorCall.Function = new ProtoCore.AST.AssociativeAST.IdentifierNode("ByCoordinates");
            listArgs = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
            listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(10.0));
            listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(10.0));
            listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(10.0));
            constructorCall.FormalArguments = listArgs;

            className = "Point";
            inode = new ProtoCore.AST.AssociativeAST.IdentifierNode(className);

            dotCall = ProtoCore.Utils.CoreUtils.GenerateCallDotNode(inode, constructorCall, liveRunner.Core);
            //==============================================
            // Build the binary expression 
            // p = Point.ByCoordinates(10,10,10)
            //==============================================
            stmt1 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
                new ProtoCore.AST.AssociativeAST.IdentifierNode("p"),
                dotCall,
//.........这里部分代码省略.........
开发者ID:algobasket,项目名称:Dynamo,代码行数:101,代码来源:MicroFeatureTests.cs

示例13: GetIdentifierStringUntilFirstParenthesis

 /// <summary>
 /// Retrieves the string format of the identifier list from left to right, leaving out any symbols after the last identifier.
 /// Given: A.B()
 ///     Return: "A.B"
 /// Given: A.B.C()[0]
 ///     Return: "A.B.C"
 /// Given: A.B().C
 ///     Return: "A.B"
 /// Given: A.B[0].C
 ///     Return: "A.B[0].C"
 /// </summary>
 /// <param name="identList"></param>
 /// <returns></returns>
 public static string GetIdentifierStringUntilFirstParenthesis(IdentifierListNode identList)
 {
     Validity.Assert(null != identList);
     string identListString = identList.ToString();
     int removeIndex = identListString.IndexOf('(');
     if (removeIndex > 0)
     {
         identListString = identListString.Remove(removeIndex);
     }
     return identListString;
 }
开发者ID:nmeek,项目名称:Dynamo,代码行数:24,代码来源:CoreUtils.cs

示例14: SSAIdentList

        //
        //  proc SSAIdentList(node, ssastack, ast)
        //  {
        //      if node is ident
        //          t = SSATemp()
        //          tmpIdent = new Ident(t)
        //          binexpr = new BinaryExpr(tmpIdent, node)
        //          ast.push(binexpr)
        //          ssastack.push(tmpIdent)
        //      else if node is identlist
        //          SSAIdentList(node.left, ssastack, ast)
        //          rhs = new identlist(new Ident(ssastack.pop), node.right)
        //          t = SSATemp()
        //          tmpIdent = new Ident(t) 
        //          binexpr = new BinaryExpr(tmpIdent, rhs) 
        //          ast.push(binexpr)
        //          ssastack.push(tmpIdent) 
        //      end
        //  }
        //

        private void SSAIdentList(AssociativeNode node, ref Stack<AssociativeNode> ssaStack, ref List<AssociativeNode> astlist)
        {
            if (node is IdentifierNode)
            {
                IdentifierNode ident = node as IdentifierNode;
                if (null == ident.ArrayDimensions)
                {
                    // Build the temp pointer
                    BinaryExpressionNode bnode = new BinaryExpressionNode();
                    bnode.Optr = ProtoCore.DSASM.Operator.assign;
                    bnode.isSSAAssignment = true;
                    bnode.isSSAPointerAssignment = true;

                    // Left node
                    var identNode = nodeBuilder.BuildIdentfier(ProtoCore.Utils.CoreUtils.BuildSSATemp(core));
                    (identNode as IdentifierNode).ReplicationGuides = GetReplicationGuides(ident);
                    bnode.LeftNode = identNode;

                    // Right node
                    bnode.RightNode = ident;

                    astlist.Add(bnode);
                    ssaStack.Push(bnode);
                }
                else
                {
                    EmitSSAArrayIndex(ident, ssaStack, ref astlist, true);
                }

            }
            else if (node is ExprListNode)
            {
                //ExprListNode exprList = node as ExprListNode;
                DFSEmitSSA_AST(node, ssaStack, ref astlist);
            }
            else if (node is FunctionCallNode)
            {
                FunctionCallNode fcall = node as FunctionCallNode;
                if (null == fcall.ArrayDimensions)
                {
                    // Build the temp pointer
                    BinaryExpressionNode bnode = new BinaryExpressionNode();
                    bnode.Optr = ProtoCore.DSASM.Operator.assign;
                    bnode.isSSAAssignment = true;
                    bnode.isSSAPointerAssignment = true;

                    // Left node
                    var identNode = nodeBuilder.BuildIdentfier(ProtoCore.Utils.CoreUtils.BuildSSATemp(core));
                    (identNode as IdentifierNode).ReplicationGuides = fcall.ReplicationGuides;
                    bnode.LeftNode = identNode;

                    // Right node
                    bnode.RightNode = fcall;


                    astlist.Add(bnode);
                    ssaStack.Push(bnode);
                }
                else
                {
                    EmitSSAArrayIndex(fcall, ssaStack, ref astlist, true);
                }

            }
            else if (node is IdentifierListNode)
            {
                IdentifierListNode identList = node as IdentifierListNode;

                //Check if the LeftNode for given IdentifierList represents a class.
                string[] classNames = ProtoCore.Utils.CoreUtils.GetResolvedClassName(core.ClassTable, identList);
                if (classNames.Length > 1)
                {
                    // There is a namespace conflict

                    // TODO Jun: Move this warning handler to after the SSA transform
                    // http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-5221
                    buildStatus.LogSymbolConflictWarning(identList.LeftNode.ToString(), classNames);
                }
                else if(classNames.Length == 1)
//.........这里部分代码省略.........
开发者ID:whztt07,项目名称:Dynamo,代码行数:101,代码来源:CodeGen.cs

示例15: VisitIdentifierListNode

        public override AssociativeNode VisitIdentifierListNode(IdentifierListNode node)
        {
            // First pass attempt to resolve the node before traversing it deeper
            AssociativeNode newIdentifierListNode = null;
            if (IsMatchingResolvedName(node, out newIdentifierListNode))
                return newIdentifierListNode;

            var rightNode = node.RightNode;
            var leftNode = node.LeftNode;

            rightNode = rightNode.Accept(this);
            leftNode = leftNode.Accept(this);

            node = new IdentifierListNode
            {
                LeftNode = leftNode,
                RightNode = rightNode,
                Optr = Operator.dot
            };
            return RewriteIdentifierListNode(node);
        }
开发者ID:sh4nnongoh,项目名称:Dynamo,代码行数:21,代码来源:ElementRewriter.cs


注:本文中的ProtoCore.AST.AssociativeAST.IdentifierListNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。