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


C# AssociativeAST.VarDeclNode类代码示例

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


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

示例1: ArgumentSignatureNode

        public ArgumentSignatureNode(ArgumentSignatureNode rhs)
            : base(rhs)
        {
            Arguments = new List<VarDeclNode>();

            foreach (VarDeclNode aNode in rhs.Arguments)
            {
                VarDeclNode newNode = new VarDeclNode(aNode);
                Arguments.Add(newNode);
            }
        }
开发者ID:Benglin,项目名称:designscript,代码行数:11,代码来源:AssociativeAST.cs

示例2: GenerateBuiltInMethodSignatureNode

    private static ProtoCore.AST.AssociativeAST.FunctionDefinitionNode GenerateBuiltInMethodSignatureNode(ProtoCore.Lang.BuiltInMethods.BuiltInMethod method)
    {
        ProtoCore.AST.AssociativeAST.FunctionDefinitionNode fDef = new ProtoCore.AST.AssociativeAST.FunctionDefinitionNode();
        fDef.Name = ProtoCore.Lang.BuiltInMethods.GetMethodName(method.ID);
        fDef.ReturnType = method.ReturnType;
        fDef.IsExternLib = true;
        fDef.IsBuiltIn = true;
        fDef.BuiltInMethodId = method.ID;
        fDef.Signature = new ProtoCore.AST.AssociativeAST.ArgumentSignatureNode();
        fDef.MethodAttributes = method.MethodAttributes;

        foreach (KeyValuePair<string, ProtoCore.Type> param in method.Parameters)
        {
            ProtoCore.AST.AssociativeAST.VarDeclNode arg = new ProtoCore.AST.AssociativeAST.VarDeclNode();
            arg.NameNode = new ProtoCore.AST.AssociativeAST.IdentifierNode { Name = param.Key, Value = param.Key };
            arg.ArgumentType = param.Value;
            fDef.Signature.AddArgument(arg);
        }

        return fDef;
    }
开发者ID:RobertiF,项目名称:Dynamo,代码行数:21,代码来源:CoreUtils.cs

示例3: BuildArgumentInfoFromVarDeclNode

        private ArgumentInfo BuildArgumentInfoFromVarDeclNode(VarDeclNode argNode)
        {
            var argumentName = String.Empty;
            ProtoCore.AST.Node defaultExpression = null;
            if (argNode.NameNode is IdentifierNode)
            {
                argumentName = (argNode.NameNode as IdentifierNode).Value;
            }
            else if (argNode.NameNode is BinaryExpressionNode)
            {
                var bNode = argNode.NameNode as BinaryExpressionNode;
                defaultExpression = bNode;
                argumentName = (bNode.LeftNode as IdentifierNode).Value;
            }
            else
            {
                Validity.Assert(false, "Check generated AST");
            }

            var argInfo = new ProtoCore.DSASM.ArgumentInfo 
            { 
                Name = argumentName, 
                DefaultExpression = defaultExpression,
                Attributes = argNode.ExternalAttributes
            };
            return argInfo;
        }
开发者ID:AutodeskFractal,项目名称:Dynamo,代码行数:27,代码来源:CodeGen.cs

示例4: EmitClassDeclNode


