當前位置: 首頁>>代碼示例>>C#>>正文


C# AssociativeAST.IdentifierNode類代碼示例

本文整理匯總了C#中ProtoCore.AST.AssociativeAST.IdentifierNode的典型用法代碼示例。如果您正苦於以下問題:C# IdentifierNode類的具體用法?C# IdentifierNode怎麽用?C# IdentifierNode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IdentifierNode類屬於ProtoCore.AST.AssociativeAST命名空間,在下文中一共展示了IdentifierNode類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CreateAssignmentNode

        private static BinaryExpressionNode CreateAssignmentNode(AssociativeNode rhsNode)
        {

            IdentifierNode lhs = new IdentifierNode(string.Format("tVar_{0}", staticVariableIndex++));
            BinaryExpressionNode bNode = new BinaryExpressionNode(lhs, rhsNode, ProtoCore.DSASM.Operator.assign);
            return bNode;
        }
開發者ID:heegwon,項目名稱:Dynamo,代碼行數:7,代碼來源:ASTCompilerUtils.cs

示例2: BuildOutputAst

        public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAstNodes)
        {
            AssociativeNode rhs = null;

            if (IsPartiallyApplied)
            {
                var connectedInputs = new List<AssociativeNode>();
                var functionNode = new IdentifierNode(functionName);
                var paramNumNode = new IntNode(1);
                var positionNode = AstFactory.BuildExprList(connectedInputs);
                var arguments = AstFactory.BuildExprList(inputAstNodes);
                var inputParams = new List<AssociativeNode>
                {
                    functionNode,
                    paramNumNode,
                    positionNode,
                    arguments,
                    AstFactory.BuildBooleanNode(true)
                };

                rhs = AstFactory.BuildFunctionCall("_SingleFunctionObject", inputParams);
            }
            else
            {
                rhs = AstFactory.BuildFunctionCall(functionName, inputAstNodes);
            }

            return new[]
            {
               AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), rhs)
            };
        }
開發者ID:rafatahmed,項目名稱:Dynamo,代碼行數:32,代碼來源:String.cs

示例3: BuildAssocIdentifier

 public static ProtoCore.AST.AssociativeAST.IdentifierNode BuildAssocIdentifier(Core core, string name, ProtoCore.PrimitiveType type = ProtoCore.PrimitiveType.kTypeVar)
 {
     var ident = new ProtoCore.AST.AssociativeAST.IdentifierNode();
     ident.Name = ident.Value = name;
     ident.datatype = TypeSystem.BuildPrimitiveTypeObject(type, 0);
     return ident;
 }
開發者ID:RobertiF,項目名稱:Dynamo,代碼行數:7,代碼來源:CoreUtils.cs

