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


C# AssociativeAST.FunctionDefinitionNode类代码示例

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


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

示例1: SplitFunctionDefinitionNode

 private void SplitFunctionDefinitionNode(FunctionDefinitionNode node)
 {
     if (!node.IsExternLib)
     {
         node.FunctionBody.Body = SplitMulitpleAssignment(node.FunctionBody.Body);
     }
 }
开发者ID:sh4nnongoh,项目名称:Dynamo,代码行数:7,代码来源:CodeGen_SSA.cs

示例2: InsertBinaryOperationMethod

    private static void InsertBinaryOperationMethod(Core core, ProtoCore.AST.Node root, Operator op, PrimitiveType r, PrimitiveType op1, PrimitiveType op2, int retRank = 0, int op1rank = 0, int op2rank = 0)
    {
        ProtoCore.AST.AssociativeAST.FunctionDefinitionNode funcDefNode = new ProtoCore.AST.AssociativeAST.FunctionDefinitionNode();
        funcDefNode.access = ProtoCore.DSASM.AccessSpecifier.kPublic;
        funcDefNode.IsAssocOperator = true;
        funcDefNode.IsBuiltIn = true;
        funcDefNode.Name = Op.GetOpFunction(op);
        funcDefNode.ReturnType = new ProtoCore.Type() { Name = core.TypeSystem.GetType((int)r), UID = (int)r, rank = retRank};
        ProtoCore.AST.AssociativeAST.ArgumentSignatureNode args = new ProtoCore.AST.AssociativeAST.ArgumentSignatureNode();
        args.AddArgument(new ProtoCore.AST.AssociativeAST.VarDeclNode()
        {
            memregion = ProtoCore.DSASM.MemoryRegion.kMemStack,
            access = ProtoCore.DSASM.AccessSpecifier.kPublic,
            NameNode = BuildAssocIdentifier(core, ProtoCore.DSASM.Constants.kLHS),
            ArgumentType = new ProtoCore.Type { Name = core.TypeSystem.GetType((int)op1), UID = (int)op1, rank = op1rank}
        });
        args.AddArgument(new ProtoCore.AST.AssociativeAST.VarDeclNode()
        {
            memregion = ProtoCore.DSASM.MemoryRegion.kMemStack,
            access = ProtoCore.DSASM.AccessSpecifier.kPublic,
            NameNode = BuildAssocIdentifier(core, ProtoCore.DSASM.Constants.kRHS),
            ArgumentType = new ProtoCore.Type { Name = core.TypeSystem.GetType((int)op2), UID = (int)op2, rank = op2rank}
        });
        funcDefNode.Signature = args;

        ProtoCore.AST.AssociativeAST.CodeBlockNode body = new ProtoCore.AST.AssociativeAST.CodeBlockNode();
        ProtoCore.AST.AssociativeAST.IdentifierNode _return = BuildAssocIdentifier(core, ProtoCore.DSDefinitions.Keyword.Return, ProtoCore.PrimitiveType.kTypeReturn);

        ProtoCore.AST.AssociativeAST.IdentifierNode lhs = BuildAssocIdentifier(core, ProtoCore.DSASM.Constants.kLHS);
        ProtoCore.AST.AssociativeAST.IdentifierNode rhs = BuildAssocIdentifier(core, ProtoCore.DSASM.Constants.kRHS);
        body.Body.Add(new ProtoCore.AST.AssociativeAST.BinaryExpressionNode() { LeftNode = _return, Optr = ProtoCore.DSASM.Operator.assign, RightNode = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode() { LeftNode = lhs, RightNode = rhs, Optr = op } });
        funcDefNode.FunctionBody = body;
        (root as ProtoCore.AST.AssociativeAST.CodeBlockNode).Body.Add(funcDefNode);
    }
开发者ID:RobertiF,项目名称:Dynamo,代码行数:34,代码来源:CoreUtils.cs