//.........这里部分代码省略.........
                EmitMemberVariables(classDecl, graphNode);
            }
            else if (ProtoCore.CompilerDefinitions.Associative.CompilePass.kClassMemFuncSig == compilePass)
            {
                // Class member variable pass
                // Populating each class entry vtables with their respective
                // member variables signatures
                globalClassIndex = core.ClassTable.GetClassId(classDecl.ClassName);

                List<AssociativeNode> thisPtrOverloadList = new List<AssociativeNode>();
                foreach (AssociativeNode funcdecl in classDecl.Procedures)
                {
                    DfsTraverse(funcdecl, ref inferedType);

                    var funcDef = funcdecl as FunctionDefinitionNode;
                    if (funcDef == null || funcDef.IsStatic || funcDef.Name == ProtoCore.DSDefinitions.Keyword.Dispose)
                        continue;

                    bool isGetterSetter = CoreUtils.IsGetterSetter(funcDef.Name);

                    var thisPtrArgName = Constants.kThisPointerArgName;
                    if (!isGetterSetter)
                    {
                        var classsShortName = classDecl.ClassName.Split('.').Last();
                        var typeDepName = classsShortName.ToLower();
                        if (typeDepName != classsShortName && funcDef.Signature.Arguments.All(a => a.NameNode.Name != typeDepName))
                            thisPtrArgName = typeDepName;
                    }

                    // This is a function, create its parameterized this pointer overload
                    ThisPointerProcOverload thisProc = new ThisPointerProcOverload();
                    thisProc.classIndex = globalClassIndex;
                    thisProc.procNode = new FunctionDefinitionNode(funcDef);
                    var thisPtrArg = new VarDeclNode()
                    {
                        Access = ProtoCore.CompilerDefinitions.AccessModifier.kPublic,
                        NameNode = AstFactory.BuildIdentifier(thisPtrArgName),
                        ArgumentType = new ProtoCore.Type { Name = classDecl.ClassName, UID = globalClassIndex, rank = 0 }
                    };
                    thisProc.procNode.Signature.Arguments.Insert(0, thisPtrArg);
                    thisProc.procNode.IsAutoGeneratedThisProc = true;

                    if (CoreUtils.IsGetterSetter(funcDef.Name))
                    {
                        InsertThisPointerAtBody(thisProc);
                    }
                    else
                    {
                        // Generate a static function for member function f():
                        //     satic def f(a: A)
                        //     { 
                        //        return = a.f()
                        //     }
                        thisProc.procNode.IsStatic = true;
                        BuildThisFunctionBody(thisProc);
                    }

                    thisPtrOverloadList.Add(thisProc.procNode);
                }

                foreach (var overloadFunc in thisPtrOverloadList)
                {
                    // Emit the newly defined overloads
                    DfsTraverse(overloadFunc, ref inferedType);
                }
开发者ID:AutodeskFractal,项目名称:Dynamo,代码行数:66,代码来源:CodeGen.cs

示例5: EmitSetterFunction

        private FunctionDefinitionNode EmitSetterFunction(ProtoCore.DSASM.SymbolNode prop, ProtoCore.Type argType)
        {
            var argument = new ProtoCore.AST.AssociativeAST.VarDeclNode()
            {
                Access = ProtoCore.CompilerDefinitions.AccessModifier.kPublic,
                NameNode =AstFactory.BuildIdentifier(Constants.kTempArg),
                ArgumentType = argType
            };
            var argumentSingature = new ArgumentSignatureNode();
            argumentSingature.AddArgument(argument);

            FunctionDefinitionNode setter = new FunctionDefinitionNode
            {
                Name = ProtoCore.DSASM.Constants.kSetterPrefix + prop.name,
                Signature = argumentSingature,
                Pattern = null,
                ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeNull, 0),
                FunctionBody = new CodeBlockNode(),
                IsExternLib = false,
                IsDNI = false,
                ExternLibName = null,
                Access = prop.access,
                IsStatic = prop.isStatic,
                IsAutoGenerated = true
            };

            // property = %tmpArg
            var propIdent = new TypedIdentifierNode();
            propIdent.Name = propIdent.Value = prop.name;
            propIdent.datatype = prop.datatype;

            var tmpArg =AstFactory.BuildIdentifier(Constants.kTempArg);
            var assignment = AstFactory.BuildBinaryExpression(propIdent, tmpArg, Operator.assign);
            setter.FunctionBody.Body.Add(assignment);

            // return = null;
            var returnNull = AstFactory.BuildReturnStatement(new NullNode()); 
            setter.FunctionBody.Body.Add(returnNull);

            return setter;
        }
开发者ID:AutodeskFractal,项目名称:Dynamo,代码行数:41,代码来源:CodeGen.cs

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

示例7: BuildArgumentTypeFromVarDeclNode

        private ProtoCore.Type BuildArgumentTypeFromVarDeclNode(VarDeclNode argNode)
        {
            Validity.Assert(argNode != null);
            if (argNode == null)
            {
                return new ProtoCore.Type();
            }

            int uid = compileStateTracker.TypeSystem.GetType(argNode.ArgumentType.Name);
            if (uid == (int)PrimitiveType.kInvalidType && !compileStateTracker.IsTempVar(argNode.NameNode.Name))
            {
                string message = String.Format(ProtoCore.BuildData.WarningMessage.kArgumentTypeUndefined, argNode.ArgumentType.Name, argNode.NameNode.Name);
                buildStatus.LogWarning(ProtoCore.BuildData.WarningID.kTypeUndefined, message, compileStateTracker.CurrentDSFileName, argNode.line, argNode.col);
            }

            bool isArray = argNode.ArgumentType.IsIndexable;
            int rank = argNode.ArgumentType.rank;

            return compileStateTracker.TypeSystem.BuildTypeObject(uid, isArray, rank);
        }
