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


C# AssociativeAST.FunctionCallNode类代码示例

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


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

示例1: CreateFunctionCallNode

        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);
        }
开发者ID:heegwon,项目名称:Dynamo,代码行数:9,代码来源:ASTCompilerUtils.cs

示例2: CreateEntityNode

        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);            
        }
开发者ID:heegwon,项目名称:Dynamo,代码行数:12,代码来源:ASTCompilerUtils.cs

示例3: 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

示例4: TraverseDotCallArguments

        private void TraverseDotCallArguments(FunctionCallNode funcCall, 
                                              FunctionDotCallNode dotCall,
                                              ProcedureNode procCallNode,
                                              List<ProtoCore.Type> arglist,
                                              string procName,
                                              int classIndex,
                                              string className,
                                              bool isStaticCall,
                                              bool isConstructor,
                                              GraphNode graphNode,
                                              ProtoCore.CompilerDefinitions.Associative.SubCompilePass subPass,
                                              BinaryExpressionNode bnode)
        {
            // Update graph dependencies
            if (subPass != ProtoCore.CompilerDefinitions.Associative.SubCompilePass.kUnboundIdentifier && graphNode != null)
            {
                if (isStaticCall)
                {
                    Validity.Assert(classIndex != Constants.kInvalidIndex);
                    Validity.Assert(!string.IsNullOrEmpty(className));

                    SymbolNode classSymbol = new SymbolNode();
                    classSymbol.name = className;
                    classSymbol.classScope = classIndex;
                    PushSymbolAsDependent(classSymbol, graphNode);
                }
            }

            int funtionArgCount = 0;
            for (int n = 0; n < funcCall.FormalArguments.Count; ++n)
            {
                if (isStaticCall || isConstructor)
                {
                    if (n != Constants.kDotArgIndexArrayArgs)
                    {
                        continue;
                    }
                }

                AssociativeNode paramNode = funcCall.FormalArguments[n];
                ProtoCore.Type paramType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 0);

                emitReplicationGuide = false;

                // If it's a binary node then continue type check, otherwise 
                // disable type check and just take the type of paramNode itself
                enforceTypeCheck = !(paramNode is BinaryExpressionNode);

                if (ProtoCore.DSASM.Constants.kDotArgIndexPtr == n)
                {
                    // Traversing the first arg (the LHS pointer/Static instanct/Constructor
                    
                    // Replication guides only allowed on method, e.g.,
                    // 
                    //    x = p<1>.f({1,2}<2>); 
                    //
                    // But not on getter, e.g.,
                    // 
                    //    c = a<1>.x<2>; 
                    if (!CoreUtils.IsGetterSetter(procName) && !isConstructor)
                    {
                        emitReplicationGuide = true;
                    }

                    DfsTraverse(paramNode, ref paramType, false, graphNode, subPass, bnode);
                }
                else if (ProtoCore.DSASM.Constants.kDotArgIndexArrayArgs == n)
                {
                    // Traversing the actual arguments passed into the function 
                    // (not the dot function)
                    int defaultArgNumber = 0;

                    // If its null this is the second call in a chained dot
                    if (null != procCallNode)
                    {
                        defaultArgNumber = procCallNode.ArgumentInfos.Count - dotCall.FunctionCall.FormalArguments.Count;
                    }

                    // Enable graphnode dependencies if its a setter method
                    bool allowDependentState = null != graphNode ? graphNode.allowDependents : false;
                    if (CoreUtils.IsSetter(procName))
                    {
                        // If the arguments are not temporaries
                        ExprListNode exprList = paramNode as ExprListNode;
                        Validity.Assert(1 == exprList.Exprs.Count);

                        string varname = string.Empty;
                        if (exprList.Exprs[0] is IdentifierNode)
                        {
                            varname = (exprList.Exprs[0] as IdentifierNode).Name;

                            if (!CoreUtils.IsAutoGeneratedVar(varname))
                            {
                                graphNode.allowDependents = true;
                            }
                            else if (CoreUtils.IsSSATemp(varname) && core.Options.GenerateSSA)
                            {
                                graphNode.allowDependents = true;
                            }
                        }
//.........这里部分代码省略.........
开发者ID:AutodeskFractal,项目名称:Dynamo,代码行数:101,代码来源:CodeGen.cs

示例5: BuildThisFunctionBody

        private void BuildThisFunctionBody(ThisPointerProcOverload procOverload)
        {
            BinaryExpressionNode thisFunctionBody = new BinaryExpressionNode();
            IdentifierNode leftNode = new IdentifierNode();
            leftNode.Name = leftNode.Value = ProtoCore.DSDefinitions.Keyword.Return;
            thisFunctionBody.LeftNode = leftNode;

            thisFunctionBody.Optr = Operator.assign;


            // Build the function call and pass it the arguments including the this pointer
            FunctionCallNode fcall = new FunctionCallNode();
            IdentifierNode identNode = new IdentifierNode();
            identNode.Name = procOverload.procNode.Name;
            fcall.Function = identNode;

            // Set the arguments passed into the function excluding the 'this' argument
            List<AssociativeNode> args = new List<AssociativeNode>();
            for (int n = 1; n < procOverload.procNode.Signature.Arguments.Count; ++n)
            {
                VarDeclNode varDecl = procOverload.procNode.Signature.Arguments[n];
                args.Add(varDecl.NameNode);
            }
            fcall.FormalArguments = args;


            // Build the dotcall node
            procOverload.procNode.FunctionBody.Body = new List<AssociativeNode>();
            procOverload.procNode.FunctionBody.Body.Add(thisFunctionBody);

            thisFunctionBody.RightNode = CoreUtils.GenerateCallDotNode(procOverload.procNode.Signature.Arguments[0].NameNode, fcall, core);
        }
开发者ID:AutodeskFractal,项目名称:Dynamo,代码行数:32,代码来源:CodeGen.cs

示例6: 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

示例7: SSAIdentList

        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;
                    bnode.IsFirstIdentListNode = true;

                    // Left node
                    var identNode =AstFactory.BuildIdentifier(ProtoCore.Utils.CoreUtils.BuildSSATemp(core));
                    identNode.ReplicationGuides = GetReplicationGuides(ident);
                    identNode.AtLevel = ident.AtLevel;

                    bnode.LeftNode = identNode;

                    // Right node
                    bnode.RightNode = ident;

                    astlist.Add(bnode);
                    ssaStack.Push(bnode);
                }
                else
                {
                    EmitSSAArrayIndex(ident, ssaStack, ref astlist, true);
                    (astlist[0] as BinaryExpressionNode).IsFirstIdentListNode = 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;
                    bnode.IsFirstIdentListNode = true;

                    // Left node
                    var identNode =AstFactory.BuildIdentifier(ProtoCore.Utils.CoreUtils.BuildSSATemp(core));
                    identNode.ReplicationGuides = fcall.ReplicationGuides;
                    identNode.AtLevel = fcall.AtLevel;
                    bnode.LeftNode = identNode;

                    // Right node
                    bnode.RightNode = fcall;


                    astlist.Add(bnode);
                    ssaStack.Push(bnode);
                }
                else
                {
                    EmitSSAArrayIndex(fcall, ssaStack, ref astlist, true);
                    (astlist[0] as BinaryExpressionNode).IsFirstIdentListNode = true;
                }

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

                // Build the rhs identifier list containing the temp pointer
                IdentifierListNode rhsIdentList = new IdentifierListNode();
                rhsIdentList.Optr = Operator.dot;

                bool isLeftNodeExprList = false;

                // Check if identlist matches any namesapce
                bool resolvedCall = false;
                string[] classNames = ProtoCore.Utils.CoreUtils.GetResolvedClassName(core.ClassTable, identList);
                if (classNames.Length == 1)
                {
                    //
                    // The identlist is a class name and should not be SSA'd
                    // such as:
                    //  p = Obj.Create()
                    //
                    var leftNode =AstFactory.BuildIdentifier(classNames[0]);
                    rhsIdentList.LeftNode = leftNode;
                    ProtoCore.Utils.CoreUtils.CopyDebugData(leftNode, node);
                    resolvedCall = true;
                }
                else if (classNames.Length > 0)
                {
                    // There is a resolution conflict
                    // identList resolved to multiple classes 
//.........这里部分代码省略.........
开发者ID:AutodeskFractal,项目名称:Dynamo,代码行数:101,代码来源:CodeGen.cs

示例8: DFSEmit_SSA_AST


//.........这里部分代码省略.........
                }

                //bnode.RightNode = rhsIdent;

                //astlist.Add(bnode);
                //ssaStack.Push(bnode);
            }
            else if (node is IdentifierNode)
            {
                IdentifierNode ident = node as IdentifierNode;

                if (null == ident.ArrayDimensions)
                {
                    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 = ident;

                    bnode.isSSAAssignment = true;

                    astlist.Add(bnode);
                    ssaStack.Push(bnode);
                }
                else
                {
                    EmitSSAArrayIndex(ident, ssaStack, ref astlist);
                }
            }
            else if (node is FunctionCallNode || node is FunctionDotCallNode)
            {
                FunctionCallNode fcNode = null;
                if (node is FunctionCallNode)
                {
                    fcNode = node as FunctionCallNode;

                    for (int idx = 0; idx < fcNode.FormalArguments.Count; idx++)
                    {
                        AssociativeNode arg = fcNode.FormalArguments[idx];
                        DFSEmitSSA_AST(arg, ssaStack, ref astlist);
                        AssociativeNode argNode = ssaStack.Pop();

                        if (argNode is BinaryExpressionNode)
                        {
                            BinaryExpressionNode argBinaryExpr = argNode as BinaryExpressionNode;
                            (argBinaryExpr.LeftNode as IdentifierNode).ReplicationGuides = GetReplicationGuidesFromASTNode(argBinaryExpr.RightNode);

                            fcNode.FormalArguments[idx] = argBinaryExpr.LeftNode;
                        }
                        else
                        {
                            fcNode.FormalArguments[idx] = argNode;
                        }
                    }
                }

                BinaryExpressionNode bnode = new BinaryExpressionNode();
                bnode.Optr = ProtoCore.DSASM.Operator.assign;

                // Left node
                var identNode = nodeBuilder.BuildIdentfier(ProtoCore.Utils.CoreUtils.GetSSATemp(compileStateTracker));
                bnode.LeftNode = identNode;
开发者ID:samuto,项目名称:designscript,代码行数:67,代码来源:CodeGen.cs

示例9: GenerateUnaryOperatorMethodCallNode

        private ProtoCore.AST.AssociativeAST.AssociativeNode GenerateUnaryOperatorMethodCallNode(UnaryOperator op, ProtoCore.AST.AssociativeAST.AssociativeNode operand)
        {
            ProtoCore.AST.AssociativeAST.FunctionCallNode funCallNode = new ProtoCore.AST.AssociativeAST.FunctionCallNode();
            ProtoCore.AST.AssociativeAST.IdentifierNode funcName = new ProtoCore.AST.AssociativeAST.IdentifierNode { Value = ProtoCore.DSASM.Constants.kInternalNamePrefix + op.ToString(), Name = ProtoCore.DSASM.Constants.kInternalNamePrefix + op.ToString() };
            funCallNode.Function = funcName;
            funCallNode.Name = ProtoCore.DSASM.Constants.kInternalNamePrefix + op.ToString();
            funCallNode.FormalArguments.Add(operand);

            NodeUtils.CopyNodeLocation(funCallNode, operand);
            return funCallNode;
        }
开发者ID:Benglin,项目名称:designscript,代码行数:11,代码来源:Parser.cs

示例10: 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 = this.core.ClassTable.GetAllMatchingClasses(identList.LeftNode.ToString());
                if (classNames.Length > 1)
                {
                    string message = string.Format(WarningMessage.kMultipleSymbolFound, identList.LeftNode.ToString(), classNames[0]);
                    for(int i = 1; i < classNames.Length; ++i)
                        message += ", " + classNames[i];
                    this.core.BuildStatus.LogWarning(WarningID.kMultipleSymbolFound, message);
                }

                if(classNames.Length == 1)
                {
                    var leftNode = nodeBuilder.BuildIdentfier(classNames[0]);
//.........这里部分代码省略.........
开发者ID:TheChosen0ne,项目名称:Dynamo,代码行数:101,代码来源:CodeGen.cs

示例11: FunctionDotCallNode

 public FunctionDotCallNode(FunctionDotCallNode rhs): base(rhs)
 {
     DotCall = new FunctionCallNode(rhs.DotCall);
     FunctionCall = new FunctionCallNode(rhs.FunctionCall);
     lhsName = rhs.lhsName;
     isLastSSAIdentListFactor = rhs.isLastSSAIdentListFactor;
 }
开发者ID:qingemeng,项目名称:designscript,代码行数:7,代码来源:AssociativeAST.cs

示例12: FunctionCallNode

        public FunctionCallNode(FunctionCallNode rhs)
            : base(rhs)
        {
            Function = NodeUtils.Clone(rhs.Function);
            FormalArguments = new List<AssociativeNode>();
            foreach (AssociativeNode argNode in rhs.FormalArguments)
            {
                AssociativeNode tempNode = NodeUtils.Clone(argNode);
                FormalArguments.Add(tempNode);
            }

            DynamicTableIndex = rhs.DynamicTableIndex;
        }
开发者ID:qingemeng,项目名称:designscript,代码行数:13,代码来源:AssociativeAST.cs

示例13: GraphILTest_FFIClassUsage_03

        public void GraphILTest_FFIClassUsage_03()
        {
            //
            //  a=2;
            //  tSSA_150=1..10;
            //  x= tSSA_150;
            //  tSSA_151=x;
            //  tSSA_152=a;
            //  tSSA_153=( tSSA_151+ tSSA_152);
            //  var_79153f69593b4fde9bb50646a1aaea96= tSSA_153;
            //  tSSA_154=Point.ByCoordinates(var_79153f69593b4fde9bb50646a1aaea96,a,a);
            //  var_347c1113204a4d15a22f7daf83bbe20e= tSSA_154;
            //

            //
            //  a=2;
            //  x=1..10;
            //  var_79153f69593b4fde9bb50646a1aaea96=(x+a);
            //  var_347c1113204a4d15a22f7daf83bbe20e=Point.ByCoordinates(var_79153f69593b4fde9bb50646a1aaea96,a,a);
            //

            ProtoScript.Runners.ILiveRunner liveRunner = new ProtoScript.Runners.LiveRunner();

            List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
            //==============================================
            // Build the import Nodes
            //==============================================
            //ProtoCore.AST.AssociativeAST.ImportNode importNode = new ProtoCore.AST.AssociativeAST.ImportNode();
            //importNode.ModuleName = "ProtoGeometry.dll";
            //astList.Add(importNode);

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




            // Build the AST trees
            // a = 2
            ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign1 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
                new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
                new ProtoCore.AST.AssociativeAST.IntNode(2),
                ProtoCore.DSASM.Operator.assign);
            astList.Add(assign1);


            // x = 1..10;
            ProtoCore.AST.AssociativeAST.RangeExprNode rangeExpr = new ProtoCore.AST.AssociativeAST.RangeExprNode();
            rangeExpr.FromNode = new ProtoCore.AST.AssociativeAST.IntNode(1);
            rangeExpr.ToNode = new ProtoCore.AST.AssociativeAST.IntNode(10);
            rangeExpr.StepNode = new ProtoCore.AST.AssociativeAST.IntNode(1);
            ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign2 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
                new ProtoCore.AST.AssociativeAST.IdentifierNode("x"),
                rangeExpr,
                ProtoCore.DSASM.Operator.assign);
            astList.Add(assign2);

            // var_79153f69593b4fde9bb50646a1aaea96 = (x + a);
            ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign3 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
                new ProtoCore.AST.AssociativeAST.IdentifierNode("dude"),
                new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
                    new ProtoCore.AST.AssociativeAST.IdentifierNode("x"),
                    new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
                    ProtoCore.DSASM.Operator.add),
                ProtoCore.DSASM.Operator.assign);

            astList.Add(assign3);




            //==============================================
            // 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.IdentifierNode("dude"));
            listArgs.Add(new ProtoCore.AST.AssociativeAST.IdentifierNode("a"));
            listArgs.Add(new ProtoCore.AST.AssociativeAST.IdentifierNode("a"));
            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("final"),
                dotCall,
                ProtoCore.DSASM.Operator.assign);
            astList.Add(stmt1);


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