示例4: TestMethodHasNullCheck

 public void TestMethodHasNullCheck()
 {
     AssociativeNode foo = new IdentifierNode("foo");
     Assert.Throws<ArgumentNullException>(() => AstFactory.BuildAssignment(foo, null));
     Assert.Throws<ArgumentNullException>(() => AstFactory.BuildAssignment(null, foo));
     Assert.Throws<ArgumentNullException>(() => AstFactory.BuildBinaryExpression(foo, null, ProtoCore.DSASM.Operator.assign));
     Assert.Throws<ArgumentNullException>(() => AstFactory.BuildBinaryExpression(null, foo, ProtoCore.DSASM.Operator.assign));
     Assert.Throws<ArgumentNullException>(() => AstFactory.BuildConditionalNode(null, foo, foo));
     Assert.Throws<ArgumentNullException>(() => AstFactory.BuildConditionalNode(foo, null, foo));
     Assert.Throws<ArgumentNullException>(() => AstFactory.BuildConditionalNode(foo, foo, null));
     List<AssociativeNode> nullList = null;
     List<AssociativeNode> fooList = new List<AssociativeNode>();
     Assert.Throws<ArgumentNullException>(() => AstFactory.BuildExprList(nullList));
     Assert.Throws<ArgumentNullException>(() => AstFactory.BuildFunctionCall(() => {}, null));
     string nullIdent = null;
     AssociativeNode nullNode = null;
     Assert.Throws<ArgumentNullException>(() => AstFactory.BuildFunctionObject(nullNode, 0, new List<int> {}, fooList));
     Assert.Throws<ArgumentNullException>(() => AstFactory.BuildFunctionObject(foo, 0, null, fooList));
     Assert.Throws<ArgumentNullException>(() => AstFactory.BuildFunctionObject(nullNode, 0, new List<int> {}, null));
     Assert.Throws<ArgumentException>(() => AstFactory.BuildFunctionObject(nullIdent, 0, new List<int> { } , fooList));
     Assert.Throws<ArgumentException>(() => AstFactory.BuildFunctionObject(string.Empty, 0, new List<int> { } , fooList));
     Assert.Throws<ArgumentException>(() => AstFactory.BuildIdentifier(null));
     Assert.Throws<ArgumentException>(() => AstFactory.BuildIdentifier(String.Empty));
     Assert.Throws<ArgumentNullException>(() => AstFactory.BuildStringNode(null));
     Assert.Throws<ArgumentException>(() => AstFactory.BuildParamNode(null));
     Assert.Throws<ArgumentException>(() => AstFactory.BuildParamNode(string.Empty));
     Assert.Throws<ArgumentNullException>(() => AstFactory.BuildReturnStatement(null));
     Assert.Throws<ArgumentNullException>(() => AstFactory.AddReplicationGuide(null, null, false));
 }
開發者ID:ankushraizada,項目名稱:Dynamo,代碼行數:29,代碼來源:AstFactoryTest.cs

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

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

示例7: BuildOutputAst

        public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAstNodes)
        {
            var lhs = GetAstIdentifierForOutputIndex(0);
            AssociativeNode rhs;

            if (IsPartiallyApplied)
            {
                var connectedInputs = Enumerable.Range(0, InPorts.Count)
                                            .Where(index=>InPorts[index].IsConnected)
                                            .Select(x => new IntNode(x) as AssociativeNode)
                                            .ToList();
                var functionNode = new IdentifierNode(Constants.kInlineConditionalMethodName);
                var paramNumNode = new IntNode(3);
                var positionNode = AstFactory.BuildExprList(connectedInputs);
                var arguments = AstFactory.BuildExprList(inputAstNodes);
                var inputParams = new List<AssociativeNode>
                {
                    functionNode,
                    paramNumNode,
                    positionNode,
                    arguments,
                    AstFactory.BuildBooleanNode(true)
                };

                rhs = AstFactory.BuildFunctionCall("__CreateFunctionObject", inputParams);
            }
            else
            {
                rhs = new InlineConditionalNode
                {
                    ConditionExpression = inputAstNodes[0],
                    TrueExpression = inputAstNodes[1],
                    FalseExpression = inputAstNodes[2]
                };
            }

            return new[]
            {
                AstFactory.BuildAssignment(lhs, rhs)
            };
        }
開發者ID:Conceptual-Design,項目名稱:Dynamo,代碼行數:41,代碼來源:If.cs

示例8: CreateArgs

        private static List<ProtoCore.AST.AssociativeAST.AssociativeNode> CreateArgs(string formatString, List<string> primitiveArgs, List<AssociativeNode> argNodes)
        {
            List<AssociativeNode> args = new List<AssociativeNode>();

            for (int i = 0; i < formatString.Length; i++)
            {
                // TODO: Add a switch-case to create primitive nodes depending on the format string
                if (formatString[i] == 'd')
                {
                    double value;
                    if (Double.TryParse(primitiveArgs[i], out value))
                    {
                        args.Add(new DoubleNode(value));
                    }
                }
                else if (formatString[i].Equals('i'))
                {
                    Int64 value;
                    if (Int64.TryParse(primitiveArgs[i], out value))
                    {
                        args.Add(new IntNode(value));
                    }
                }
                else if (formatString[i].Equals('b'))
                {
                    Boolean value;
                    if (Boolean.TryParse(primitiveArgs[i], out value))
                    {
                        args.Add(new BooleanNode(value));
                    }
                }
                else if (formatString[i].Equals('s'))
                {
                    IdentifierNode iNode = new IdentifierNode(primitiveArgs[i]);

                    args.Add(iNode);
                }
            }

            return args;
        }