开发者ID:samuto,项目名称:designscript,代码行数:20,代码来源:CodeGen.cs

示例8: ParseArgumentDeclaration

        private ProtoCore.AST.AssociativeAST.VarDeclNode ParseArgumentDeclaration(string parameterName, Type parameterType)
        {
            ProtoCore.AST.AssociativeAST.VarDeclNode varDeclNode = new ProtoCore.AST.AssociativeAST.VarDeclNode();
            varDeclNode.memregion = ProtoCore.DSASM.MemoryRegion.kMemStack;
            varDeclNode.access = ProtoCore.Compiler.AccessSpecifier.kPublic;

            ProtoCore.AST.AssociativeAST.IdentifierNode identifierNode = new ProtoCore.AST.AssociativeAST.IdentifierNode
                                                                             {
                Value = parameterName,
                Name = parameterName,
                datatype = ProtoCore.TypeSystem.BuildPrimitiveTypeObject(ProtoCore.PrimitiveType.kTypeVar, 0)
            };
            //Lets emit native DS type object
            ProtoCore.Type argtype = CLRModuleType.GetProtoCoreType(parameterType, Module);

            varDeclNode.NameNode = identifierNode;
            varDeclNode.ArgumentType = argtype;
            return varDeclNode;
        }
开发者ID:whztt07,项目名称:Dynamo,代码行数:19,代码来源:CLRDLLModule.cs

示例9: BuildParamNode

 public static VarDeclNode BuildParamNode(string paramName)
 {
     VarDeclNode param = new VarDeclNode();
     param.NameNode = BuildIdentifier(paramName);
     param.ArgumentType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, false);
     return param;
 }
开发者ID:junmendoza,项目名称:designscript,代码行数:7,代码来源:AssociativeAST.cs

示例10: Associative_ArgDecl

	void Associative_ArgDecl(out ProtoCore.AST.AssociativeAST.AssociativeNode node, ProtoCore.CompilerDefinitions.AccessModifier access = ProtoCore.CompilerDefinitions.AccessModifier.Public) {
		ProtoCore.AST.AssociativeAST.IdentifierNode tNode = null; 
		ProtoCore.AST.AssociativeAST.VarDeclNode varDeclNode = new ProtoCore.AST.AssociativeAST.VarDeclNode(); 
		varDeclNode.Access = access;
		
		Expect(1);
		if (IsKeyWord(t.val, true))
		{
		   errors.SemErr(t.line, t.col, String.Format(Resources.keywordCantBeUsedAsIdentifier, t.val));
		}
		tNode = AstFactory.BuildIdentifier(t.val);
		NodeUtils.SetNodeLocation(tNode, t);
		varDeclNode.NameNode = tNode;
		NodeUtils.CopyNodeLocation(varDeclNode, tNode);
		
		ProtoCore.Type argtype = new ProtoCore.Type(); argtype.Name = "var"; argtype.rank = 0; argtype.UID = 0; 
		if (la.kind == 47) {
			Get();
			Expect(1);
			argtype.Name = t.val; 
			if (la.kind == 10) {
				Get();
				Expect(11);
				argtype.rank = 1; 
				if (la.kind == 10 || la.kind == 24) {
					if (la.kind == 24) {
						Get();
						Expect(10);
						Expect(11);
						argtype.rank = ProtoCore.DSASM.Constants.nDimensionArrayRank; 
					} else {
						while (la.kind == 10) {
							Get();
							Expect(11);
							argtype.rank++; 
						}
					}
				}
			}
		}
		varDeclNode.ArgumentType = argtype; 
		node = varDeclNode; 
	}
开发者ID:limrzx,项目名称:Dynamo,代码行数:43,代码来源:Parser.cs