示例14: ContextDataMethodCallNode

        private AssociativeNode ContextDataMethodCallNode(IContextData data)
        {
            string appname = data.ContextProvider.Name;
            string connectionstring = data.Name;
            string varname = data.Name;
            //
            //Build a functioncall node for expression varname = ImportData(appname, connectionstring);

            var func = new ProtoCore.AST.AssociativeAST.IdentifierNode();
            func.Value = func.Name = ProtoCore.DSASM.Constants.kImportData;

            var paramAppName = new ProtoCore.AST.AssociativeAST.StringNode();
            paramAppName.value = appname;

            var paramConnectionString = new ProtoCore.AST.AssociativeAST.StringNode();
            paramConnectionString.value = connectionstring;

            var funcCall = new ProtoCore.AST.AssociativeAST.FunctionCallNode();
            funcCall.Function = func;
            funcCall.Name = ProtoCore.DSASM.Constants.kImportData;
            funcCall.FormalArguments.Add(paramAppName);
            funcCall.FormalArguments.Add(paramConnectionString);

            var var = new ProtoCore.AST.AssociativeAST.IdentifierNode();
            var.Name = var.Value = varname;

            var assignExpr = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode();
            assignExpr.LeftNode = var;
            assignExpr.Optr = ProtoCore.DSASM.Operator.assign;
            assignExpr.RightNode = funcCall;

            return assignExpr;
        }
开发者ID:algobasket,项目名称:Dynamo,代码行数:33,代码来源:ContextDataManager.cs

示例15: EmitGetterSetterForIdent

        protected FunctionCallNode EmitGetterSetterForIdent(IdentifierNode inode, bool isSetter = false)
        {
            if (isSetter)
            {
                FunctionCallNode setter = new FunctionCallNode();
                setter.Function = inode;

                IdentifierNode tmpArg = new IdentifierNode();
                tmpArg.Name = tmpArg.Value = ProtoCore.DSASM.Constants.kTempArg;
                tmpArg.datatype = core.TypeSystem.BuildTypeObject(PrimitiveType.kTypeVar, false);
                setter.FormalArguments.Add(tmpArg);

                return setter;
            }
            else
            {
                FunctionCallNode getter = new FunctionCallNode();
                getter.Function = inode;
                return getter;
            }
        }
开发者ID:santom,项目名称:designscript,代码行数:21,代码来源:AssociativeCodeGen.cs


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