開發者ID:heegwon,項目名稱:Dynamo,代碼行數:41,代碼來源:ASTCompilerUtils.cs

示例9: Variable

        public Variable(IdentifierNode identNode)
        {
            if (identNode == null)
                throw new ArgumentNullException();

            Name = identNode.ToString();
            Row = identNode.line;
            StartColumn = identNode.col;
        }
開發者ID:rafatahmed,項目名稱:Dynamo,代碼行數:9,代碼來源:CodeBlockNode.cs

示例10: definitions

        /*
            1 Copy user-defined function definitions (excluding constructors) into a temp

            2 Modify its signature to include an additional this pointer as the first argument.
              The 'this' argument should take the type of the current class being traversed and be the first argument in the function.
              The function name must be name mangled in order to stay unique

            3 Append this temp to the current vtable
        */
        private void InsertThisPointerArg(ThisPointerProcOverload procOverload)
        {
            // Modify its signature to include an additional this pointer as the first argument.
            // The 'this' argument should take the type of the current class being traversed and be the first argument in the function.
            // The function name must be name mangled in order to stay unique

            ProtoCore.AST.AssociativeAST.FunctionDefinitionNode procNode = procOverload.procNode;

            string className = compileStateTracker.ClassTable.ClassNodes[procOverload.classIndex].name;
            string thisPtrArgName = ProtoCore.DSASM.Constants.kThisPointerArgName;

            ProtoCore.AST.AssociativeAST.IdentifierNode ident = new ProtoCore.AST.AssociativeAST.IdentifierNode();
            ident.Name = ident.Value = thisPtrArgName;

            VarDeclNode thisPtrArg = new ProtoCore.AST.AssociativeAST.VarDeclNode()
            {
                memregion = ProtoCore.DSASM.MemoryRegion.kMemStack,
                access = ProtoCore.DSASM.AccessSpecifier.kPublic,
                NameNode = ident,
                ArgumentType = new ProtoCore.Type { Name = className, UID = procOverload.classIndex, IsIndexable = false, rank = 0 }
            };

            procNode.Singnature.Arguments.Insert(0, thisPtrArg);

            ProtoCore.Type type = new ProtoCore.Type();
        }
開發者ID:samuto,項目名稱:designscript,代碼行數:35,代碼來源:CodeGen.cs

示例11: EmitReplicationGuideForIdentifier

        private bool EmitReplicationGuideForIdentifier(IdentifierNode t)
        {
            bool isReplicationGuideEmitted = false;
            if (emitReplicationGuide)
            {
                int replicationGuides = 0;
                if (null != t.ReplicationGuides)
                {
                    isReplicationGuideEmitted = true;

                    replicationGuides = t.ReplicationGuides.Count;
                    for (int n = 0; n < replicationGuides; ++n)
                    {
                        ProtoCore.DSASM.StackValue opguide = new ProtoCore.DSASM.StackValue();
                        Debug.Assert(t.ReplicationGuides[n] is IdentifierNode);
                        IdentifierNode nodeGuide = t.ReplicationGuides[n] as IdentifierNode;

                        EmitInstrConsole(ProtoCore.DSASM.kw.push, nodeGuide.Value);
                        opguide.optype = ProtoCore.DSASM.AddressType.Int;
                        opguide.opdata = System.Convert.ToInt64(nodeGuide.Value);
                        EmitPush(opguide);
                    }
                }
            }

            return isReplicationGuideEmitted;
        }