示例11: Associative_vardecl

	void Associative_vardecl(out ProtoCore.AST.AssociativeAST.AssociativeNode node, ProtoCore.CompilerDefinitions.AccessModifier access = ProtoCore.CompilerDefinitions.AccessModifier.Public, bool isStatic = false, List<ProtoCore.AST.AssociativeAST.AssociativeNode> attrs = null) {
		ProtoCore.AST.AssociativeAST.IdentifierNode tNode = null; 
		ProtoCore.AST.AssociativeAST.VarDeclNode varDeclNode = new ProtoCore.AST.AssociativeAST.VarDeclNode(); 
		varDeclNode.Access = access;
		varDeclNode.IsStatic = isStatic;
		
		Expect(1);
		if (IsKeyWord(t.val, true))
		{
		   errors.SemErr(t.line, t.col, String.Format(Resources.keywordCantBeUsedAsIdentifier, t.val));
		}
		NodeUtils.SetNodeLocation(varDeclNode, t);
		tNode = AstFactory.BuildIdentifier(t.val);
		NodeUtils.SetNodeLocation(tNode, t);
		varDeclNode.NameNode = tNode;
		
		if (la.kind == 47) {
			Get();
			Expect(1);
			ProtoCore.Type argtype = new ProtoCore.Type(); argtype.Name = t.val; argtype.rank = 0; 
			if (la.kind == 10) {
				Get();
				Expect(11);
				argtype.rank = 1; 
				if (la.kind == 10 || la.kind == 24 || la.kind == 51) {
					if (la.kind == 24) {
						Get();
						Expect(10);
						Expect(11);
						argtype.rank = ProtoCore.DSASM.Constants.nDimensionArrayRank; 
					} else {
						while (la.kind == 10) {
							Get();
							Expect(11);
							argtype.rank++; 
						}
					}
				}
			}
			string oldName = tNode.Name;
			string oldValue = tNode.Value;
			
			// Here since the variable has an explicitly specified type 
			// the "IdentifierNode" should really be "TypedIdentifierNode"
			// (which is used to indicate the identifier that has explicit 
			// type specified).
			tNode = new ProtoCore.AST.AssociativeAST.TypedIdentifierNode()
			{
			   Name = oldName,
			   Value = oldValue
			};
			
			argtype.UID = core.TypeSystem.GetType(argtype.Name);
			tNode.datatype = argtype;
			varDeclNode.NameNode = tNode;
			varDeclNode.ArgumentType = argtype;
			
		}
		if (la.kind == 51) {
			Get();
			ProtoCore.AST.AssociativeAST.AssociativeNode rhsNode; 
			Associative_Expression(out rhsNode);
			ProtoCore.AST.AssociativeAST.BinaryExpressionNode bNode = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode();
			NodeUtils.CopyNodeLocation(bNode, varDeclNode);
			bNode.LeftNode = tNode;
			bNode.RightNode = rhsNode;
			bNode.Optr = Operator.assign;
			varDeclNode.NameNode = bNode;       
			
		}
		node = varDeclNode; 
		//if(!isGlobalScope) {
		//    localVarCount++;
		//}
		
	}
开发者ID:limrzx,项目名称:Dynamo,代码行数:76,代码来源:Parser.cs

示例12: Associative_ArgDecl

        void Associative_ArgDecl(out ProtoCore.AST.AssociativeAST.AssociativeNode node, ProtoCore.DSASM.AccessSpecifier access = ProtoCore.DSASM.AccessSpecifier.kPublic)
        {
            ProtoCore.AST.AssociativeAST.IdentifierNode tNode = null;
            ProtoCore.AST.AssociativeAST.VarDeclNode varDeclNode = new ProtoCore.AST.AssociativeAST.VarDeclNode();
            varDeclNode.memregion = ProtoCore.DSASM.MemoryRegion.kMemStack;
            varDeclNode.access = access;

            Expect(1);
            if (IsKeyWord(t.val, true))
            {
               errors.SemErr(t.line, t.col, String.Format("\"{0}\" is a keyword, identifier expected", t.val));
            }
            tNode = ProtoCore.Utils.CoreUtils.BuildAssocIdentifier(core, t.val);
            NodeUtils.SetNodeLocation(tNode, t);
            varDeclNode.NameNode = tNode;
            NodeUtils.CopyNodeLocation(varDeclNode, tNode);

            ProtoCore.Type argtype = new ProtoCore.Type(); argtype.Name = "var"; argtype.rank = 0; argtype.UID = 0;
            if (la.kind == 48) {
            Get();
            Expect(1);
            argtype.Name = t.val;
            if (la.kind == 7) {
                argtype.IsIndexable = true;
                Get();
                Expect(8);
                argtype.rank = 1;
                if (la.kind == 7 || la.kind == 21) {
                    if (la.kind == 21) {
                        Get();
                        Expect(7);
                        Expect(8);
                        argtype.rank = ProtoCore.DSASM.Constants.nDimensionArrayRank;
                    } else {
                        while (la.kind == 7) {
                            Get();
                            Expect(8);
                            argtype.rank++;
                        }
                    }
                }
            }
            }
            varDeclNode.ArgumentType = argtype;
            node = varDeclNode;
        }
开发者ID:Benglin,项目名称:designscript,代码行数:46,代码来源:Parser.cs