示例3: InsertBinaryOperationMethod

        private static void InsertBinaryOperationMethod(Core core, CodeBlockNode root, Operator op, PrimitiveType r, PrimitiveType op1, PrimitiveType op2, int retRank = 0, int op1rank = 0, int op2rank = 0)
        {
            FunctionDefinitionNode funcDefNode = new FunctionDefinitionNode();
            funcDefNode.access = CompilerDefinitions.AccessModifier.kPublic;
            funcDefNode.IsAssocOperator = true;
            funcDefNode.IsBuiltIn = true;
            funcDefNode.Name = Op.GetOpFunction(op);
            funcDefNode.ReturnType = new Type() { Name = core.TypeSystem.GetType((int)r), UID = (int)r, rank = retRank };
            ArgumentSignatureNode args = new ArgumentSignatureNode();
            args.AddArgument(new VarDeclNode()
            {
                Access = CompilerDefinitions.AccessModifier.kPublic,
                NameNode = AstFactory.BuildIdentifier(DSASM.Constants.kLHS),
                ArgumentType = new Type { Name = core.TypeSystem.GetType((int)op1), UID = (int)op1, rank = op1rank }
            });
            args.AddArgument(new VarDeclNode()
            {
                Access = CompilerDefinitions.AccessModifier.kPublic,
                NameNode = AstFactory.BuildIdentifier(DSASM.Constants.kRHS),
                ArgumentType = new Type { Name = core.TypeSystem.GetType((int)op2), UID = (int)op2, rank = op2rank }
            });
            funcDefNode.Signature = args;

            CodeBlockNode body = new CodeBlockNode();

            var lhs = AstFactory.BuildIdentifier(DSASM.Constants.kLHS);
            var rhs = AstFactory.BuildIdentifier(DSASM.Constants.kRHS);
            var binaryExpr = AstFactory.BuildBinaryExpression(lhs, rhs, op);
            body.Body.Add(AstFactory.BuildReturnStatement(binaryExpr));

            funcDefNode.FunctionBody = body;
            root.Body.Add(funcDefNode);
        }
开发者ID:nmeek,项目名称:Dynamo,代码行数:33,代码来源:CoreUtils.cs

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

示例5: EmitSetterForMemVar

        private void EmitSetterForMemVar(ProtoCore.AST.AssociativeAST.ClassDeclNode cnode, ProtoCore.DSASM.SymbolNode memVar)
        {
            var argument = new ProtoCore.AST.AssociativeAST.VarDeclNode()
            {
                memregion = ProtoCore.DSASM.MemoryRegion.kMemStack,
                access = ProtoCore.DSASM.AccessSpecifier.kPublic,
                NameNode = new ProtoCore.AST.AssociativeAST.IdentifierNode()
                {
                    Value = ProtoCore.DSASM.Constants.kTempArg,
                    Name = ProtoCore.DSASM.Constants.kTempArg,
                    datatype = core.TypeSystem.BuildTypeObject(PrimitiveType.kTypeVar, false)
                },
                ArgumentType = new ProtoCore.Type
                {
                    Name = core.TypeSystem.GetType((int)PrimitiveType.kTypeVar),
                    UID = (int)PrimitiveType.kTypeVar
                }
            };

            var argumentSingature = new ArgumentSignatureNode();
            argumentSingature.AddArgument(argument);

            FunctionDefinitionNode setter = new FunctionDefinitionNode()
            {
                Name = ProtoCore.DSASM.Constants.kSetterPrefix + memVar.name,
                Singnature = argumentSingature,
                Pattern = null,
                ReturnType = core.TypeSystem.BuildTypeObject((int)PrimitiveType.kTypeNull, false),
                FunctionBody = new CodeBlockNode(),
                IsExternLib = false,
                IsDNI = false,
                ExternLibName = null,
                access = memVar.access,
                IsStatic = memVar.isStatic
            };

            // property = %tmpArg
            setter.FunctionBody.Body.Add(new BinaryExpressionNode()
            {
                // return = property;
                LeftNode = new IdentifierNode()
                {
                    Value = memVar.name,
                    Name = memVar.name,
                    datatype = core.TypeSystem.BuildTypeObject(PrimitiveType.kTypeVar, false)
                },
                Optr = ProtoCore.DSASM.Operator.assign,
                RightNode = new IdentifierNode()
                {
                    Value = ProtoCore.DSASM.Constants.kTempArg,
                    Name = ProtoCore.DSASM.Constants.kTempArg,
                    datatype = core.TypeSystem.BuildTypeObject(PrimitiveType.kTypeVar, false)
                }
            });

            // return = null;
            setter.FunctionBody.Body.Add(new BinaryExpressionNode()
            {
                LeftNode = new IdentifierNode()
                {
                    Value = ProtoCore.DSDefinitions.Kw.kw_return,
                    Name = ProtoCore.DSDefinitions.Kw.kw_return,
                    datatype = core.TypeSystem.BuildTypeObject(PrimitiveType.kTypeReturn, false)
                },
                Optr = ProtoCore.DSASM.Operator.assign,
                RightNode = new NullNode()
            });

            cnode.funclist.Add(setter);
        }
