Changeset 2433


Ignore:
Timestamp:
Oct 11, 2012, 4:21:27 PM (7 years ago)
Author:
ksherdy
Message:

Added accessors / generators static convenience methods.

Location:
proto/pablo/src/compiler/ast
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • proto/pablo/src/compiler/ast/Accessors.java

    r2419 r2433  
    7474                return node.child(1);
    7575        }
    76 
     76       
    7777        ////////////////////////////////////////////////////////////////////////////
    7878        // WhileStatement helpers
     
    8585        // FunctionInvocationNode helpers
    8686        ////////////////////////////////////////////////////////////////////////////
    87         public static ASTNode functionName(FunctionInvocationNode node) {
     87        public static ASTNode functionInvocationName(FunctionInvocationNode node) {
    8888                return node.child(0);
    8989        }
    90         public static List<ASTNode> functionArgs(FunctionInvocationNode node) {
     90        public static List<ASTNode> functionInvocationArgs(FunctionInvocationNode node) {
    9191                return node.getChildren().subList(1, node.nChildren());
    9292        }
     
    101101       
    102102        public static String functionIdentifier(FunctionInvocationNode node) {
    103                 ASTNode functionName = functionName(node);
     103                ASTNode functionName = functionInvocationName(node);
    104104                String identifier = identifierLexeme(functionName);
    105105                return identifier;
  • proto/pablo/src/compiler/ast/Generators.java

    r2419 r2433  
    4545        }
    4646
     47        /** Makes a new compound FunctionInvocationNode with a array of identifiers string and the TextLocation taken from token.
     48         * @param identifiers           an array of identifiers, for example {"a", "b"} will result in function call a.b();
     49         * @param locationToken         a token containing the TextLocation for this new node.
     50         * @param children                      an array of ASTNode children
     51         * @return      the new FunctionInvocationNode
     52         */
     53        public static ASTNode makeFunctionInvocationNode(String[] identifiers, Token locationToken, ASTNode [] children) {
     54                CompoundVariableNode identifierNode = Generators.makeCompoundVariableNode(identifiers, locationToken);
     55                ASTNode functionInvocationNode = Generators.makeFunctionInvocationNode(identifierNode, locationToken);
     56                for(ASTNode child:children) {
     57                        functionInvocationNode.appendChild(child);
     58                }
     59                return functionInvocationNode;
     60        }       
     61       
    4762        /** Makes a new FunctionInvocationNode with an ASTNode identifier and the TextLocation taken from token.
    4863         * @param identifier            an ASTNode, must be IdentifierNode or CompundVariableNode
     
    8398                return functionInvocationNode;
    8499        }
    85 
     100               
    86101        /** Makes a new CompoundVariableNode with an array of identifier strings and and the TextLocation taken from token.
    87102         * Currently, no special consideration with only one identifier in the array.
Note: See TracChangeset for help on using the changeset viewer.