示例13: Associative_vardecl

        void Associative_vardecl(out ProtoCore.AST.AssociativeAST.AssociativeNode node, ProtoCore.DSASM.AccessSpecifier access = ProtoCore.DSASM.AccessSpecifier.kPublic, bool isStatic = false, List<ProtoCore.AST.AssociativeAST.AssociativeNode> attrs = null)
        {
            ProtoCore.AST.AssociativeAST.IdentifierNode tNode = null;
            ProtoCore.AST.AssociativeAST.VarDeclNode varDeclNode = new ProtoCore.AST.AssociativeAST.VarDeclNode();
            varDeclNode.memregion = ProtoCore.DSASM.MemoryRegion.kMemStack;
            varDeclNode.access = access;
            varDeclNode.Attributes = attrs;
            varDeclNode.IsStatic = isStatic;

            Expect(1);
            if (IsKeyWord(t.val, true))
            {
               errors.SemErr(t.line, t.col, String.Format("\"{0}\" is a keyword, identifier expected", t.val));
            }
            NodeUtils.SetNodeLocation(varDeclNode, t);
            tNode = ProtoCore.Utils.CoreUtils.BuildAssocIdentifier(core, t.val);
            NodeUtils.SetNodeLocation(tNode, t);
            varDeclNode.NameNode = tNode;

            if (la.kind == 48) {
            Get();
            Expect(1);
            ProtoCore.Type argtype = new ProtoCore.Type(); argtype.Name = t.val; argtype.rank = 0;
            if (la.kind == 7) {
                argtype.IsIndexable = true;
                Get();
                Expect(8);
                argtype.rank = 1;
                if (la.kind == 7 || la.kind == 21 || la.kind == 47) {
                    if (la.kind == 21) {
                        Get();
                        Expect(7);
                        Expect(8);
                        argtype.rank = ProtoCore.DSASM.Constants.nDimensionArrayRank;
                    } else {
                        while (la.kind == 7) {
                            Get();
                            Expect(8);
                            argtype.rank++;
                        }
                    }
                }
            }
            string oldName = tNode.Name;
            string oldValue = tNode.Value;

            // Here since the variable has an explicitly specified type
            // the "IdentifierNode" should really be "TypedIdentifierNode"
            // (which is used to indicate the identifier that has explicit
            // type specified).
            tNode = new ProtoCore.AST.AssociativeAST.TypedIdentifierNode()
            {
               Name = oldName,
               Value = oldValue
            };

            argtype.UID = core.TypeSystem.GetType(argtype.Name);
            tNode.datatype = argtype;
            varDeclNode.NameNode = tNode;
            varDeclNode.ArgumentType = argtype;

            }
            if (la.kind == 47) {
            Get();
            ProtoCore.AST.AssociativeAST.AssociativeNode rhsNode;
            Associative_Expression(out rhsNode);
            ProtoCore.AST.AssociativeAST.BinaryExpressionNode bNode = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode();
            NodeUtils.CopyNodeLocation(bNode, varDeclNode);
            bNode.LeftNode = tNode;
            bNode.RightNode = rhsNode;
            bNode.Optr = Operator.assign;
            varDeclNode.NameNode = bNode;

            }
            node = varDeclNode;
            //if(!isGlobalScope) {
            //    localVarCount++;
            //}
        }
开发者ID:Benglin,项目名称:designscript,代码行数:79,代码来源:Parser.cs

示例14: AddArgument

 public void AddArgument(VarDeclNode arg)
 {
     Arguments.Add(arg);
 }
开发者ID:qingemeng,项目名称:designscript,代码行数:4,代码来源:AssociativeAST.cs

示例15: VarDeclNode

 public VarDeclNode(VarDeclNode rhs)
     : base(rhs)
 {
     Attributes = new List<AssociativeNode>();
     foreach (AssociativeNode aNode in rhs.Attributes)
     {
         AssociativeNode newNode = NodeUtils.Clone(aNode);
         Attributes.Add(newNode);
     }
     memregion = rhs.memregion;
     ArgumentType = new ProtoCore.Type
     {
         UID = rhs.ArgumentType.UID,
         rank = rhs.ArgumentType.rank,
         IsIndexable = rhs.ArgumentType.IsIndexable,
         Name = rhs.ArgumentType.Name
     };
     NameNode = NodeUtils.Clone(rhs.NameNode);
     access = rhs.access;
     IsStatic = rhs.IsStatic;
 }
开发者ID:qingemeng,项目名称:designscript,代码行数:21,代码来源:AssociativeAST.cs


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