開發者ID:samuto,項目名稱:designscript,代碼行數:27,代碼來源:CodeGen.cs

示例12: EmitInlineConditionalNode

        private void EmitInlineConditionalNode(AssociativeNode node, ref ProtoCore.Type inferedType, ProtoCore.AssociativeGraph.GraphNode graphNode = null, ProtoCore.DSASM.AssociativeSubCompilePass subPass = ProtoCore.DSASM.AssociativeSubCompilePass.kNone, ProtoCore.AST.AssociativeAST.BinaryExpressionNode parentNode = null)
        {
            if (subPass == AssociativeSubCompilePass.kUnboundIdentifier)
            {
                return;
            }

            bool isInlineConditionalFlag = false;
            int startPC = pc;
            bool isReturn = false;
            if (graphNode != null)
            {
                isInlineConditionalFlag = graphNode.isInlineConditional;
                graphNode.isInlineConditional = true;
                startPC = graphNode.updateBlock.startpc;
                isReturn = graphNode.isReturn;
            }

            InlineConditionalNode inlineConditionalNode = node as InlineConditionalNode;
            // TODO: Jun, this 'if' condition needs to be removed as it was the old implementation - pratapa
            if (inlineConditionalNode.IsAutoGenerated)
            {
                // Normal inline conditional

                IfStatementNode ifNode = new IfStatementNode();
                ifNode.ifExprNode = inlineConditionalNode.ConditionExpression;
                List<AssociativeNode> ifBody = new List<AssociativeNode>();
                List<AssociativeNode> elseBody = new List<AssociativeNode>();
                ifBody.Add(inlineConditionalNode.TrueExpression);
                elseBody.Add(inlineConditionalNode.FalseExpression);
                ifNode.IfBody = ifBody;
                ifNode.ElseBody = elseBody;

                EmitIfStatementNode(ifNode, ref inferedType, graphNode);
            }
            else
            {
                // CPS inline conditional

                FunctionCallNode inlineCall = new FunctionCallNode();
                IdentifierNode identNode = new IdentifierNode();
                identNode.Name = ProtoCore.DSASM.Constants.kInlineConditionalMethodName;
                inlineCall.Function = identNode;

                DebugProperties.BreakpointOptions oldOptions = compileStateTracker.DebugProps.breakOptions;
                DebugProperties.BreakpointOptions newOptions = oldOptions;
                newOptions |= DebugProperties.BreakpointOptions.EmitInlineConditionalBreakpoint;
                compileStateTracker.DebugProps.breakOptions = newOptions;

                compileStateTracker.DebugProps.highlightRange = new ProtoCore.CodeModel.CodeRange
                {
                    StartInclusive = new ProtoCore.CodeModel.CodePoint
                    {
                        LineNo = parentNode.line,
                        CharNo = parentNode.col
                    },

                    EndExclusive = new ProtoCore.CodeModel.CodePoint
                    {
                        LineNo = parentNode.endLine,
                        CharNo = parentNode.endCol
                    }
                };

                // True condition language block
                BinaryExpressionNode bExprTrue = new BinaryExpressionNode();
                bExprTrue.LeftNode = nodeBuilder.BuildReturn();
                bExprTrue.Optr = Operator.assign;
                bExprTrue.RightNode = inlineConditionalNode.TrueExpression;

                LanguageBlockNode langblockT = new LanguageBlockNode();
                int trueBlockId = ProtoCore.DSASM.Constants.kInvalidIndex;
                langblockT.codeblock.language = ProtoCore.Language.kAssociative;
                langblockT.codeblock.fingerprint = "";
                langblockT.codeblock.version = "";
                compileStateTracker.AssocNode = bExprTrue;
                EmitDynamicLanguageBlockNode(langblockT, bExprTrue, ref inferedType, ref trueBlockId, graphNode, AssociativeSubCompilePass.kNone);
                compileStateTracker.AssocNode = null;
                ProtoCore.AST.AssociativeAST.DynamicBlockNode dynBlockT = new ProtoCore.AST.AssociativeAST.DynamicBlockNode(trueBlockId);

                // False condition language block
                BinaryExpressionNode bExprFalse = new BinaryExpressionNode();
                bExprFalse.LeftNode = nodeBuilder.BuildReturn();
                bExprFalse.Optr = Operator.assign;
                bExprFalse.RightNode = inlineConditionalNode.FalseExpression;

                LanguageBlockNode langblockF = new LanguageBlockNode();
                int falseBlockId = ProtoCore.DSASM.Constants.kInvalidIndex;
                langblockF.codeblock.language = ProtoCore.Language.kAssociative;
                langblockF.codeblock.fingerprint = "";
                langblockF.codeblock.version = "";
                compileStateTracker.AssocNode = bExprFalse;
                EmitDynamicLanguageBlockNode(langblockF, bExprFalse, ref inferedType, ref falseBlockId, graphNode, AssociativeSubCompilePass.kNone);
                compileStateTracker.AssocNode = null;
                ProtoCore.AST.AssociativeAST.DynamicBlockNode dynBlockF = new ProtoCore.AST.AssociativeAST.DynamicBlockNode(falseBlockId);

                compileStateTracker.DebugProps.breakOptions = oldOptions;
                compileStateTracker.DebugProps.highlightRange = new ProtoCore.CodeModel.CodeRange
                {
                    StartInclusive = new ProtoCore.CodeModel.CodePoint
//.........這裏部分代碼省略.........
開發者ID:samuto,項目名稱:designscript,代碼行數:101,代碼來源:CodeGen.cs

示例13: GetFunctionApplication

        protected override AssociativeNode GetFunctionApplication(NodeModel model, List<AssociativeNode> inputAstNodes)
        {
            AssociativeNode rhs;

            string function = Definition.Name;

            switch (Definition.Type)
            {
                case FunctionType.Constructor:
                case FunctionType.StaticMethod:
                    if (model.IsPartiallyApplied)
                    {
                        var functionNode = new IdentifierListNode
                        {
                            LeftNode = new IdentifierNode(Definition.ClassName),
                            RightNode = new IdentifierNode(Definition.Name)
                        };
                        rhs = CreateFunctionObject(model, functionNode, inputAstNodes);
                    }
                    else
                    {
                        model.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 (model.IsPartiallyApplied)
                    {
                        var functionNode = new IdentifierListNode
                        {
                            LeftNode = new IdentifierNode(Definition.ClassName),
                            RightNode = new IdentifierNode(Definition.Name)
                        };
                        rhs = CreateFunctionObject(model, 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 (model.IsPartiallyApplied)
                    {
                        var functionNode = new IdentifierListNode
                        {
                            LeftNode = new IdentifierNode(Definition.ClassName),
                            RightNode = new IdentifierNode(Definition.Name)
                        };
                        rhs = CreateFunctionObject(model, functionNode, inputAstNodes);
                    }
                    else
                    {
                        rhs = new NullNode();
                        model.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:khoaho,項目名稱:Dynamo,代碼行數:101,代碼來源:DSFunction.cs

示例14: ParseUserCodeCore

        private static void ParseUserCodeCore(Core core, string expression, out List<AssociativeNode> astNodes, out List<AssociativeNode> commentNodes)
        {
            astNodes = new List<AssociativeNode>();

            core.ResetForPrecompilation();
            core.IsParsingCodeBlockNode = true;
            core.ParsingMode = ParseMode.AllowNonAssignment;

            ParseResult parseResult = ParserUtils.ParseWithCore(expression, core);

            commentNodes = ParserUtils.GetAstNodes(parseResult.CommentBlockNode);
            var nodes = ParserUtils.GetAstNodes(parseResult.CodeBlockNode);
            Validity.Assert(nodes != null);

            int index = 0;
            int typedIdentIndex = 0;
            foreach (var node in nodes)
            {
                var n = node as AssociativeNode;
                Validity.Assert(n != null);

                // Append the temporaries only if it is not a function def or class decl
                bool isFunctionOrClassDef = n is FunctionDefinitionNode || n is ClassDeclNode;

                // Handle non Binary expression nodes separately
                if (n is ModifierStackNode)
                {
                    core.BuildStatus.LogSemanticError(Resources.ModifierBlockNotSupported);
                }
                else if (n is ImportNode)
                {
                    core.BuildStatus.LogSemanticError(Resources.ImportStatementNotSupported);
                }
                else if (isFunctionOrClassDef)
                {
                    // Add node as it is
                    astNodes.Add(node);
                }
                else
                {
                    // Handle temporary naming for temporary Binary exp. nodes and non-assignment nodes
                    var ben = node as BinaryExpressionNode;
                    if (ben != null && ben.Optr == Operator.assign)
                    {
                        var mNode = ben.RightNode as ModifierStackNode;
                        if (mNode != null)
                        {
                            core.BuildStatus.LogSemanticError(Resources.ModifierBlockNotSupported);
                        }
                        var lNode = ben.LeftNode as IdentifierNode;
                        if (lNode != null && lNode.Value == Constants.kTempProcLeftVar)
                        {
                            string name = Constants.kTempVarForNonAssignment + index;
                            var newNode = new BinaryExpressionNode(new IdentifierNode(name), ben.RightNode);
                            astNodes.Add(newNode);
                            index++;
                        }
                        else
                        {
                            // Add node as it is
                            astNodes.Add(node);
                            index++;
                        }
                    }
                    else
                    {
                        if (node is TypedIdentifierNode)
                        {
                            // e.g. a : int = %tTypedIdent_<Index>;
                            var ident = new IdentifierNode(Constants.kTempVarForTypedIdentifier + typedIdentIndex);
                            NodeUtils.CopyNodeLocation(ident, node);
                            var typedNode = new BinaryExpressionNode(node as TypedIdentifierNode, ident, Operator.assign);
                            NodeUtils.CopyNodeLocation(typedNode, node);
                            astNodes.Add(typedNode);
                            typedIdentIndex++;
                        }
                        else
                        {
                            string name = Constants.kTempVarForNonAssignment + index;
                            var newNode = new BinaryExpressionNode(new IdentifierNode(name), n);
                            astNodes.Add(newNode);
                            index++;
                        }
                        
                    }
                }
            }
        }
開發者ID:limrzx,項目名稱:Dynamo,代碼行數:88,代碼來源:CompilerUtils.cs

示例15: EmitConstructorDefinitionNode

        private void EmitConstructorDefinitionNode(AssociativeNode node, ref ProtoCore.Type inferedType, ProtoCore.DSASM.AssociativeSubCompilePass subPass = ProtoCore.DSASM.AssociativeSubCompilePass.kNone)
        {
            ConstructorDefinitionNode funcDef = node as ConstructorDefinitionNode;
            ProtoCore.DSASM.CodeBlockType originalBlockType = codeBlock.blockType;
            codeBlock.blockType = ProtoCore.DSASM.CodeBlockType.kFunction;

            if (IsParsingMemberFunctionSig())
            {
                Debug.Assert(null == localProcedure);
                localProcedure = new ProtoCore.DSASM.ProcedureNode();

                localProcedure.name = funcDef.Name;
                localProcedure.pc = ProtoCore.DSASM.Constants.kInvalidIndex;
                localProcedure.localCount = 0;// Defer till all locals are allocated
                localProcedure.returntype.UID = core.TypeSystem.GetType(funcDef.ReturnType.Name);
                if (localProcedure.returntype.UID == ProtoCore.DSASM.Constants.kInvalidIndex)
                    localProcedure.returntype.UID = (int)PrimitiveType.kTypeVar;
                localProcedure.returntype.Name = core.TypeSystem.GetType(localProcedure.returntype.UID);
                localProcedure.returntype.IsIndexable = false;
                localProcedure.isConstructor = true;
                localProcedure.runtimeIndex = 0;

                Debug.Assert(ProtoCore.DSASM.Constants.kInvalidIndex != globalClassIndex, "A constructor node must be associated with class");
                localProcedure.localCount = 0;

                int peekFunctionindex = core.ClassTable.ClassNodes[globalClassIndex].vtable.procList.Count;

                if (!funcDef.IsExternLib)
                    CodeRangeTable.AddClassBlockFunctionEntry(globalClassIndex,
                        peekFunctionindex,
                        funcDef.FunctionBody.line,
                        funcDef.FunctionBody.col,
                        funcDef.FunctionBody.endLine,
                        funcDef.FunctionBody.endCol,
                        core.CurrentDSFileName);

                // Append arg symbols
                List<KeyValuePair<string, ProtoCore.Type>> argsToBeAllocated = new List<KeyValuePair<string, ProtoCore.Type>>();
                if (null != funcDef.Signature)
                {
                    int argNumber = 0;
                    foreach (VarDeclNode argNode in funcDef.Signature.Arguments)
                    {
                        ++argNumber;

                        IdentifierNode paramNode = null;
                        bool aIsDefault = false;
                        ProtoCore.AST.Node aDefaultExpression = null;
                        if (argNode.NameNode is IdentifierNode)
                        {
                            paramNode = argNode.NameNode as IdentifierNode;
                        }
                        else if (argNode.NameNode is BinaryExpressionNode)
                        {
                            BinaryExpressionNode bNode = argNode.NameNode as BinaryExpressionNode;
                            paramNode = bNode.LeftNode as IdentifierNode;
                            aIsDefault = true;
                            aDefaultExpression = bNode;
                            //buildStatus.LogSemanticError("Default parameters are not supported");
                            //throw new BuildHaltException();
                        }
                        else
                        {
                            Debug.Assert(false, "Check generated AST");
                        }

                        ProtoCore.Type argType = new ProtoCore.Type();
                        argType.UID = core.TypeSystem.GetType(argNode.ArgumentType.Name);
                        if (argType.UID == ProtoCore.DSASM.Constants.kInvalidIndex)
                            argType.UID = (int)PrimitiveType.kTypeVar;
                        argType.Name = core.TypeSystem.GetType(argType.UID);
                        argType.IsIndexable = argNode.ArgumentType.IsIndexable;
                        argType.rank = argNode.ArgumentType.rank;

                        argsToBeAllocated.Add(new KeyValuePair<string, ProtoCore.Type>(paramNode.Value, argType));
                        localProcedure.argTypeList.Add(argType);
                        ProtoCore.DSASM.ArgumentInfo argInfo = new ProtoCore.DSASM.ArgumentInfo { isDefault = aIsDefault, defaultExpression = aDefaultExpression, Name = paramNode.Name };
                        localProcedure.argInfoList.Add(argInfo);
                    }
                }

                int findex = core.ClassTable.ClassNodes[globalClassIndex].vtable.Append(localProcedure);

                // Comment Jun: Catch this assert given the condition as this type of mismatch should never occur
                if (ProtoCore.DSASM.Constants.kInvalidIndex != findex)
                {
                    Debug.Assert(peekFunctionindex == localProcedure.procId);
                    argsToBeAllocated.ForEach(arg =>
                    {
                        int symbolIndex = AllocateArg(arg.Key, findex, arg.Value);
                        if (ProtoCore.DSASM.Constants.kInvalidIndex == symbolIndex)
                        {
                            throw new BuildHaltException();
                        }
                    });
                }
            }
            else if (IsParsingMemberFunctionBody())
            {
                // Build arglist for comparison
//.........這裏部分代碼省略.........
開發者ID:santom,項目名稱:designscript,代碼行數:101,代碼來源:AssociativeCodeGen.cs


注:本文中的ProtoCore.AST.AssociativeAST.IdentifierNode類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。