Пример #1
0
            private static int GetArgNumber(AST.VariableDeclNode arg, AST.FunctionDefinitionNode funDef)
            {
                for (int i = 0; i < funDef.Parameters.Count(); i++)
                {
                    if (Object.ReferenceEquals(arg, funDef.Parameters.ElementAt(i)))
                    {
                        return(i);
                    }
                }

                return(-1);
            }
Пример #2
0
        /// <summary>
        /// Returns fully prepared backend Function object for the given program function.
        /// </summary>
        /// <param name="funDef">Function definition.</param>
        /// <param name="expGraph">ControlFlowGraph of this function body.</param>
        public static B.Function BuildBackendFunction(AST.FunctionDefinitionNode funDef, IEnumerable <Vertex> expGraph)
        {
            B.Function f = funDef.BackendFunction; // get previously created backend function object
            // FIXME: this code is no longer needed -> args will be constructed inside function object
            for (int i = 0; i < f.ArgsCount; i++)
            {
                // for each argument set temporary node used for this argument inside created backend tree

                //f.ArgsLocations[i] = new Brep.TemporaryNode();
            }

            f.Body = new List <Brep.Node> {
                (new DFSBuilder(funDef, expGraph.Last())).Build(expGraph.First())
            };
            f.Result = null;             // this is set by DFSBuilder

            return(f);
        }
Пример #3
0
        // ----- Methods -----

        #region implemented abstract members of Node

        // Program -> (Function|Record)* Eof
        public override void BuildNode <TSymbol>(IParseTree <TSymbol> parseTree)
        {
            var childs = ASTBuilder.ChildrenArray(parseTree);

            for (int i = 0; i < childs.Length - 1; i++) // skip last child - it is EOF
            {
                switch (ASTBuilder.GetName(childs [i].Symbol))
                {
                case "RecordTypeDeclaration":
                    var recordNode = new RecordTypeDeclarationNode();
                    recordNode.BuildNode(childs [i]);
                    records.AddLast(recordNode);
                    break;

                default:
                    var funNode = new FunctionDefinitionNode();
                    funNode.BuildNode(childs [i]);
                    functions.AddLast(funNode);
                    break;
                }
            }
        }
Пример #4
0
 public RecursiveBuilder(AST.FunctionDefinitionNode funDef)
 {
     this.funDef = funDef;
 }
Пример #5
0
 public static Brep.Node BuildNode(ExpressionNode expNode, AST.FunctionDefinitionNode funDef)
 {
     return((new RecursiveBuilder(funDef)).Build(expNode as dynamic));
 }
Пример #6
0
 public DFSBuilder(AST.FunctionDefinitionNode funDef, Vertex resNode)
 {
     this.funDef  = funDef;
     this.resNode = resNode;
 }
Пример #7
0
 public FunctionCallNode(string name, IReadOnlyList <ExpressionNode> arguments, FunctionDefinitionNode definition)
 {
     this.Name       = name;
     this.Arguments  = arguments;
     this.Definition = definition;
 }