开发者ID:santom,项目名称:designscript,代码行数:70,代码来源:AssociativeCodeGen.cs

示例6: EmitGetterForMemVar

        private void EmitGetterForMemVar(ProtoCore.AST.AssociativeAST.ClassDeclNode cnode, ProtoCore.DSASM.SymbolNode memVar)
        {
            FunctionDefinitionNode getter = new FunctionDefinitionNode()
            {
                Name = ProtoCore.DSASM.Constants.kGetterPrefix + memVar.name,
                Singnature = new ArgumentSignatureNode(),
                Pattern = null,
                ReturnType = core.TypeSystem.BuildTypeObject((int)PrimitiveType.kTypeVar, false),
                FunctionBody = new CodeBlockNode(),
                IsExternLib = false,
                IsDNI = false,
                ExternLibName = null,
                access = memVar.access,
                IsStatic = memVar.isStatic
            };

            getter.FunctionBody.Body.Add(new BinaryExpressionNode()
            {
                // return = property;
                LeftNode = new IdentifierNode()
                {
                    Value = ProtoCore.DSDefinitions.Kw.kw_return,
                    Name = ProtoCore.DSDefinitions.Kw.kw_return,
                    datatype = core.TypeSystem.BuildTypeObject(PrimitiveType.kTypeReturn, false)
                },
                Optr = ProtoCore.DSASM.Operator.assign,
                RightNode = new IdentifierNode()
                {
                    Value = memVar.name,
                    Name = memVar.name,
                    datatype = core.TypeSystem.BuildTypeObject(PrimitiveType.kTypeVar, false)
                }
            });

            cnode.funclist.Add(getter);
        }
开发者ID:santom,项目名称:designscript,代码行数:36,代码来源:AssociativeCodeGen.cs

示例7: Initialize

 private void Initialize(FunctionDefinitionNode functionDefinitionNode)
 {
 }
开发者ID:samuto,项目名称:designscript,代码行数:3,代码来源:Statement.cs

示例8: EmitMemberVariables


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

                    if (!skipInitialization)
                    {
                        if (vardecl.IsStatic)
                            staticPropertyInitList.Add(bNode);
                        else
                            thisClass.DefaultArgExprList.Add(bNode);
                    }
                }
                else if (vardecl.NameNode is BinaryExpressionNode)
                {
                    BinaryExpressionNode bNode = vardecl.NameNode as BinaryExpressionNode;
                    varIdent = bNode.LeftNode as IdentifierNode;

                    bNode.endCol = vardecl.endCol;
                    bNode.endLine = vardecl.endLine;

                    if (vardecl.IsStatic)
                        staticPropertyInitList.Add(bNode);
                    else
                        thisClass.DefaultArgExprList.Add(bNode);
                }
                else
                {
                    Validity.Assert(false, "Check generated AST");
                }

                // It is possible that fail to allocate variable. In that 
                // case we should remove initializing expression from 
                // cnode's defaultArgExprList
                int symbolIndex = AllocateMemberVariable(thisClassIndex, thisClassIndex, varIdent.Value, vardecl.ArgumentType.rank, vardecl.Access, vardecl.IsStatic);
                if (symbolIndex == ProtoCore.DSASM.Constants.kInvalidIndex)
                {
                    Validity.Assert(thisClass.DefaultArgExprList.Count > 0);
                    thisClass.DefaultArgExprList.RemoveAt(thisClass.DefaultArgExprList.Count - 1);
                }
                // Only generate getter/setter for non-ffi class
                else if (!classDecl.IsExternLib)
                {
                    ProtoCore.DSASM.SymbolNode prop =
                        vardecl.IsStatic
                        ? core.CodeBlockList[0].symbolTable.symbolList[symbolIndex]
                        : core.ClassTable.ClassNodes[thisClassIndex].Symbols.symbolList[symbolIndex];
                    string typeName = vardecl.ArgumentType.Name;
                    if (String.IsNullOrEmpty(typeName))
                    {
                        prop.datatype = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank);
                    }
                    else
                    {
                        int type = core.TypeSystem.GetType(typeName);
                        if (type == (int)PrimitiveType.kInvalidType)
                        {
                            string message = String.Format(ProtoCore.Properties.Resources.kTypeUndefined, typeName);
                            core.BuildStatus.LogWarning(ProtoCore.BuildData.WarningID.kTypeUndefined, message, core.CurrentDSFileName, vardecl.line, vardecl.col, graphNode);
                            prop.datatype = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 0);
                        }
                        else
                        {
                            int rank = vardecl.ArgumentType.rank;
                            prop.datatype = core.TypeSystem.BuildTypeObject(type, rank);
                            if (type != (int)PrimitiveType.kTypeVar || prop.datatype.IsIndexable)
                            {
                                prop.staticType = prop.datatype;
                            }
                        }
                    }

                    EmitGetterForProperty(classDecl, prop);
                    EmitSetterForProperty(classDecl, prop);
                }
            }
            classOffset = 0;

            // Now we are going to create a static function __init_static_properties()
            // which will initialize all static properties. We will emit a 
            // call to this function after all classes have been compiled.
            if (staticPropertyInitList.Count > 0 && !classDecl.IsExternLib)
            {
                FunctionDefinitionNode initFunc = new FunctionDefinitionNode
                {
                    Name = ProtoCore.DSASM.Constants.kStaticPropertiesInitializer,
                    Signature = new ArgumentSignatureNode(),
                    Pattern = null,
                    ReturnType = new ProtoCore.Type { Name = core.TypeSystem.GetType((int)PrimitiveType.kTypeNull), UID = (int)PrimitiveType.kTypeNull },
                    FunctionBody = new CodeBlockNode(),
                    IsExternLib = false,
                    IsDNI = false,
                    ExternLibName = null,
                    Access = ProtoCore.CompilerDefinitions.AccessModifier.kPublic,
                    IsStatic = true
                };
                classDecl.Procedures.Add(initFunc);

                staticPropertyInitList.ForEach(bNode => initFunc.FunctionBody.Body.Add(bNode));
                initFunc.FunctionBody.Body.Add(AstFactory.BuildReturnStatement(new NullNode()));
            }

            unPopulatedClasses.Remove(thisClassIndex);
        }
开发者ID:AutodeskFractal,项目名称:Dynamo,代码行数:101,代码来源:CodeGen.cs

示例9: EmitClassDeclNode


//.........这里部分代码省略.........
                    if (tmpCNode.Base != Constants.kInvalidIndex)
                    {
                        baseClass = tmpCNode.Base;
                        while (ProtoCore.DSASM.Constants.kInvalidIndex != baseClass)
                        {
                            thisClass.CoerceTypes.Add(baseClass, (int)ProtoCore.DSASM.ProcedureDistance.CoerceBaseClass);
                            tmpCNode = core.ClassTable.ClassNodes[baseClass];

                            baseClass = ProtoCore.DSASM.Constants.kInvalidIndex;
                            if (tmpCNode.Base != Constants.kInvalidIndex)
                            {
                                baseClass = tmpCNode.Base;
                            }
                        }
                    }
                }
            }
            else if (ProtoCore.CompilerDefinitions.CompilePass.ClassMemVar == compilePass)
            {
                EmitMemberVariables(classDecl, graphNode);
            }
            else if (ProtoCore.CompilerDefinitions.CompilePass.ClassMemFuncSig == 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
                    var procNode = new FunctionDefinitionNode(funcDef);
                    var thisPtrArg = new VarDeclNode()
                    {
                        Access = ProtoCore.CompilerDefinitions.AccessModifier.Public,
                        NameNode = AstFactory.BuildIdentifier(thisPtrArgName),
                        ArgumentType = new ProtoCore.Type { Name = classDecl.ClassName, UID = globalClassIndex, rank = 0 }
                    };
                    procNode.Signature.Arguments.Insert(0, thisPtrArg);
                    procNode.IsAutoGeneratedThisProc = true;

                    if (CoreUtils.IsGetterSetter(funcDef.Name))
                    {
                        for (int n = 0; n < procNode.FunctionBody.Body.Count; ++n)
                        {
                            if (procNode.FunctionBody.Body[n] is BinaryExpressionNode)
                            {
                                var assocNode = procNode.FunctionBody.Body[n] as BinaryExpressionNode;
开发者ID:Conceptual-Design,项目名称:Dynamo,代码行数:67,代码来源:CodeGen.cs

示例10: ParseFieldAccessor

        private ProtoCore.AST.AssociativeAST.FunctionDefinitionNode ParseFieldAccessor(FieldInfo f)
        {
            if (null == f || SupressesImport(f))
                return null;

            ProtoCore.AST.AssociativeAST.FunctionDefinitionNode func = new ProtoCore.AST.AssociativeAST.FunctionDefinitionNode();
            func.Name = string.Format("%get_{0}", f.Name);
            func.Pattern = null;
            func.Signature = new ProtoCore.AST.AssociativeAST.ArgumentSignatureNode();
            func.ReturnType = CLRModuleType.GetProtoCoreType(f.FieldType, Module);
            func.FunctionBody = null;
            func.access = ProtoCore.Compiler.AccessSpecifier.kPublic;
            func.IsDNI = false;
            func.IsExternLib = true;
            func.ExternLibName = Module.Name;
            func.IsStatic = f.IsStatic;

            return func;
        }
开发者ID:whztt07,项目名称:Dynamo,代码行数:19,代码来源:CLRDLLModule.cs

示例11: VisitFunctionDefinitionNode

 public override AssociativeNode VisitFunctionDefinitionNode(FunctionDefinitionNode node)
 {
     // Not applying renaming to function defintion node, otherwise
     // function defintion would depend on variables that defined in
     // code block node, and there are implicit dependency between
     // code block node that uses this funciton and code block node
     // that defines this function.
     return node;
 }
开发者ID:sh4nnongoh,项目名称:Dynamo,代码行数:9,代码来源:CodeBlockNode.cs

示例12: FunctionDefinitionNode

        public FunctionDefinitionNode(FunctionDefinitionNode rhs)
        {
            this.Name = rhs.Name;
            if (null != rhs.FunctionBody)
            {
                this.FunctionBody = new CodeBlockNode(rhs.FunctionBody);
            }
            else
            {
                this.FunctionBody = new CodeBlockNode();
            }

            this.ReturnType = rhs.ReturnType;

            this.Attributes = rhs.Attributes;
            this.Singnature = new ArgumentSignatureNode(rhs.Singnature);
            this.Pattern = rhs.Pattern;
            this.IsExternLib = rhs.IsExternLib;
            this.BuiltInMethodId = rhs.BuiltInMethodId;
            this.IsDNI = rhs.IsDNI;
            this.ExternLibName = rhs.ExternLibName;
            this.access = rhs.access;
            this.IsStatic = rhs.IsStatic;
            this.IsAutoGenerated = rhs.IsAutoGenerated;
            this.IsAssocOperator = rhs.IsAssocOperator;
            this.IsAutoGeneratedThisProc = IsAutoGeneratedThisProc;
            this.IsBuiltIn = rhs.IsBuiltIn;
        }
开发者ID:qingemeng,项目名称:designscript,代码行数:28,代码来源:AssociativeAST.cs

示例13: InsertDotMemVarMethod

        private static void InsertDotMemVarMethod(Core core, ProtoCore.AST.Node root)
        {
            ProtoCore.AST.AssociativeAST.FunctionDefinitionNode funcDefNode = new ProtoCore.AST.AssociativeAST.FunctionDefinitionNode();
            funcDefNode.access = ProtoCore.DSASM.AccessSpecifier.kPublic;
            funcDefNode.Name = ProtoCore.DSASM.Constants.kDotArgMethodName;
            funcDefNode.ReturnType = new ProtoCore.Type() { Name = core.TypeSystem.GetType((int)PrimitiveType.kTypeVar), UID = (int)PrimitiveType.kTypeVar };
            ProtoCore.AST.AssociativeAST.ArgumentSignatureNode args = new ProtoCore.AST.AssociativeAST.ArgumentSignatureNode();
            args.AddArgument(new ProtoCore.AST.AssociativeAST.VarDeclNode()
            {
            memregion = ProtoCore.DSASM.MemoryRegion.kMemStack,
            access = ProtoCore.DSASM.AccessSpecifier.kPublic,
            NameNode = BuildAssocIdentifier(core, ProtoCore.DSASM.Constants.kLHS),
            ArgumentType = new ProtoCore.Type { Name = core.TypeSystem.GetType((int)PrimitiveType.kTypeVar), UID = (int)PrimitiveType.kTypeVar }
            });
            args.AddArgument(new ProtoCore.AST.AssociativeAST.VarDeclNode()
            {
            memregion = ProtoCore.DSASM.MemoryRegion.kMemStack,
            access = ProtoCore.DSASM.AccessSpecifier.kPublic,
            NameNode = BuildAssocIdentifier(core, ProtoCore.DSASM.Constants.kRHS),
            ArgumentType = new ProtoCore.Type { Name = core.TypeSystem.GetType((int)PrimitiveType.kTypeInt), UID = (int)PrimitiveType.kTypeInt }
            });
            args.AddArgument(new ProtoCore.AST.AssociativeAST.VarDeclNode()
            {
            memregion = ProtoCore.DSASM.MemoryRegion.kMemStack,
            access = ProtoCore.DSASM.AccessSpecifier.kPublic,
            NameNode = BuildAssocIdentifier(core, "%rhsDimExprList"),
            ArgumentType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeInt, 1)
            });
            args.AddArgument(new ProtoCore.AST.AssociativeAST.VarDeclNode()
            {
            memregion = ProtoCore.DSASM.MemoryRegion.kMemStack,
            access = ProtoCore.DSASM.AccessSpecifier.kPublic,
            NameNode = BuildAssocIdentifier(core, "%rhsDim"),
            ArgumentType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeInt, 0)
            });
            funcDefNode.Signature = args;

            ProtoCore.AST.AssociativeAST.CodeBlockNode body = new ProtoCore.AST.AssociativeAST.CodeBlockNode();
            ProtoCore.AST.AssociativeAST.IdentifierNode _return = BuildAssocIdentifier(core, ProtoCore.DSDefinitions.Keyword.Return, ProtoCore.PrimitiveType.kTypeReturn);

            ProtoCore.AST.AssociativeAST.DotFunctionBodyNode dotNode = new ProtoCore.AST.AssociativeAST.DotFunctionBodyNode(args.Arguments[0].NameNode, args.Arguments[1].NameNode, args.Arguments[2].NameNode, args.Arguments[3].NameNode);
            body.Body.Add(new ProtoCore.AST.AssociativeAST.BinaryExpressionNode() { LeftNode = _return, Optr = ProtoCore.DSASM.Operator.assign, RightNode = dotNode});
            funcDefNode.FunctionBody = body;
            (root as ProtoCore.AST.AssociativeAST.CodeBlockNode).Body.Add(funcDefNode);
        }
开发者ID:TheChosen0ne,项目名称:Dynamo,代码行数:45,代码来源:CoreUtils.cs

示例14: InsertUnaryOperationMethod

        // The following methods are used to insert methods to the bottom of the AST and convert operator to these method calls 
        // to support replication on operators 
        private static void InsertUnaryOperationMethod(Core core, CodeBlockNode root, UnaryOperator op, PrimitiveType r, PrimitiveType operand)
        {
            FunctionDefinitionNode funcDefNode = new FunctionDefinitionNode();
            funcDefNode.access = CompilerDefinitions.AccessModifier.kPublic;
            funcDefNode.IsAssocOperator = true;
            funcDefNode.IsBuiltIn = true;
            funcDefNode.Name = Op.GetUnaryOpFunction(op);
            funcDefNode.ReturnType = new Type() { Name = core.TypeSystem.GetType((int)r), UID = (int)r };
            ArgumentSignatureNode args = new ArgumentSignatureNode();
            args.AddArgument(new VarDeclNode()
            {
                Access = CompilerDefinitions.AccessModifier.kPublic,
                NameNode = AstFactory.BuildIdentifier("%param"),
                ArgumentType = new Type { Name = core.TypeSystem.GetType((int)operand), UID = (int)operand }
            });
            funcDefNode.Signature = args;

            CodeBlockNode body = new CodeBlockNode();
            IdentifierNode param = AstFactory.BuildIdentifier("%param");
            body.Body.Add(AstFactory.BuildReturnStatement(new UnaryExpressionNode() { Expression = param, Operator = op }));
            funcDefNode.FunctionBody = body;
            root.Body.Add(funcDefNode);
        }
开发者ID:nmeek,项目名称:Dynamo,代码行数:25,代码来源:CoreUtils.cs

示例15: GetFunctionHash

 /// <summary>
 /// Gets the has id of a function signature given the name and argument types
 /// </summary>
 /// <param name="functionDef"></param>
 /// <returns></returns>
 public static int GetFunctionHash(FunctionDefinitionNode functionDef)
 {
     Validity.Assert(null != functionDef);
     string functionDescription = functionDef.Name;
     foreach (VarDeclNode argNode in functionDef.Signature.Arguments)
     {
         functionDescription += argNode.ArgumentType.ToString();
     }
     return functionDescription.GetHashCode();
 }
开发者ID:nmeek,项目名称:Dynamo,代码行数:15,代码来源:CoreUtils.cs


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