Changeset 3246

Show
Ignore:
Timestamp:
12/19/08 22:34:31 (11 months ago)
Author:
sukyoungryu
Message:

[ast refactoring] Replaced the span field, which every AST node contains, with the info field. Commented out two syntactic abstraction tests. Will add them back when we have cycles to clean up the syntactic abstraction code.

Location:
trunk/ProjectFortress
Files:
37 modified

Legend:

Unmodified
Added
Removed
  • trunk/ProjectFortress/astgen/Fortress.ast

    r3238 r3246  
    7777     * top-level node interface 
    7878     */ 
    79     interface ASTNode(ignoreForEquals Span span); 
     79    interface ASTNode(ASTNodeInfo info); 
    8080        /** 
    8181         * with static parameters 
     
    9494         * top-level node abstract class 
    9595         */ 
    96         root abstract AbstractNode() extends UIDObject; 
     96        root abstract AbstractNode(ASTNodeInfo info) extends UIDObject; 
    9797            /** 
    9898             * compilation unit declaration 
     
    18541854                 * common header for AST nodes 
    18551855                 */ 
    1856                 abstract ASTNodeInfo(); 
     1856                abstract ASTNodeInfo(ignoreForEquals Span span); 
     1857                    /** 
     1858                     * common header for node with Span 
     1859                     */ 
     1860                    SpanInfo(); 
    18571861                    /** 
    18581862                     * common header for parenthesized node 
  • trunk/ProjectFortress/src/com/sun/fortress/astgen/EllipsesNode.java

    r2690 r3246  
    3737 
    3838    private String nodeField = "repeatedNode"; 
    39  
    40     public EllipsesNode( NodeClass parent, ASTModel ast ){ 
     39    private String infoType; 
     40 
     41    public EllipsesNode( NodeClass parent, ASTModel ast, String in_infoType ){ 
    4142        super( "_Ellipses" + parent.name(), false, fields(ast), Types.parse(parent.name(), ast), Collections.singletonList(Types.parse("_Ellipses",ast)) ); 
     43        infoType = in_infoType; 
    4244    } 
    4345 
     
    5052        return fields(ast); 
    5153    } 
    52          
     54 
    5355    private static List<Field> fields( ASTModel ast ){ 
    5456        return new ArrayList<Field>(); 
     
    9799        writeSerialize(writer); 
    98100        writer.println(""); 
    99         writeOutputHelp(writer, this.name());       
     101        writeOutputHelp(writer, this.name()); 
    100102 
    101103        //   for (CodeGenerator g : gens) { g.generateClassMembers(writer, this); } 
     
    135137            writer.startLine("visitor.for"+name+"(this);"); 
    136138            writer.unindent(); 
    137             writer.startLine("}");             
     139            writer.startLine("}"); 
    138140        } 
    139141 
     
    148150        writer.startLine(String.format("private final AbstractNode _%s;", nodeField)); 
    149151        /* 
    150         // writer.startLine("private final Span _span;"); 
    151152        writer.startLine(String.format("private final String _%s;", fieldTransformer)); 
    152153        writer.startLine("private final java.util.Map<String,Object> _variables;"); 
     
    156157 
    157158    private void writeConstructor(TabPrintWriter writer, String className) { 
    158         writer.startLine(String.format("public %s(Span span, AbstractNode %s){", className, nodeField)); 
    159         writer.indent(); 
    160         writer.startLine("super(span);"); 
     159        writer.startLine(String.format("public %s(" + infoType + " info, AbstractNode %s){", className, nodeField)); 
     160        writer.indent(); 
     161        writer.startLine("super(info);"); 
    161162        writer.startLine(String.format("this._%s = %s;", nodeField, nodeField)); 
    162163        writer.unindent(); 
    163164        writer.startLine("}"); 
    164         /* 
    165         writer.startLine(String.format("public %s(Span span, String %s, java.util.Map<String,Object> variables, java.util.List<String> syntaxParameters ) {", className, fieldTransformer)); 
    166         writer.indent(); 
    167         writer.startLine("super(span);"); 
    168         writer.startLine(String.format("this._%s = %s;", fieldTransformer, fieldTransformer)); 
    169         writer.startLine("this._variables = variables;"); 
    170         writer.startLine("this._syntaxParameters = syntaxParameters;"); 
    171         writer.unindent(); 
    172         writer.startLine("}"); 
    173         */ 
    174165    } 
    175166 
     
    177168        writer.startLine("public " + className+"() {"); 
    178169        writer.indent(); 
    179         writer.startLine("super(new Span());"); 
     170        writer.startLine("super(NodeFactory.make" + infoType + "());"); 
    180171        writer.startLine(String.format("this._%s = null;", nodeField)); 
    181172        /* 
     
    203194        writer.startLine("}"); 
    204195        writer.unindent(); 
    205         writer.startLine("}");         
     196        writer.startLine("}"); 
    206197    } 
    207198 
     
    249240        writer.startLine("writer.indent();"); 
    250241 
    251         writer.startLine("Span temp_span = getSpan();"); 
     242        writer.startLine(infoType + " temp_info = getInfo();"); 
    252243        writer.startLine("writer.startLine();"); 
    253         writer.startLine("writer.print(\"span = \");"); 
     244        writer.startLine("writer.print(\"info = \");"); 
    254245        writer.startLine("if (lossless) {"); 
    255246        writer.indent(); 
    256         writer.startLine("writer.printSerialized(temp_span);"); 
     247        writer.startLine("writer.printSerialized(temp_info);"); 
    257248        writer.startLine("writer.print(\" \");"); 
    258         writer.startLine("writer.printEscaped(temp_span);"); 
    259         writer.unindent(); 
    260         writer.startLine("} else { writer.print(temp_span); }"); 
     249        writer.startLine("writer.printEscaped(temp_info);"); 
     250        writer.unindent(); 
     251        writer.startLine("} else { writer.print(temp_info); }"); 
    261252        writer.startLine("writer.unindent();"); 
    262253        writer.unindent(); 
  • trunk/ProjectFortress/src/com/sun/fortress/astgen/EllipsesNodeCreator.java

    r3142 r3246  
    5858        List<Pair<NodeType, NodeType>> all = new LinkedList<Pair<NodeType, NodeType>>(); 
    5959        NodeType abstractNode; 
    60         if ( ast.typeForName("AbstractNode").isNone() ) 
    61             throw new RuntimeException("Fortress.ast does not define AbstractNode!"); 
    62         else 
     60        NodeType exprNode; 
     61        NodeType typeNode; 
     62        if ( ast.typeForName("AbstractNode").isSome() && 
     63             ast.typeForName("Expr").isSome() && 
     64             ast.typeForName("Type").isSome() ) { 
     65            abstractNode = ast.typeForName("AbstractNode").unwrap(); 
     66            exprNode     = ast.typeForName("Expr").unwrap(); 
     67            typeNode     = ast.typeForName("Type").unwrap(); 
     68        } else 
     69            throw new RuntimeException("Fortress.ast does not define AbstractNode/Expr/Type!"); 
     70 
    6371            abstractNode = ast.typeForName("AbstractNode").unwrap(); 
    6472        for ( NodeType n : ast.classes() ){ 
    6573            if ( n.getClass() == NodeClass.class && 
    6674                 ast.isDescendent(abstractNode, n) ){ 
    67                 NodeType child = new EllipsesNode((NodeClass) n,ast); 
     75 
     76                String infoType; 
     77                if ( ast.isDescendent(exprNode, n) ) infoType = "ExprInfo"; 
     78                else if ( ast.isDescendent(typeNode, n) ) infoType = "TypeInfo"; 
     79                else infoType = "ASTNodeInfo"; 
     80 
     81                NodeType child = new EllipsesNode((NodeClass) n,ast,infoType); 
    6882                all.add( new Pair<NodeType,NodeType>( child, n ) ); 
    6983            } 
  • trunk/ProjectFortress/src/com/sun/fortress/astgen/SingleSpanConstructorGenerator.java

    r3142 r3246  
    2929 
    3030/** 
    31  * Produce a single argument constructor which takes a Span, and instantiates 
     31 * Produce a single argument constructor which takes a SpanInfo, and instantiates 
    3232 * each field to null, leaving clients to manually instantiate each field correctly. 
    3333 */ 
     
    3535 
    3636    private NodeType abstractNode; 
     37    private NodeType exprNode; 
     38    private NodeType typeNode; 
    3739 
    3840    public SingleSpanConstructorGenerator(ASTModel ast) { 
    3941        super(ast); 
    40         if ( ast.typeForName("AbstractNode").isNone() ) 
    41             throw new RuntimeException("Fortress.ast does not define AbstractNode!"); 
    42         else 
     42        if ( ast.typeForName("AbstractNode").isSome() && 
     43             ast.typeForName("Expr").isSome() && 
     44             ast.typeForName("Type").isSome() ) { 
    4345            abstractNode = ast.typeForName("AbstractNode").unwrap(); 
     46            exprNode     = ast.typeForName("Expr").unwrap(); 
     47            typeNode     = ast.typeForName("Type").unwrap(); 
     48        } else 
     49            throw new RuntimeException("Fortress.ast does not define AbstractNode/Expr!"); 
    4450    } 
    4551 
     
    5258    // boolean allDefaults = true; 
    5359    int nonDefault = 0; 
    54     // Guaranteed to iterate at least once, all fields have Span. 
     60    // Guaranteed to iterate at least once, all fields have SpanInfo. 
    5561    for (Field f : c.allFields(ast)) { 
    5662        //hasSingleSpanConstructor = false; 
     
    7076      writer.startLine(" * templateParams."); 
    7177      writer.startLine(" */"); 
    72       writer.startLine("protected " + c.name() + "(Span span) {"); 
     78      String infoType = "ASTNodeInfo"; 
     79      if ( ast.isDescendent(exprNode, c) ) 
     80          infoType = "ExprInfo"; 
     81      else if ( ast.isDescendent(typeNode, c) ) 
     82          infoType = "TypeInfo"; 
     83      writer.startLine("protected " + c.name() + "(" + infoType + " info) {"); 
    7384      writer.indent(); 
    74       writer.startLine("super(span);"); 
     85      writer.startLine("super(info);"); 
    7586      for (Field f : c.declaredFields(ast)) { 
    7687          String init; 
  • trunk/ProjectFortress/src/com/sun/fortress/astgen/TemplateGapClass.java

    r2934 r3246  
    3333public class TemplateGapClass extends NodeClass { 
    3434    //    private TypeName _superClass; 
    35  
    36     public TemplateGapClass(String name, List<Field> fields, TypeName superClass, List<TypeName> interfaces) { 
     35    private String infoType; 
     36 
     37    public TemplateGapClass(String name, List<Field> fields, TypeName superClass, 
     38                            List<TypeName> interfaces, String in_infoType) { 
    3739        super(name, false, fields, superClass, interfaces); 
     40        infoType = in_infoType; 
    3841        //        _superClass = superClass; 
    3942    } 
     
    5962        } 
    6063        // may include fields in a parent interface 
    61         return TemplateGapNodeCreator.TEMPLATEGAPFIELDS; 
     64        if ( infoType.equals("ExprInfo") ) 
     65            return TemplateGapNodeCreator.TEMPLATEGAPEXPRFIELDS; 
     66        else if ( infoType.equals("TypeInfo") ) 
     67            return TemplateGapNodeCreator.TEMPLATEGAPTYPEFIELDS; 
     68        else 
     69            return TemplateGapNodeCreator.TEMPLATEGAPFIELDS; 
    6270    } 
    6371 
     
    104112        writeSerialize(writer); 
    105113        writer.println(""); 
    106         writeOutputHelp(writer, this.name());       
     114        writeOutputHelp(writer, this.name()); 
    107115 
    108116        //   for (CodeGenerator g : gens) { g.generateClassMembers(writer, this); } 
     
    117125 
    118126    private void writeGetters(TabPrintWriter writer, String name) { 
    119         //        writer.startLine("final public Span getSpan() { return _span; }"); 
    120127        writer.startLine("final public Id getGapId() { return _id; }"); 
    121128        writer.startLine("final public List<Id> getTemplateParams() { return _templateParams; }"); 
     
    137144            writer.startLine("visitor.for"+name+"(this);"); 
    138145            writer.unindent(); 
    139             writer.startLine("}");             
     146            writer.startLine("}"); 
    140147        } 
    141148 
     
    149156 
    150157    private void writeFields(TabPrintWriter writer) { 
    151         // writer.startLine("private final Span _span;"); 
    152158        writer.startLine("private final Id _id;"); 
    153159        writer.startLine("private final List<Id> _templateParams;"); 
     
    155161 
    156162    private void writeConstructor(TabPrintWriter writer, String className) { 
    157         writer.startLine("public " + className+"(Span span, Id id, List<Id> templateParams) {"); 
    158         writer.indent(); 
    159         writer.startLine("super(span);"); 
     163        writer.startLine("public " + className+"(" + infoType + " info, Id id, List<Id> templateParams) {"); 
     164        writer.indent(); 
     165        writer.startLine("super(info);"); 
    160166        writer.startLine("this._id = id;"); 
    161167        writer.startLine("this._templateParams = templateParams;"); 
     
    167173        writer.startLine("public " + className+"() {"); 
    168174        writer.indent(); 
    169         writer.startLine("super(new Span());"); 
     175        writer.startLine("super(NodeFactory.make" + infoType + "());"); 
    170176        writer.startLine("this._id = null;"); 
    171177        writer.startLine("this._templateParams = null;"); 
     
    196202        writer.startLine("}"); 
    197203        writer.unindent(); 
    198         writer.startLine("}");         
     204        writer.startLine("}"); 
    199205    } 
    200206 
     
    245251        writer.startLine("writer.indent();"); 
    246252 
    247         writer.startLine("Span temp_span = getSpan();"); 
     253        writer.startLine(infoType + " temp_info = getInfo();"); 
    248254        writer.startLine("writer.startLine();"); 
    249         writer.startLine("writer.print(\"span = \");"); 
     255        writer.startLine("writer.print(\"info = \");"); 
    250256        writer.startLine("if (lossless) {"); 
    251257        writer.indent(); 
    252         writer.startLine("writer.printSerialized(temp_span);"); 
     258        writer.startLine("writer.printSerialized(temp_info);"); 
    253259        writer.startLine("writer.print(\" \");"); 
    254         writer.startLine("writer.printEscaped(temp_span);"); 
    255         writer.unindent(); 
    256         writer.startLine("} else { writer.print(temp_span); }"); 
     260        writer.startLine("writer.printEscaped(temp_info);"); 
     261        writer.unindent(); 
     262        writer.startLine("} else { writer.print(temp_info); }"); 
    257263 
    258264        writer.startLine("Id temp_id = getGapId();"); 
     
    292298    @Override 
    293299    public Iterable<Field> allFields(ASTModel ast) { 
    294         return TemplateGapNodeCreator.TEMPLATEGAPFIELDS; 
     300        if ( infoType.equals("ExprInfo") ) 
     301            return TemplateGapNodeCreator.TEMPLATEGAPEXPRFIELDS; 
     302        else if ( infoType.equals("TypeInfo") ) 
     303            return TemplateGapNodeCreator.TEMPLATEGAPTYPEFIELDS; 
     304        else 
     305            return TemplateGapNodeCreator.TEMPLATEGAPFIELDS; 
    295306    } 
    296307 
  • trunk/ProjectFortress/src/com/sun/fortress/astgen/TemplateGapNodeCreator.java

    r3142 r3246  
    3535public class TemplateGapNodeCreator extends CodeGenerator implements Runnable { 
    3636 
     37    private TypeName idType = Types.parse("Id", ast); 
     38    private TypeName listIdType = Types.parse("List<Id>", ast); 
     39 
    3740    public static List<Field> TEMPLATEGAPFIELDS; { 
    3841        TEMPLATEGAPFIELDS = new LinkedList<Field>(); 
    39         TypeName spanType = Types.parse("Span", ast); 
    40         TEMPLATEGAPFIELDS.add(new Field(spanType , "span", Option.<String>some("new Span()"), false, true, true)); 
    41         TypeName idType = Types.parse("Id", ast); 
     42        TypeName infoType = Types.parse("ASTNodeInfo", ast); 
     43        TEMPLATEGAPFIELDS.add(new Field(infoType , "info", Option.<String>some("NodeFactory.makeASTNodeInfo()"), false, true, true)); 
    4244        TEMPLATEGAPFIELDS.add(new Field(idType , "gapId", Option.<String>none(), false, false, true)); 
    43         TypeName listIdType = Types.parse("List<Id>", ast); 
    4445        TEMPLATEGAPFIELDS.add(new Field(listIdType , "templateParams", Option.<String>none(), false, false, true)); 
     46    } 
     47 
     48    public static List<Field> TEMPLATEGAPEXPRFIELDS; { 
     49        TEMPLATEGAPEXPRFIELDS = new LinkedList<Field>(); 
     50        TypeName infoType = Types.parse("ExprInfo", ast); 
     51        TEMPLATEGAPEXPRFIELDS.add(new Field(infoType , "info", Option.<String>some("NodeFactory.makeExprInfo()"), false, true, true)); 
     52        TEMPLATEGAPEXPRFIELDS.add(new Field(idType , "gapId", Option.<String>none(), false, false, true)); 
     53        TEMPLATEGAPEXPRFIELDS.add(new Field(listIdType , "templateParams", Option.<String>none(), false, false, true)); 
     54    } 
     55 
     56    public static List<Field> TEMPLATEGAPTYPEFIELDS; { 
     57        TEMPLATEGAPTYPEFIELDS = new LinkedList<Field>(); 
     58        TypeName infoType = Types.parse("TypeInfo", ast); 
     59        TEMPLATEGAPTYPEFIELDS.add(new Field(infoType , "info", Option.<String>some("NodeFactory.makeTypeInfo()"), false, true, true)); 
     60        TEMPLATEGAPTYPEFIELDS.add(new Field(idType , "gapId", Option.<String>none(), false, false, true)); 
     61        TEMPLATEGAPTYPEFIELDS.add(new Field(listIdType , "templateParams", Option.<String>none(), false, false, true)); 
    4562    } 
    4663 
     
    5875        List<Pair<NodeType, NodeType>> templateGaps = new LinkedList<Pair<NodeType, NodeType>>(); 
    5976        NodeType abstractNode; 
    60         if ( ast.typeForName("AbstractNode").isNone() ) 
    61             throw new RuntimeException("Fortress.ast does not define AbstractNode!"); 
    62         else 
     77        NodeType exprNode; 
     78        NodeType typeNode; 
     79        if ( ast.typeForName("AbstractNode").isSome() && 
     80             ast.typeForName("Expr").isSome() && 
     81             ast.typeForName("Type").isSome() ) { 
    6382            abstractNode = ast.typeForName("AbstractNode").unwrap(); 
     83            exprNode     = ast.typeForName("Expr").unwrap(); 
     84            typeNode     = ast.typeForName("Type").unwrap(); 
     85        } else 
     86            throw new RuntimeException("Fortress.ast does not define AbstractNode/Expr/Type!"); 
    6487        for (NodeClass nodeClass: ast.classes()) { 
    6588            if ( nodeClass.getClass() == NodeClass.class && 
     
    6790                List<TypeName> interfaces = new LinkedList<TypeName>(); 
    6891                interfaces.add(templateGapName); 
    69                 List<Field> fields = TemplateGapNodeCreator.TEMPLATEGAPFIELDS; 
     92                String infoType; 
     93                List<Field> fields; 
     94                if ( ast.isDescendent(exprNode, nodeClass) ) { 
     95                    infoType = "ExprInfo"; 
     96                    fields = TemplateGapNodeCreator.TEMPLATEGAPEXPRFIELDS; 
     97                } else if ( ast.isDescendent(typeNode, nodeClass) ) { 
     98                    infoType = "TypeInfo"; 
     99                    fields = TemplateGapNodeCreator.TEMPLATEGAPTYPEFIELDS; 
     100                } else { 
     101                    infoType = "ASTNodeInfo"; 
     102                    fields = TemplateGapNodeCreator.TEMPLATEGAPFIELDS; 
     103                } 
    70104                TypeName superName = Types.parse(nodeClass.name(), ast); 
    71                 NodeType templateGap = new TemplateGapClass("TemplateGap"+nodeClass.name(), fields, superName, interfaces); 
     105                NodeType templateGap = new TemplateGapClass("TemplateGap"+nodeClass.name(), 
     106                                                            fields, superName, interfaces, 
     107                                                            infoType); 
    72108                templateGaps.add(new Pair<NodeType, NodeType>(templateGap, nodeClass)); 
    73109            } 
  • trunk/ProjectFortress/src/com/sun/fortress/astgen/TemplateVisitorGenerator.java

    r2690 r3246  
    3737public class TemplateVisitorGenerator extends UpdateVisitorGenerator { 
    3838 
     39    private NodeType exprNode; 
     40    private NodeType typeNode; 
     41 
    3942    public TemplateVisitorGenerator(ASTModel ast) { 
    4043        super(ast); 
     44        if ( ast.typeForName("Expr").isSome() && 
     45             ast.typeForName("Type").isSome() ) { 
     46            exprNode = ast.typeForName("Expr").unwrap(); 
     47            typeNode = ast.typeForName("Type").unwrap(); 
     48        } else 
     49            throw new RuntimeException("Fortress.ast does not define AbstractNode/Expr/Type!"); 
    4150    } 
    4251 
     
    4554        // only defined for the "Node" class 
    4655        if (!root.name().equals("Node")) { return; } 
    47          
     56 
    4857        String visitorName = "TemplateUpdateVisitor"; 
    4958        TabPrintWriter writer = options.createJavaSourceInOutDir(visitorName); 
     
    6473        writer.startLine(" * case has a default implementation."); 
    6574        writer.startLine(" */"); 
    66         writer.startLine("@SuppressWarnings(value={\"unused\"})");         
     75        writer.startLine("@SuppressWarnings(value={\"unused\"})"); 
    6776        writer.startLine("public abstract class " + visitorName); 
    6877 
     
    7887        writer.println(); 
    7988 
    80          
     89 
    8190        writer.startLine("/* Methods to handle a node after recursion. */"); 
    8291        for (NodeType t : ast.descendents(root)) { 
     
    94103//              outputTemplateForCaseOnly(t, writer, root); 
    95104//          } 
    96         }  
     105        } 
    97106        writer.println(); 
    98107 
     
    107116//          } 
    108117        } 
    109          
     118 
    110119        NodeType templateGapInterface = null; 
    111120        for (NodeInterface ni: ast.interfaces()) { 
     
    114123            } 
    115124        } 
    116         outputForTemplateGapOnly(templateGapInterface, writer, root);         
     125        outputForTemplateGapOnly(templateGapInterface, writer, root); 
    117126 
    118127        writer.println(); 
     
    123132        writer.println(); 
    124133        outputEllipsesDefaultCase(writer, root); 
    125          
     134 
    126135        // Output helpers 
    127136        for (TypeName t : helpers()) { writer.println(); generateHelper(t, writer, root); } 
    128          
     137 
    129138        writer.unindent(); 
    130139        writer.startLine("}"); 
     
    176185            if (typeName.name().equals("TemplateGap")) { 
    177186                isTemplateGap = true; 
    178             }                 
     187            } 
    179188        } 
    180189 
     
    207216            writer.print(");"); 
    208217        } 
    209         writer.unindent(); 
    210         writer.startLine("}"); 
    211         writer.println(); 
    212     } 
    213  
    214     protected void outputTemplateVisitMethod(NodeType t, TabPrintWriter writer, NodeType root) { 
    215         outputTemplateForCaseHeader(t, writer, root.name()); 
    216         writer.indent(); 
    217  
    218         List<String> recurVals = new LinkedList<String>(); 
    219         for (Field f : TemplateGapNodeCreator.TEMPLATEGAPFIELDS) { 
    220             Option<String> recur = recurExpression(f.type(), "that." + f.getGetterName() + "()", root, true); 
    221             if (recur.isSome()) { 
    222                 String recurName = f.name() + "_result"; 
    223                 writer.startLine(f.type().name() + " " + recurName + " = " + recur.unwrap() + ";"); 
    224                 recurVals.add(recurName); 
    225             } 
    226         }    
    227         writer.startLine("return forTemplateGap"+t.name()+"Only(that"); 
    228         for (String recurVal : recurVals) { writer.print(", " + recurVal); } 
    229         writer.print(");"); 
    230  
    231218        writer.unindent(); 
    232219        writer.startLine("}"); 
     
    257244    } 
    258245 
    259     protected void outputTemplateForCaseOnly(NodeType t, TabPrintWriter writer, NodeType root) { 
     246    protected void outputForTemplateGapOnly(NodeType t, TabPrintWriter writer, NodeType root) { 
    260247        // only called for concrete cases; must not delegate 
    261248        List<String> params = new LinkedList<String>(); // "type name" strings 
    262249        List<String> getters = new LinkedList<String>(); // expressions 
    263250        List<String> paramRefs = new LinkedList<String>(); // variable names or null 
    264         for (Field f : TemplateGapNodeCreator.TEMPLATEGAPFIELDS) { 
     251        List<Field> fields; 
     252        if ( ast.isDescendent(exprNode, root) ) 
     253            fields = TemplateGapNodeCreator.TEMPLATEGAPEXPRFIELDS; 
     254        else if ( ast.isDescendent(typeNode, root) ) 
     255            fields = TemplateGapNodeCreator.TEMPLATEGAPTYPEFIELDS; 
     256        else 
     257            fields = TemplateGapNodeCreator.TEMPLATEGAPFIELDS; 
     258        for (Field f : fields) { 
    265259            getters.add("that." + f.getGetterName() + "()"); 
    266260            if (canRecurOn(f.type(), root)) { 
     
    271265            else { paramRefs.add(null); } 
    272266        } 
    273         outputTemplateForCaseHeader(t.name(), writer, root.name(), "Only", params); 
    274         writer.indent(); 
    275         writer.startLine("Node template = forTemplateGapOnly(that"); 
    276         for (Field f : TemplateGapNodeCreator.TEMPLATEGAPFIELDS) { 
    277             if (canRecurOn(f.type(), root)) { 
    278                 writer.print(", " + f.name()+"_result"); 
    279             } 
    280         } 
    281         writer.print(");"); 
    282  
    283         writer.startLine("if (!template.equals(that)) return template;"); 
    284  
    285         if (params.isEmpty()) { writer.startLine("return that;"); } 
    286         else { 
    287             writer.startLine("if ("); 
    288             boolean first = true; 
    289             for (Pair<String, String> getterAndRef : IterUtil.zip(getters, paramRefs)) { 
    290                 if (getterAndRef.second() != null) { 
    291                     if (first) { first = false; } 
    292                     else { writer.print(" && "); } 
    293                     writer.print(getterAndRef.first() + " == " + getterAndRef.second()); 
    294                 } 
    295             } 
    296             writer.print(") return that;"); 
    297  
    298             writer.startLine("else return new TemplateGap" + t.name() + "("); 
    299             first = true; 
    300             for (Pair<String, String> getterAndRef : IterUtil.zip(getters, paramRefs)) { 
    301                 if (first) { first = false; } 
    302                 else { writer.print(", "); } 
    303                 if (getterAndRef.second() == null) { writer.print(getterAndRef.first()); } 
    304                 else { writer.print(getterAndRef.second()); } 
    305             } 
    306             writer.print(");"); 
    307         } 
    308         writer.unindent(); 
    309         writer.startLine("}"); 
    310     } 
    311  
    312     protected void outputForTemplateGapOnly(NodeType t, TabPrintWriter writer, NodeType root) { 
    313         // only called for concrete cases; must not delegate 
    314         List<String> params = new LinkedList<String>(); // "type name" strings 
    315         List<String> getters = new LinkedList<String>(); // expressions 
    316         List<String> paramRefs = new LinkedList<String>(); // variable names or null 
    317         for (Field f : TemplateGapNodeCreator.TEMPLATEGAPFIELDS) { 
    318             getters.add("that." + f.getGetterName() + "()"); 
    319             if (canRecurOn(f.type(), root)) { 
    320                 String paramName = f.name() + "_result"; 
    321                 params.add(f.type().name() + " " + paramName); 
    322                 paramRefs.add(paramName); 
    323             } 
    324             else { paramRefs.add(null); } 
    325         } 
    326267        outputTemplateForCaseHeader("", writer, root.name(), "Only", params); 
    327268        writer.indent(); 
  • trunk/ProjectFortress/src/com/sun/fortress/astgen/TransformationNode.java

    r2690 r3246  
    3636public class TransformationNode extends NodeClass { 
    3737 
     38    private String infoType; 
     39 
    3840    /* the field that corresponds to the name of the transformer function. */ 
    3941    private final String fieldTransformer = "syntaxTransformer"; 
    4042 
    41     public TransformationNode( NodeClass parent, ASTModel ast ){ 
     43    public TransformationNode( NodeClass parent, ASTModel ast, 
     44                               String in_infoType ){ 
    4245        super( "_SyntaxTransformation" + parent.name(), false, fields(ast), Types.parse(parent.name(), ast), Collections.singletonList(Types.parse("_SyntaxTransformation",ast)) ); 
     46        infoType = in_infoType; 
    4347    } 
    4448 
     
    5155        return fields(ast); 
    5256    } 
    53          
     57 
    5458    private static List<Field> fields( ASTModel ast ){ 
    5559        /* 
     
    7680        writer.startLine(" * @version  Generated automatically by ASTGen at "); 
    7781        writer.print(new Date()); 
    78         writer.startLine(" */");         
     82        writer.startLine(" */"); 
    7983        writer.startLine("@SuppressWarnings(value={\"unused\"})"); 
    8084        // Class header 
     
    104108        writeSerialize(writer); 
    105109        writer.println(""); 
    106         writeOutputHelp(writer, this.name());       
     110        writeOutputHelp(writer, this.name()); 
    107111 
    108112        //   for (CodeGenerator g : gens) { g.generateClassMembers(writer, this); } 
     
    139143            writer.startLine("visitor.for"+name+"(this);"); 
    140144            writer.unindent(); 
    141             writer.startLine("}");             
     145            writer.startLine("}"); 
    142146        } 
    143147 
     
    150154 
    151155    private void writeFields(TabPrintWriter writer) { 
    152         // writer.startLine("private final Span _span;"); 
    153156        writer.startLine(String.format("private final String _%s;", fieldTransformer)); 
    154157        writer.startLine("private final java.util.Map<String,Level> _variables;"); 
     
    157160 
    158161    private void writeConstructor(TabPrintWriter writer, String className) { 
    159         writer.startLine(String.format("public %s(Span span, String %s, java.util.Map<String,Level> variables, java.util.List<String> syntaxParameters ) {", className, fieldTransformer)); 
    160         writer.indent(); 
    161         writer.startLine("super(span);"); 
     162        writer.startLine(String.format("public %s(" + infoType + " info, String %s, java.util.Map<String,Level> variables, java.util.List<String> syntaxParameters ) {", className, fieldTransformer)); 
     163        writer.indent(); 
     164        writer.startLine("super(info);"); 
    162165        writer.startLine(String.format("this._%s = %s;", fieldTransformer, fieldTransformer)); 
    163166        writer.startLine("this._variables = variables;"); 
     
    170173        writer.startLine("public " + className+"() {"); 
    171174        writer.indent(); 
    172         writer.startLine("super(new Span());"); 
     175        writer.startLine("super(NodeFactory.make" + infoType + "());"); 
    173176        writer.startLine(String.format("this._%s = null;", fieldTransformer)); 
    174177        writer.startLine("this._variables = null;"); 
     
    193196        writer.startLine("}"); 
    194197        writer.unindent(); 
    195         writer.startLine("}");         
     198        writer.startLine("}"); 
    196199    } 
    197200 
     
    239242        writer.startLine("writer.indent();"); 
    240243 
    241         writer.startLine("Span temp_span = getSpan();"); 
     244        writer.startLine(infoType + " temp_info = getInfo();"); 
    242245        writer.startLine("writer.startLine();"); 
    243         writer.startLine("writer.print(\"span = \");"); 
     246        writer.startLine("writer.print(\"info = \");"); 
    244247        writer.startLine("if (lossless) {"); 
    245248        writer.indent(); 
    246         writer.startLine("writer.printSerialized(temp_span);"); 
     249        writer.startLine("writer.printSerialized(temp_info);"); 
    247250        writer.startLine("writer.print(\" \");"); 
    248         writer.startLine("writer.printEscaped(temp_span);"); 
    249         writer.unindent(); 
    250         writer.startLine("} else { writer.print(temp_span); }"); 
     251        writer.startLine("writer.printEscaped(temp_info);"); 
     252        writer.unindent(); 
     253        writer.startLine("} else { writer.print(temp_info); }"); 
    251254        writer.startLine("writer.unindent();"); 
    252255        writer.unindent(); 
  • trunk/ProjectFortress/src/com/sun/fortress/astgen/TransformationNodeCreator.java

    r3142 r3246  
    5858        List<Pair<NodeType, NodeType>> all = new LinkedList<Pair<NodeType, NodeType>>(); 
    5959        NodeType abstractNode; 
    60         if ( ast.typeForName("AbstractNode").isNone() ) 
    61             throw new RuntimeException("Fortress.ast does not define AbstractNode!"); 
    62         else 
     60        NodeType exprNode; 
     61        NodeType typeNode; 
     62        if ( ast.typeForName("AbstractNode").isSome() && 
     63             ast.typeForName("Expr").isSome() && 
     64             ast.typeForName("Type").isSome() ) { 
    6365            abstractNode = ast.typeForName("AbstractNode").unwrap(); 
     66            exprNode     = ast.typeForName("Expr").unwrap(); 
     67            typeNode     = ast.typeForName("Type").unwrap(); 
     68        } else 
     69            throw new RuntimeException("Fortress.ast does not define AbstractNode/Expr/Type!"); 
    6470        for ( NodeType n : ast.classes() ){ 
    6571            if ( n.getClass() == NodeClass.class && 
    6672                 ast.isDescendent(abstractNode, n) ){ 
    67                 NodeType child = new TransformationNode((NodeClass) n,ast); 
     73 
     74                String infoType; 
     75                if ( ast.isDescendent(exprNode, n) ) infoType = "ExprInfo"; 
     76                else if ( ast.isDescendent(typeNode, n) ) infoType = "TypeInfo"; 
     77                else infoType = "ASTNodeInfo"; 
     78 
     79                NodeType child = new TransformationNode((NodeClass) n,ast,infoType); 
    6880                all.add( new Pair<NodeType,NodeType>( child, n ) ); 
    6981            } 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/DesugaringVisitor.java

    r3243 r3246  
    536536 
    537537        TraitTypeHeader header = NodeFactory.makeTraitTypeHeader(that.getHeader(), gettersAndDecls, contract_result); 
    538         return forObjectDeclOnly(that, header, params_result); 
     538        return forObjectDeclOnly(that, that.getInfo(), header, params_result); 
    539539    } 
    540540 
     
    557557        TraitTypeHeader header = NodeFactory.makeTraitTypeHeaderWithDecls(that.getHeader(), gettersAndDecls); 
    558558 
    559         return forTraitDeclOnly(that, header, NodeUtil.getExcludesClause(that), 
     559        return forTraitDeclOnly(that, that.getInfo(), header, NodeUtil.getExcludesClause(that), 
    560560                                NodeUtil.getComprisesClause(that)); 
    561561    } 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/DottedMethodRewriteVisitor.java

    r3225 r3246  
    5656        TraitTypeHeader header = NodeFactory.makeTraitTypeHeaderWithDecls(that.getHeader(), decls_result ); 
    5757 
    58         return super.forObjectDeclOnly(that, header, that.getParams()); 
     58        return super.forObjectDeclOnly(that, that.getInfo(), header, that.getParams()); 
    5959    } 
    6060 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/MutableVarRefRewriteVisitor.java

    r3225 r3246  
    9797        TraitTypeHeader header = NodeFactory.makeTraitTypeHeaderWithDecls(that.getHeader(), decls_result ); 
    9898 
    99         return super.forObjectDeclOnly(that, header, that.getParams()); 
     99        return super.forObjectDeclOnly(that, that.getInfo(), header, that.getParams()); 
    100100    } 
    101101 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/ObjectExpressionVisitor.java

    r3243 r3246  
    171171    @Override 
    172172    public Node forComponentOnly(Component that, 
     173                                 ASTNodeInfo info, 
    173174                                 APIName name_result, 
    174175                                 List<Import> imports_result, 
     
    176177                                 List<APIName> exports_result) { 
    177178        decls_result.addAll(newObjectDecls); 
    178         return super.forComponentOnly(that, name_result, 
     179        return super.forComponentOnly(that, info, name_result, 
    179180                        imports_result, decls_result, exports_result); 
    180181    } 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/PreDisambiguationDesugaringVisitor.java

    r3225 r3246  
    9191        } 
    9292 
    93         return super.forTraitDeclOnly(that, header_result, 
     93        return super.forTraitDeclOnly(that, that.getInfo(), header_result, 
    9494                                      excludesClause_result, 
    9595                                      comprisesClause_result); 
     
    103103        header_result = NodeFactory.makeTraitTypeHeader(header_result, 
    104104                                                        rewriteExtendsClause(that, header_result.getExtendsClause())); 
    105         return super.forObjectDeclOnly(that, header_result, params_result); 
     105        return super.forObjectDeclOnly(that, that.getInfo(), 
     106                                       header_result, params_result); 
    106107    } 
    107108 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/ExprDisambiguator.java

    r3244 r3246  
    676676                                v.recurOnListOfDecl(NodeUtil.getDecls(that))); 
    677677 
    678         return forTraitDeclOnly(that, header, 
     678        return forTraitDeclOnly(that, that.getInfo(), header, 
    679679                                v.recurOnListOfBaseType(NodeUtil.getExcludesClause(that)), 
    680680                                v.recurOnOptionOfListOfBaseType(NodeUtil.getComprisesClause(that))); 
     
    727727                                 v.recurOnListOfDecl(NodeUtil.getDecls(that))); 
    728728 
    729         return forObjectDeclOnly(that, header, 
     729        return forObjectDeclOnly(that, that.getInfo(), header, 
    730730                                 v.recurOnOptionOfListOfParam(NodeUtil.getParams(that))); 
    731731    } 
     
    757757        // to share its name with a field, so blindly checking for shadowing at this point 
    758758        // doesn't work. 
    759         return forFnDeclOnly(that, header, 
     759        return forFnDeclOnly(that, that.getInfo(), header, 
    760760                             that.getUnambiguousName(), 
    761761                             v.recurOnOptionOfExpr(NodeUtil.getBody(that)), 
     
    824824        ExprDisambiguator v = this.extendWithVars(Collections.singleton(that.getName())); 
    825825        return forCatchOnly(that, 
     826                            that.getInfo(), 
    826827                            (Id)that.getName().accept(v), 
    827828                            v.recurOnListOfCatchClause(that.getClauses())); 
     
    835836        ExprDisambiguator v = extendWithOutcome(NodeUtil.getSpan(that)); 
    836837        return forContractOnly(that, 
     838                               that.getInfo(), 
    837839                               v.recurOnOptionOfListOfExpr(that.getRequiresClause()), 
    838840                               v.recurOnOptionOfListOfEnsuresClause(that.getEnsuresClause()), 
     
    866868 
    867869        return forIfClauseOnly(that, 
     870                               that.getInfo(), 
    868871                               (GeneratorClause)that.getTestClause().accept(this), 
    869872                               (Block)that.getBody().accept(e_d)); 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/NonterminalDisambiguator.java

    r3211 r3246  
    3636import com.sun.fortress.nodes.NonterminalHeader; 
    3737import com.sun.fortress.nodes.NonterminalParameter; 
     38import com.sun.fortress.nodes.ASTNodeInfo; 
    3839import com.sun.fortress.nodes.StaticParam; 
    3940import com.sun.fortress.nodes.SyntaxDecl; 
     
    8485    @Override 
    8586    public Node forNonterminalDefOnly(NonterminalDef that, 
     87                                      ASTNodeInfo info, 
    8688                                      Id _name_result, 
    8789                                      List<SyntaxDecl> syntaxDefs_result, 
     
    9193            throw new RuntimeException("Type inference is not supported yet!"); 
    9294        } 
    93         return super.forNonterminalDefOnly(that, header_result.getName(), syntaxDefs_result, 
     95        return super.forNonterminalDefOnly(that, that.getInfo(), 
     96                                           header_result.getName(), syntaxDefs_result, 
    9497                                           header_result, astType_result); 
    9598    } 
     
    97100    @Override 
    98101    public Node forNonterminalExtensionDefOnly(NonterminalExtensionDef that, 
     102                                               ASTNodeInfo info, 
    99103                                               Id name_result, 
    100104                                               List<SyntaxDecl> syntaxDefs_result) { 
    101105        Id name = disambiguateNonterminalName(name_result); 
    102         return super.forNonterminalExtensionDefOnly(that, name, syntaxDefs_result); 
     106        return super.forNonterminalExtensionDefOnly(that, that.getInfo(), 
     107                                                    name, syntaxDefs_result); 
    103108    } 
    104109 
    105110    @Override 
    106111    public Node forNonterminalHeaderOnly(NonterminalHeader that, 
     112                                         ASTNodeInfo info, 
    107113                                         Id name_result, 
    108114                                         List<NonterminalParameter> params_result, 
     
    111117                                         Option<WhereClause> whereClause_result) { 
    112118        Id name = disambiguateNonterminalName(name_result); 
    113         return super.forNonterminalHeaderOnly(that, name, params_result, 
     119        return super.forNonterminalHeaderOnly(that, that.getInfo(), 
     120                                              name, params_result, 
    114121                                              staticParams_result, type_result, whereClause_result); 
    115122    } 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/SelfParamDisambiguator.java

    r3227 r3246  
    3030import com.sun.fortress.nodes.ObjectExpr; 
    3131import com.sun.fortress.nodes.Param; 
     32import com.sun.fortress.nodes.ASTNodeInfo; 
    3233import com.sun.fortress.nodes.TraitDecl; 
    3334import com.sun.fortress.nodes.Type; 
     
    9495            int traitNestingDepth = 0; 
    9596            @Override 
    96             public Node forParamOnly(Param that, Id name_result, 
     97                public Node forParamOnly(Param that, ASTNodeInfo info, 
     98                                         Id name_result, 
    9799                                                 Option<Type> type_result, 
    98100                                                 Option<Expr> defaultExpr_result, 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/TypeDisambiguator.java

    r3243 r3246  
    7070import com.sun.fortress.nodes.Op; 
    7171import com.sun.fortress.nodes.OpArg; 
     72import com.sun.fortress.nodes.ASTNodeInfo; 
    7273import com.sun.fortress.nodes.StaticArg; 
    7374import com.sun.fortress.nodes.StaticParam; 
     
    154155                v.recurOnListOfTraitTypeWhere(NodeUtil.getExtendsClause(that)), 
    155156                v.recurOnListOfDecl(NodeUtil.getDecls(that))); 
    156         return forTraitDeclOnly(that, header, 
     157        return forTraitDeclOnly(that, that.getInfo(), header, 
    157158                v.recurOnListOfBaseType(NodeUtil.getExcludesClause(that)), 
    158159                v.recurOnOptionOfListOfBaseType(NodeUtil.getComprisesClause(that))); 
     
    174175                v.recurOnListOfDecl(NodeUtil.getDecls(that))); 
    175176 
    176         return forObjectDeclOnly(that, header, 
     177        return forObjectDeclOnly(that, that.getInfo(), header, 
    177178                v.recurOnOptionOfListOfParam(NodeUtil.getParams(that))); 
    178179    } 
     
    194195                v.recurOnOptionOfType(NodeUtil.getReturnType(that))); 
    195196 
    196         return forFnDeclOnly(that, header, 
     197        return forFnDeclOnly(that, that.getInfo(), header, 
    197198                that.getUnambiguousName(), 
    198199                v.recurOnOptionOfExpr(NodeUtil.getBody(that)), 
     
    471472 
    472473    @Override public Node forSuperSyntaxDefOnly(SuperSyntaxDef that, 
     474                                                ASTNodeInfo info, 
    473475                                                Id nonterminal_result, Id grammar_result) { 
    474476        Id disambiguatedGrammar = handleGrammarName(grammar_result); 
    475         return new SuperSyntaxDef(NodeUtil.getSpan(that), 
     477        return new SuperSyntaxDef(info, 
    476478                                  that.getModifier(), nonterminal_result, disambiguatedGrammar); 
    477479    } 
    478480 
    479481    @Override 
    480     public Node forGrammarDeclOnly(GrammarDecl that, Id name_result, 
     482    public Node forGrammarDeclOnly(GrammarDecl that, 
     483                                   ASTNodeInfo info, Id name_result, 
    481484            List<Id> extends_result, 
    482485            List<GrammarMemberDecl> members_result, 
     
    487490        Id name = handleGrammarName(name_result); 
    488491 
    489         GrammarDecl disambiguatedGrammar = new GrammarDecl(NodeUtil.getSpan(that), 
     492        GrammarDecl disambiguatedGrammar = new GrammarDecl(info, 
    490493                                                           name, p.first(), members_result, transformers, that.isNativeDef()); 
    491494 
     
    559562//        System.err.println("t: "+t); 
    560563        return forNonterminalHeaderOnly(that, 
     564                                        that.getInfo(), 
    561565            (Id) that.getName().accept(v), 
    562566            v.recurOnListOfNonterminalParameter(that.getParams()), 
     
    571575    @Override 
    572576        public Node forTypeArgOnly(final TypeArg arg, 
     577                                   ASTNodeInfo info, 
    573578                                   final Type t) { 
    574579        if(arg.getTypeArg() instanceof VarType){ 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/InferenceVarInserter.java

    r3225 r3246  
    3131import com.sun.fortress.nodes.Param; 
    3232import com.sun.fortress.nodes.StaticParam; 
     33import com.sun.fortress.nodes.ASTNodeInfo; 
    3334import com.sun.fortress.nodes.Type; 
    3435import com.sun.fortress.nodes.WhereClause; 
     
    4647 
    4748        @Override 
    48         public Node forLValueOnly(LValue that, Id name_result, 
     49            public Node forLValueOnly(LValue that, ASTNodeInfo info, 
     50                                  Id name_result, 
    4951                                  Option<Type> type_result) { 
    5052                if( type_result.isNone() ) { 
     
    7274        Option<Expr> body_result = recurOnOptionOfExpr(that.getBody()); 
    7375        Option<Id> implementsUnambiguousName_result = recurOnOptionOfId(that.getImplementsUnambiguousName()); 
    74         return  forFnDeclOnly(that, name_result, staticParams_result, params_result, 
     76        return  forFnDeclOnly(that, that.getInfo(), name_result, staticParams_result, params_result, 
    7577                              returnType_result, throwsClause_result, 
    7678                              where_result, contract_result, unambiguousName_result, 
     
    7981 
    8082    public Node forFnDeclOnly(FnDecl that, 
     83                              ASTNodeInfo info, 
    8184                              IdOrOpOrAnonymousName name_result, 
    8285                              List<StaticParam> staticParams_result, List<Param> params_result, 
     
    100103                                                    contract_result, 
    101104                                                    params_result, new_ret_type); 
    102         return super.forFnDeclOnly(that, header, unambiguousName_result, 
     105        return super.forFnDeclOnly(that, info, header, unambiguousName_result, 
    103106                                   body_result, implementsUnambiguousName_result); 
    104107    } 
    105108 
    106109        @Override 
    107         public Node forParamOnly(Param that, Id name_result, 
     110            public Node forParamOnly(Param that, ASTNodeInfo info, Id name_result, 
    108111                                 Option<Type> type_result, 
    109112                                 Option<Expr> defaultExpr_result, 
     
    116119                                                type_result; 
    117120 
    118                 return super.forParamOnly(that, name_result, new_type, 
     121                return super.forParamOnly(that, info, name_result, new_type, 
    119122                                          defaultExpr_result, varargsType_result); 
    120123            } else 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeAnalyzer.java

    r3239 r3246  
    356356 
    357357            @Override public Effect forEffectOnly(Effect e, 
     358                                                  ASTNodeInfo info_result, 
    358359                                                  Option<List<BaseType>> normalThrows) { 
    359360                if (normalThrows.isNone()) { return e; } 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeChecker.java

    r3241 r3246  
    20312031        @Override 
    20322032        public TypeCheckerResult forComponentOnly(Component that, 
     2033                                                  TypeCheckerResult info, 
    20332034                                                  TypeCheckerResult name_result, 
    20342035                                                  List<TypeCheckerResult> imports_result, 
     
    20532054        @Override 
    20542055        public TypeCheckerResult forContractOnly(Contract that, 
     2056                                                 TypeCheckerResult info, 
    20552057                        Option<List<TypeCheckerResult>> requires_result, 
    20562058                        Option<List<TypeCheckerResult>> ensures_result, 
     
    28692871        @Override 
    28702872        public TypeCheckerResult forIntArgOnly(IntArg that, 
     2873                                               TypeCheckerResult info, 
    28712874                                               TypeCheckerResult val_result) { 
    28722875                return new TypeCheckerResult(that); 
     
    34473450        @Override 
    34483451        public TypeCheckerResult forIntBaseOnly(IntBase that, 
     3452                                                TypeCheckerResult info, 
    34493453                                                TypeCheckerResult val_result) { 
    34503454                return new TypeCheckerResult(that); 
  • trunk/ProjectFortress/src/com/sun/fortress/nodes_util/ExprFactory.java

    r3242 r3246  
    4646    public static AmbiguousMultifixOpExpr makeAmbiguousMultifixOpExpr(AmbiguousMultifixOpExpr that, 
    4747                                                                      boolean parenthesized) { 
    48         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, NodeUtil.getExprType(that)); 
    49         return makeAmbiguousMultifixOpExpr(NodeUtil.getSpan(that), info, 
    50                                            that.getInfix_op(), that.getMultifix_op(), 
     48        ExprInfo info = NodeFactory.makeExprInfo(NodeUtil.getSpan(that), parenthesized, NodeUtil.getExprType(that)); 
     49        return makeAmbiguousMultifixOpExpr(info, that.getInfix_op(), that.getMultifix_op(), 
    5150                                           that.getArgs()); 
    5251    } 
     
    5655                                                                      FunctionalRef multifix_op, 
    5756                                                                      List<Expr> args) { 
    58         ExprInfo info = NodeFactory.makeExprInfo(false, Option.<Type>none()); 
    59         return makeAmbiguousMultifixOpExpr(span, info, infix_op, multifix_op, 
     57        ExprInfo info = NodeFactory.makeExprInfo(span, false, Option.<Type>none()); 
     58        return makeAmbiguousMultifixOpExpr(info, infix_op, multifix_op, 
    6059                                           args); 
    6160    } 
    6261 
    63     public static AmbiguousMultifixOpExpr makeAmbiguousMultifixOpExpr(Span span, 
    64                                                                       ExprInfo info, 
     62    public static AmbiguousMultifixOpExpr makeAmbiguousMultifixOpExpr(ExprInfo info, 
    6563                                                                      FunctionalRef infix_op, 
    6664                                                                      FunctionalRef multifix_op, 
    6765                                                                      List<Expr> args) { 
    68         return new AmbiguousMultifixOpExpr(span, info, infix_op, multifix_op, args); 
     66        return new AmbiguousMultifixOpExpr(info, infix_op, multifix_op, args); 
    6967    } 
    7068 
     
    7876                                                List<StaticArg> staticArgs, 
    7977                                                Expr elem) { 
    80         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    81         return new ArrayElement(span, info, staticArgs, elem); 
     78        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     79        return new ArrayElement(info, staticArgs, elem); 
    8280    } 
    8381 
     
    110108                                                  List<ArrayExpr> elems, 
    111109                                                  boolean outermost) { 
    112         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    113         return new ArrayElements(span, info, staticArgs, dim, elems, 
     110        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     111        return new ArrayElements(info, staticArgs, dim, elems, 
    114112                                 outermost); 
    115113    } 
     
    125123                                              FunctionalRef infix, Expr front, 
    126124                                              List<MathItem> rest) { 
    127         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    128         return new MathPrimary(span, info, multi, infix, front, rest); 
     125        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     126        return new MathPrimary(info, multi, infix, front, rest); 
    129127    } 
    130128 
     
    166164                                                        List<StaticArg> staticArgs, 
    167165                                                        Expr expr) { 
    168         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    169         return new MethodInvocation(span, info, obj, field, staticArgs, expr); 
     166        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     167        return new MethodInvocation(info, obj, field, staticArgs, expr); 
    170168    } 
    171169 
     
    230228                                    Option<Type> ty, FunctionalRef op, 
    231229                                    List<Expr> exprs) { 
    232         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    233         return new OpExpr(span, info, op, exprs); 
     230        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     231        return new OpExpr(info, op, exprs); 
    234232    } 
    235233 
     
    281279                                List<Expr> exprs, boolean isFnApp, 
    282280                                boolean tight) { 
    283         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    284         return new Juxt(span, info, multi, infix, exprs, isFnApp, tight); 
     281        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     282        return new Juxt(info, multi, infix, exprs, isFnApp, tight); 
    285283    } 
    286284 
     
    288286                                                  Option<Type> ty, Expr expr, 
    289287                                                  List<StaticArg> sargs) { 
    290         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    291         return make_RewriteFnRef(span, info, expr, sargs); 
    292     } 
    293  
    294     public static _RewriteFnRef make_RewriteFnRef(Span span, ExprInfo info, 
     288        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     289        return make_RewriteFnRef(info, expr, sargs); 
     290    } 
     291 
     292    public static _RewriteFnRef make_RewriteFnRef(ExprInfo info, 
    295293                                                  Expr expr, 
    296294                                                  List<StaticArg> sargs) { 
    297         return new _RewriteFnRef(span, info, expr, sargs); 
     295        return new _RewriteFnRef(info, expr, sargs); 
    298296    } 
    299297 
     
    384382                                  Option<List<FunctionalRef>> overloadings, 
    385383                                  Option<Type> overloadingType) { 
    386         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    387         return new FnRef(span, info, staticArgs, 
     384        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     385        return new FnRef(info, staticArgs, 
    388386                         lexicalDepth, name, names, overloadings, overloadingType); 
    389387    } 
     
    428426                                          Option<List<FunctionalRef>> overloadings, 
    429427                                          Option<Type> overloadingType) { 
    430         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    431         return new OpRef(span, info, staticArgs, 
     428        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     429        return new OpRef(info, staticArgs, 
    432430                         lexicalDepth, name, names, overloadings, overloadingType); 
    433431    } 
    434432 
    435433    public static _RewriteObjectExprRef make_RewriteObjectExprRef(_RewriteObjectExpr rwoe) { 
    436         return new _RewriteObjectExprRef(NodeUtil.getSpan(rwoe), rwoe.getInfo(), 
     434        return new _RewriteObjectExprRef(rwoe.getInfo(), 
    437435                                         rwoe.getGenSymName(), rwoe.getStaticArgs()); 
    438436    } 
     
    515513                                    Option<Type> ty, Id varId, 
    516514                                    List<StaticArg> staticArgs, int lexicalDepth) { 
    517         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    518         return new VarRef(span, info, varId, staticArgs, 
     515        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     516        return new VarRef(info, varId, staticArgs, 
    519517                          lexicalDepth); 
    520518    } 
     
    573571                                                    String text, 
    574572                                                    BigInteger intVal) { 
    575         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    576         return new IntLiteralExpr(span, info, text, intVal); 
     573        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     574        return new IntLiteralExpr(info, text, intVal); 
    577575    } 
    578576 
     
    587585                                                      String text, 
    588586                                                      int charVal) { 
    589         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    590         return new CharLiteralExpr(span, info, text, charVal); 
     587        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     588        return new CharLiteralExpr(info, text, charVal); 
    591589    } 
    592590 
     
    599597                                                      Option<Type> ty, 
    600598                                                      String text) { 
    601         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    602         return new VoidLiteralExpr(span, info, text); 
     599        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     600        return new VoidLiteralExpr(info, text); 
    603601    } 
    604602 
     
    646644                                                  Option<Op> op, 
    647645                                                  List<StaticArg> staticArgs) { 
    648         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    649         return new SubscriptExpr(span, info, obj, subs, op, staticArgs); 
     646        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     647        return new SubscriptExpr(info, obj, subs, op, staticArgs); 
    650648    } 
    651649 
     
    708706                                                List<LValue> lhs, 
    709707                                                Option<Expr> rhs) { 
    710         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    711         return new LocalVarDecl(span, info, body, lhs, rhs); 
     708        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     709        return new LocalVarDecl(info, body, lhs, rhs); 
    712710    } 
    713711 
     
    730728                                    Expr body) { 
    731729        return makeFnExpr(span, false, Option.<Type>none(), 
    732                           new AnonymousFnName(span, Option.<APIName>none()), 
     730                          makeAnonymousFnName(span, Option.<APIName>none()), 
    733731                          Collections.<StaticParam>emptyList(), params, 
    734732                          returnType, Option.<WhereClause>none(), 
     
    750748                                                   Option.<Contract>none(), params, 
    751749                                                   returnType); 
    752         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    753         return new FnExpr(span, info, header, body); 
     750        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     751        return new FnExpr(info, header, body); 
     752    } 
     753 
     754    public static AnonymousFnName makeAnonymousFnName(Span span, Option<APIName> api) { 
     755        ExprInfo info = NodeFactory.makeExprInfo(span); 
     756        return new AnonymousFnName(info, api); 
    754757    } 
    755758 
     
    773776                                Option<Id> targetOp, 
    774777                                Option<Expr> retExpr) { 
    775         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    776         return new Exit(span, info, targetOp, retExpr); 
     778        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     779        return new Exit(info, targetOp, retExpr); 
    777780    } 
    778781 
     
    789792                                                            List<StaticArg> staticArgs, 
    790793                                                            List<ArrayComprehensionClause> clauses) { 
    791         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    792         return new ArrayComprehension(span, info, staticArgs, clauses); 
     794        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     795        return new ArrayComprehension(info, staticArgs, clauses); 
    793796    } 
    794797 
     
    809812                                              List<GeneratorClause> gens, 
    810813                                              Expr body) { 
    811         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    812         return new Accumulator(span, info, staticArgs, accOp, gens, body); 
     814        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     815        return new Accumulator(info, staticArgs, accOp, gens, body); 
    813816    } 
    814817 
     
    834837                                        List<TypecaseClause> clauses, 
    835838                                        Option<Block> elseClause) { 
    836         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    837         return new Typecase(span, info, bindIds, bindExpr, clauses, elseClause); 
     839        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     840        return new Typecase(info, bindIds, bindExpr, clauses, elseClause); 
    838841    } 
    839842 
     
    859862                                          List<KeywordExpr> keywords, 
    860863                                          boolean inApp) { 
    861         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    862         return new TupleExpr(span, info, exprs, varargs, keywords, inApp); 
     864        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     865        return new TupleExpr(info, exprs, varargs, keywords, inApp); 
    863866    } 
    864867 
     
    879882                              List<BaseType> forbidClause, 
    880883                              Option<Block> finallyClause) { 
    881         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    882         return new Try(span, info, body, catchClause, forbidClause, finallyClause); 
     884        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     885        return new Try(info, body, catchClause, forbidClause, finallyClause); 
    883886    } 
    884887 
     
    904907                                            Option<Type> ty, 
    905908                                            TraitTypeHeader header) { 
    906         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    907         return new ObjectExpr(span, info, header); 
     909        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     910        return new ObjectExpr(info, header); 
    908911    } 
    909912 
     
    960963                                                            List<StaticArg> staticArgs, 
    961964                                                            Option<List<Param>> params) { 
    962         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    963         return new _RewriteObjectExpr(span, info, header, 
     965        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     966        return new _RewriteObjectExpr(info, header, 
    964967                                      implicitTypeParameters, genSymName, 
    965968                                      staticArgs, params); 
     
    9991002                                            Expr rhs, 
    10001003                                            Option<List<FunctionalRef>> opsForLhs) { 
    1001         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    1002         return new Assignment(span, info, lhs, assignOp, rhs, opsForLhs); 
     1004        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     1005        return new Assignment(info, lhs, assignOp, rhs, opsForLhs); 
    10031006    } 
    10041007 
     
    10391042                                  boolean withinDo, 
    10401043                                  List<Expr> exprs) { 
    1041         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    1042         return new Block(span, info, loc, atomicBlock, withinDo, exprs); 
     1044        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     1045        return new Block(info, loc, atomicBlock, withinDo, exprs); 
    10431046    } 
    10441047 
     
    10751078    public static If makeIf(Span sp, Expr cond, Block _then, Block _else) { 
    10761079        return makeIf(sp, 
    1077                       new IfClause(NodeFactory.makeSpan(cond, _else), 
     1080                      new IfClause(NodeFactory.makeSpanInfo(NodeFactory.makeSpan(cond, _else)), 
    10781081                                   makeGeneratorClause(NodeUtil.getSpan(cond), cond), 
    10791082                                   _then), 
     
    10831086    public static If makeIf(Span sp, Expr cond, Block _then) { 
    10841087        return makeIf(sp, 
    1085                       new IfClause(NodeFactory.makeSpan(cond, _then), 
     1088                      new IfClause(NodeFactory.makeSpanInfo(NodeFactory.makeSpan(cond, _then)), 
    10861089                                   makeGeneratorClause(NodeUtil.getSpan(cond), cond), 
    10871090                                   _then)); 
     
    10931096                            List<IfClause> clauses, 
    10941097                            Option<Block> elseClause) { 
    1095         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    1096         return new If(span, info, clauses, elseClause); 
     1098        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     1099        return new If(info, clauses, elseClause); 
    10971100    } 
    10981101 
     
    11161119                                        List<CaseClause> clauses, 
    11171120                                        Option<Block> elseClause) { 
    1118         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    1119         return new CaseExpr(span, info, param, compare, 
     1121        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     1122        return new CaseExpr(info, param, compare, 
    11201123                            equalsOp, inOp, clauses, elseClause); 
    11211124    } 
     
    11231126    public static ChainExpr makeChainExpr(Expr e, Op _op, Expr _expr) { 
    11241127        List<Link> links = new ArrayList<Link>(1); 
    1125         Link link = new Link(NodeFactory.makeSpan(_op, _expr), makeOpRef(NodeFactory.makeOpInfix(_op)), _expr); 
     1128        Link link = new Link(NodeFactory.makeSpanInfo(NodeFactory.makeSpan(_op, _expr)), 
     1129                             makeOpRef(NodeFactory.makeOpInfix(_op)), _expr); 
    11261130        links.add(link); 
    11271131        return makeChainExpr(NodeFactory.makeSpan(e, _expr), e, links); 
     
    11301134    public static ChainExpr makeChainExpr(Span sp, Expr e, Op _op, Expr _expr) { 
    11311135        List<Link> links = new ArrayList<Link>(1); 
    1132         Link link = new Link(NodeFactory.makeSpan(_op, _expr), 
     1136        Link link = new Link(NodeFactory.makeSpanInfo(NodeFactory.makeSpan(_op, _expr)), 
    11331137                             makeOpRef(NodeFactory.makeOpInfix(_op)), _expr); 
    11341138        links.add(link); 
     
    11451149                                          Option<Type> ty, 
    11461150                                          Expr first, List<Link> links) { 
    1147         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    1148         return new ChainExpr(span, info, first, links); 
     1151        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     1152        return new ChainExpr(info, first, links); 
    11491153    } 
    11501154 
     
    11591163                                                  Expr function, 
    11601164                                                  Expr argument) { 
    1161         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    1162         return new _RewriteFnApp(span, info, function, argument); 
     1165        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     1166        return new _RewriteFnApp(info, function, argument); 
    11631167    } 
    11641168 
     
    11911195                                        Option<Type> ty, 
    11921196                                        Expr obj, Id field) { 
    1193         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    1194         return new FieldRef(span, info, obj, field); 
     1197        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     1198        return new FieldRef(info, obj, field); 
    11951199    } 
    11961200 
     
    12031207                                            Option<Type> ty, 
    12041208                                            Expr expr) { 
    1205         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    1206         return new AtomicExpr(span, info, expr); 
     1209        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     1210        return new AtomicExpr(info, expr); 
    12071211    } 
    12081212 
     
    12181222                              List<GeneratorClause> gens, 
    12191223                              Block body) { 
    1220         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    1221         return new For(span, info, gens, body); 
     1224        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     1225        return new For(info, gens, body); 
    12221226    } 
    12231227 
     
    12311235                                  Option<Type> ty, 
    12321236                                  Expr body) { 
    1233         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    1234         return new Spawn(span, info, body); 
     1237        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     1238        return new Spawn(info, body); 
    12351239    } 
    12361240 
     
    12451249                                                  Option<Type> ty, 
    12461250                                                  Expr expr) { 
    1247         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    1248         return new TryAtomicExpr(span, info, expr); 
     1251        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     1252        return new TryAtomicExpr(info, expr); 
    12491253    } 
    12501254 
     
    12611265                                  List<Expr> body, 
    12621266                                  List<FnDecl> fns) { 
    1263         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    1264         return new LetFn(span, info, body, fns); 
     1267        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     1268        return new LetFn(info, body, fns); 
    12651269    } 
    12661270 
     
    12791283                                  Option<Type> ty, 
    12801284                                  Expr expr) { 
    1281         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    1282         return new Throw(span, info, expr); 
     1285        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     1286        return new Throw(info, expr); 
    12831287    } 
    12841288 
     
    12911295                                                          Option<Type> ty, 
    12921296                                                          String text) { 
    1293         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    1294         return new StringLiteralExpr(span, info, text); 
     1297        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     1298        return new StringLiteralExpr(info, text); 
    12951299    } 
    12961300 
     
    13031307                                                        int denomBase, 
    13041308                                                        int denomPower) { 
    1305         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    1306         return new FloatLiteralExpr(span, info, text, 
     1309        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     1310        return new FloatLiteralExpr(info, text, 
    13071311                                    intPart, numerator, denomBase, denomPower); 
    13081312    } 
     
    13171321                                    Option<Type> ty, 
    13181322                                    Expr expr, Type annType) { 
    1319         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    1320         return new AsExpr(span, info, expr, annType); 
     1323        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     1324        return new AsExpr(info, expr, annType); 
    13211325    } 
    13221326 
     
    13301334                                        Option<Type> ty, 
    13311335                                        Expr expr, Type annType) { 
    1332         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    1333         return new AsIfExpr(span, info, expr, annType); 
     1336        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     1337        return new AsIfExpr(info, expr, annType); 
    13341338    } 
    13351339 
     
    13521356                                  GeneratorClause testExpr, 
    13531357                                  Do body) { 
    1354         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    1355         return new While(span, info, testExpr, body); 
     1358        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     1359        return new While(info, testExpr, body); 
    13561360    } 
    13571361 
     
    13651369                                  Option<Type> ty, 
    13661370                                  Id name, Block body) { 
    1367         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    1368         return new Label(span, info, name, body); 
     1371        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     1372        return new Label(info, name, body); 
    13691373    } 
    13701374 
     
    13911395                            Option<Type> ty, 
    13921396                            List<Block> fronts) { 
    1393         ExprInfo info = NodeFactory.makeExprInfo(parenthesized, ty); 
    1394         return new Do(span, info, fronts); 
     1397        ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 
     1398        return new Do(info, fronts); 
    13951399    } 
    13961400 
     
    15041508 
    15051509    public static GeneratorClause makeGeneratorClause(Span span, 
    1506             Iterable<Id> ids, 
    1507             Expr expr) { 
    1508         return new GeneratorClause(span, CollectUtil.makeList(ids), expr); 
     1510                                                      Iterable<Id> ids, 
     1511                                                      Expr expr) { 
     1512        return new GeneratorClause(NodeFactory.makeSpanInfo(span), CollectUtil.makeList(ids), expr); 
    15091513    } 
    15101514 
    15111515    public static GeneratorClause makeGeneratorClause(Span span, Expr cond) { 
    1512         return new GeneratorClause(span, Collections.<Id>emptyList(), cond); 
     1516        return new GeneratorClause(NodeFactory.makeSpanInfo(span), Collections.<Id>emptyList(), cond); 
    15131517    } 
    15141518 
     
    17351739        } 
    17361740        public Expr forTemplateGapExpr(TemplateGapExpr e) { 
    1737             return new TemplateGapExpr(NodeUtil.getSpan(e), e.getGapId(), e.getTemplateParams()); 
     1741            return new TemplateGapExpr(NodeFactory.makeExprInfo(NodeUtil.getSpan(e)), 
     1742                                       e.getGapId(), e.getTemplateParams()); 
    17381743        } 
    17391744 
     
    18241829 
    18251830    public static TemplateGapExpr makeTemplateGapExpr(Span s, Id id, List<Id> params) { 
    1826         return new TemplateGapExpr(s, id, params); 
     1831        return new TemplateGapExpr(NodeFactory.makeExprInfo(s), id, params); 
    18271832    } 
    18281833 
    18291834    public static TemplateGapSimpleExpr makeTemplateGapSimpleExpr(Span s, Id id, List<Id> params) { 
    1830         return new TemplateGapSimpleExpr(s, id, params); 
     1835        return new TemplateGapSimpleExpr(NodeFactory.makeExprInfo(s), id, params); 
    18311836    } 
    18321837 
    18331838    public static TemplateGapPrimary makeTemplateGapPrimary(Span s, Id id, List<Id> params) { 
    1834         return new TemplateGapPrimary(s, id, params); 
     1839        return new TemplateGapPrimary(NodeFactory.makeExprInfo(s), id, params); 
    18351840    } 
    18361841 
    18371842    public static TemplateGapFnExpr makeTemplateGapFnExpr(Span s, Id id, List<Id> params) { 
    18381843        Expr body = makeVarRef(id); 
    1839         return new TemplateGapFnExpr(s, id, params); 
     1844        return new TemplateGapFnExpr(NodeFactory.makeExprInfo(s), id, params); 
    18401845    } 
    18411846 
    18421847    public static TemplateGapJuxt makeTemplateGapJuxt(Span s, Id id, List<Id> params) { 
    1843         return new TemplateGapJuxt(s, id, params); 
     1848        return new TemplateGapJuxt(NodeFactory.makeExprInfo(s), id, params); 
    18441849    } 
    18451850 
    18461851    public static TemplateGapName makeTemplateGapName(Span s, Id id, List<Id> params) { 
    1847         return new TemplateGapName(s, id, params); 
     1852        return new TemplateGapName(NodeFactory.makeSpanInfo(s), id, params); 
    18481853    } 
    18491854 
    18501855    public static TemplateGapId makeTemplateGapId(Span s, Id id, List<Id> params) { 
    1851         return new TemplateGapId(s, id, params); 
     1856        return new TemplateGapId(NodeFactory.makeSpanInfo(s), id, params); 
    18521857    } 
    18531858 
    18541859    public static TemplateGapLiteralExpr makeTemplateGapLiteralExpr(Span s, Id id, List<Id> params) { 
    1855         return new TemplateGapLiteralExpr(s, id, params); 
     1860        return new TemplateGapLiteralExpr(NodeFactory.makeExprInfo(s), id, params); 
    18561861    } 
    18571862 
    18581863    public static TemplateGapNumberLiteralExpr makeTemplateGapNumberLiteralExpr(Span s, Id id, List<Id> params) { 
    1859         return new TemplateGapNumberLiteralExpr(s, id, params); 
     1864        return new TemplateGapNumberLiteralExpr(NodeFactory.makeExprInfo(s), id, params); 
    18601865    } 
    18611866 
    18621867    public static TemplateGapFloatLiteralExpr makeTemplateGapFloatLiteralExpr(Span s, Id id, List<Id> params) { 
    1863         return new TemplateGapFloatLiteralExpr(s, id, params); 
     1868        return new TemplateGapFloatLiteralExpr(NodeFactory.makeExprInfo(s), id, params); 
    18641869    } 
    18651870 
    18661871    public static TemplateGapIntLiteralExpr makeTemplateGapIntLiteralExpr(Span s, Id id, List<Id> params) { 
    1867         return new TemplateGapIntLiteralExpr(s, id, params); 
     1872        return new TemplateGapIntLiteralExpr(NodeFactory.makeExprInfo(s), id, params); 
    18681873    } 
    18691874 
    18701875    public static TemplateGapCharLiteralExpr makeTemplateGapCharLiteralExpr(Span s, Id id, List<Id> params) { 
    1871         return new TemplateGapCharLiteralExpr(s, id, params); 
     1876        return new TemplateGapCharLiteralExpr(NodeFactory.makeExprInfo(s), id, params); 
    18721877    } 
    18731878 
    18741879    public static TemplateGapStringLiteralExpr makeTemplateGapStringLiteralExpr(Span s, Id id, List<Id> params) { 
    1875         return new TemplateGapStringLiteralExpr(s, id, params); 
     1880        return new TemplateGapStringLiteralExpr(NodeFactory.makeExprInfo(s), id, params); 
    18761881    } 
    18771882 
    18781883    public static TemplateGapVoidLiteralExpr makeTemplateGapVoidLiteralExpr(Span s, Id id, List<Id> params) { 
    1879         return new TemplateGapVoidLiteralExpr(s, id, params); 
     1884        return new TemplateGapVoidLiteralExpr(NodeFactory.makeExprInfo(s), id, params); 
    18801885    } 
    18811886 
  • trunk/ProjectFortress/src/com/sun/fortress/nodes_util/NodeFactory.java

    r3243 r3246  
    148148    } 
    149149 
    150     public static Span makeSpanInfo(Span span) { return span; } 
     150    public static ASTNodeInfo makeASTNodeInfo() { return new SpanInfo(new Span()); } 
     151 
     152    public static SpanInfo makeSpanInfo(Span span) { return new SpanInfo(span); } 
     153 
     154    public static SpanInfo makeSpanInfo(SpanInfo info, Span span) { 
     155        return new SpanInfo(span); 
     156    } 
    151157 
    152158    public static Component makeComponent(Span span, APIName name, 
     
    162168                                          boolean isNative, 
    163169                                          List<APIName> exports) { 
    164         return new Component(span, name, imports, decls, isNative, exports); 
     170        return new Component(makeSpanInfo(span), name, imports, decls, isNative, exports); 
    165171    } 
    166172 
     
    189195 
    190196    public static AliasedSimpleName makeAliasedSimpleName(IdOrOpOrAnonymousName name) { 
    191         return new AliasedSimpleName(NodeUtil.getSpan(name), name, 
     197        return makeAliasedSimpleName(NodeUtil.getSpan(name), name, 
    192198                                     Option.<IdOrOpOrAnonymousName>none()); 
    193199    } 
     
    195201    public static AliasedSimpleName makeAliasedSimpleName(IdOrOpOrAnonymousName name, 
    196202                                                          IdOrOpOrAnonymousName alias) { 
    197         return new AliasedSimpleName(FortressUtil.spanTwo(name, alias), name, 
     203        return makeAliasedSimpleName(FortressUtil.spanTwo(name, alias), name, 
    198204                                     Option.<IdOrOpOrAnonymousName>some(alias)); 
    199205    } 
    200206 
     207    public static AliasedSimpleName makeAliasedSimpleName(Span span, 
     208                                                          IdOrOpOrAnonymousName name, 
     209                                                          Option<IdOrOpOrAnonymousName> alias) { 
     210        return new AliasedSimpleName(makeSpanInfo(span), name, alias); 
     211    } 
     212 
    201213    public static AliasedAPIName makeAliasedAPIName(APIName api) { 
    202         return new AliasedAPIName(NodeUtil.getSpan(api), api, Option.<Id>none()); 
     214        return makeAliasedAPIName(NodeUtil.getSpan(api), api, Option.<Id>none()); 
    203215    } 
    204216 
    205217    public static AliasedAPIName makeAliasedAPIName(APIName api, Id alias) { 
    206         return new AliasedAPIName(FortressUtil.spanTwo(api, alias), api, 
     218        return makeAliasedAPIName(FortressUtil.spanTwo(api, alias), api, 
    207219                                  Option.<Id>some(alias)); 
     220    } 
     221 
     222    public static AliasedAPIName makeAliasedAPIName(Span span, APIName api, 
     223                                                    Option<Id> alias) { 
     224        return new AliasedAPIName(makeSpanInfo(span), api, alias); 
    208225    } 
    209226 
     
    229246                                                     Option.<Contract>none(), 
    230247                                                     extendsC, decls); 
    231         return new TraitDecl(span, header, excludesC, comprisesC); 
     248        return new TraitDecl(makeSpanInfo(span), header, excludesC, comprisesC); 
    232249    } 
    233250 
     
    278295                                                     throwsC, contract, extendsC, 
    279296                                                     decls); 
    280         return new ObjectDecl(span, header, params); 
     297        return new ObjectDecl(makeSpanInfo(span), header, params); 
    281298    } 
    282299 
     
    360377        FnHeader header = makeFnHeader(mods, name, staticParams, whereC, throwsC, 
    361378                                       contract, params, returnType); 
    362         return new FnDecl(span, header, unambiguousName, body, implementsUnambiguousName); 
     379        return new FnDecl(makeSpanInfo(span), header, unambiguousName, body, implementsUnambiguousName); 
    363380    } 
    364381 
     
    369386    public static DimDecl makeDimDecl(Span span, Id dim, Option<Type> derived, 
    370387                                      Option<Id> defaultId) { 
    371         return new DimDecl(span, dim, derived, defaultId); 
     388        return new DimDecl(makeSpanInfo(span), dim, derived, defaultId); 
    372389    } 
    373390 
    374391    public static UnitDecl makeUnitDecl(Span span, boolean si_unit, List<Id> units, 
    375392                                        Option<Type> dim, Option<Expr> def) { 
    376         return new UnitDecl(span, si_unit, units, dim, def); 
     393        return new UnitDecl(makeSpanInfo(span), si_unit, units, dim, def); 
    377394    } 
    378395 
     
    466483    public static LValue makeLValue(Span span, Id name, Modifiers mods, 
    467484                                    Option<Type> type, boolean mutable) { 
    468         return new LValue(span, name, mods, type, mutable); 
     485        return new LValue(makeSpanInfo(span), name, mods, type, mutable); 
    469486    } 
    470487 
     
    541558                                  Option<Type> type, Option<Expr> expr, 
    542559                                  Option<Type> varargsType) { 
    543         return new Param(span, name, mods, type, expr, varargsType); 
    544     } 
    545  
    546     /** temporary hack!!! **/ 
    547     public static Span makeExprInfo(Span span) { 
    548         return span; 
    549     } 
    550     /** temporary hack!!! **/ 
    551     public static ExprInfo makeExprInfo(Span span, 
    552                                         boolean parenthesized, 
     560        return new Param(makeSpanInfo(span), name, mods, type, expr, varargsType); 
     561    } 
     562 
     563    public static ExprInfo makeExprInfo(ExprInfo org, Span span) { 
     564        return makeExprInfo(span, org.isParenthesized(), org.getExprType()); 
     565    } 
     566 
     567    public static ExprInfo makeExprInfo() { 
     568        return makeExprInfo(new Span()); 
     569    } 
     570 
     571    public static ExprInfo makeExprInfo(Span span) { 
     572        return makeExprInfo(span, false); 
     573    } 
     574 
     575    public static ExprInfo makeExprInfo(Span span, boolean parenthesized) { 
     576        return makeExprInfo(span, parenthesized, 
     577                            Option.<Type>none()); 
     578    } 
     579 
     580    public static ExprInfo makeExprInfo(Span span, boolean parenthesized, 
    553581                                        Option<Type> ty) { 
    554         return makeExprInfo(parenthesized, ty); 
    555     } 
    556  
    557     public static ExprInfo makeExprInfo() { 
    558         return makeExprInfo(false); 
    559     } 
    560  
    561     public static ExprInfo makeExprInfo(boolean parenthesized) { 
    562         return makeExprInfo(parenthesized, 
    563                             Option.<Type>none()); 
    564     } 
    565  
    566     public static ExprInfo makeExprInfo(boolean parenthesized, 
    567                                         Option<Type> ty) { 
    568         return new ExprInfo(parenthesized, ty); 
    569     } 
    570  
    571     /** temporary hack!!! **/ 
    572     public static Span makeTypeInfo(Span span) { 
    573         return span; 
    574     } 
    575     /** temporary hack!!! **/ 
    576     public static TypeInfo makeTypeInfo(Span span, 
    577                                         boolean parenthesized, 
     582        return new ExprInfo(span, parenthesized, ty); 
     583    } 
     584 
     585    public static TypeInfo makeTypeInfo(TypeInfo org, Span span) { 
     586        return makeTypeInfo(span, org.isParenthesized(), org.getStaticParams(), 
     587                            org.getWhereClause()); 
     588    } 
     589 
     590    public static TypeInfo makeTypeInfo() { 
     591        return makeTypeInfo(new Span()); 
     592    } 
     593 
     594    public static TypeInfo makeTypeInfo(Span span) { 
     595        return makeTypeInfo(span, false); 
     596    } 
     597 
     598    public static TypeInfo makeTypeInfo(Span span, boolean parenthesized) { 
     599        return makeTypeInfo(span, parenthesized, 
     600                            Collections.<StaticParam>emptyList(), 
     601                            Option.<WhereClause>none()); 
     602    } 
     603 
     604    public static TypeInfo makeTypeInfo(Span span, boolean parenthesized, 
    578605                                        List<StaticParam> sparams, 
    579606                                        Option<WhereClause> where) { 
    580         return makeTypeInfo(parenthesized, sparams, where); 
    581     } 
    582  
    583     public static TypeInfo makeTypeInfo() { 
    584         return makeTypeInfo(false); 
    585     } 
    586  
    587     public static TypeInfo makeTypeInfo(boolean parenthesized) { 
    588         return makeTypeInfo(parenthesized, 
    589                             Collections.<StaticParam>emptyList(), 
    590                             Option.<WhereClause>none()); 
    591     } 
    592  
    593     public static TypeInfo makeTypeInfo(boolean parenthesized, 
    594                                         List<StaticParam> sparams, 
    595                                         Option<WhereClause> where) { 
    596         return new TypeInfo(parenthesized, sparams, where); 
     607        return new TypeInfo(span, parenthesized, sparams, where); 
    597608    } 
    598609 
     
    613624                                          List<StaticParam> sparams, 
    614625                                          Option<WhereClause> where) { 
    615         TypeInfo info = makeTypeInfo(parenthesized, sparams, where); 
    616         return new ArrowType(span, info, domain, range, effect); 
     626        TypeInfo info = makeTypeInfo(span, parenthesized, sparams, where); 
     627        return new ArrowType(info, domain, range, effect); 
    617628    } 
    618629 
     
    634645                                          Option<Type> varargs, 
    635646                                          List<KeywordType> keywords) { 
    636         TypeInfo info = makeTypeInfo(parenthesized); 
    637         return new TupleType(span, info, elements, varargs, keywords); 
     647        TypeInfo info = makeTypeInfo(span, parenthesized); 
     648        return new TupleType(info, elements, varargs, keywords); 
    638649    } 
    639650 
     
    647658                                                  Type elem, DimExpr dim, 
    648659                                                  Option<Expr> unit) { 
    649         TypeInfo info = makeTypeInfo(parenthesized); 
    650         return new TaggedDimType(span, info, elem, dim, unit); 
     660        TypeInfo info = makeTypeInfo(span, parenthesized); 
     661        return new TaggedDimType(info, elem, dim, unit); 
    651662    } 
    652663 
     
    715726                                          Id name, List<StaticArg> sargs, 
    716727                                          List<StaticParam> sparams) { 
    717         TypeInfo info = makeTypeInfo(parenthesized); 
    718         return new TraitType(span, info, name, sargs, sparams); 
     728        TypeInfo info = makeTypeInfo(span, parenthesized); 
     729        return new TraitType(info, name, sargs, sparams); 
    719730    } 
    720731 
     
    738749    public static VarType makeVarType(Span span, boolean parenthesized, 
    739750                                      Id name, int lexicalDepth) { 
    740         TypeInfo info = makeTypeInfo(parenthesized); 
    741         return new VarType(span, info, name, lexicalDepth); 
     751        TypeInfo info = makeTypeInfo(span, parenthesized); 
     752        return new VarType(info, name, lexicalDepth); 
    742753    } 
    743754 
     
    748759    public static DimBinaryOp makeDimBinaryOp(Span span, boolean parenthesized, 
    749760                                              DimExpr left, DimExpr right, Op op) { 
    750         TypeInfo info = makeTypeInfo(parenthesized); 
    751         return new DimBinaryOp(span, info, left, right, op); 
     761        TypeInfo info = makeTypeInfo(span, parenthesized); 
     762        return new DimBinaryOp(info, left, right, op); 
    752763    } 
    753764 
     
    758769    public static DimUnaryOp makeDimUnaryOp(Span span, boolean parenthesized, 
    759770                                            DimExpr dim, Op op) { 
    760         TypeInfo info = makeTypeInfo(parenthesized); 
    761         return new DimUnaryOp(span, info, dim, op); 
     771        TypeInfo info = makeTypeInfo(span, parenthesized); 
     772        return new DimUnaryOp(info, dim, op); 
    762773    } 
    763774 
     
    769780    public static DimExponent makeDimExponent(Span span, boolean parenthesized, 
    770781                                              Type base, IntExpr power) { 
    771         TypeInfo info = makeTypeInfo(parenthesized); 
    772         return new DimExponent(span, info, base, power); 
     782        TypeInfo info = makeTypeInfo(span, parenthesized); 
     783        return new DimExponent(info, base, power); 
    773784    } 
    774785 
     
    782793 
    783794    public static DimRef makeDimRef(Span span, boolean parenthesized, Id name) { 
    784         TypeInfo info = makeTypeInfo(parenthesized); 
    785         return new DimRef(span, info, name); 
     795        TypeInfo info = makeTypeInfo(span, parenthesized); 
     796        return new DimRef(info, name); 
    786797    } 
    787798 
    788799    public static DimBase makeDimBase(Span span, boolean parenthesized) { 
    789         TypeInfo info = makeTypeInfo(parenthesized); 
    790         return new DimBase(span, info); 
     800        TypeInfo info = makeTypeInfo(span, parenthesized); 
     801        return new DimBase(info); 
    791802    } 
    792803 
     
    801812    public static FixedPointType makeFixedPointType(Span span, boolean parenthesized, 
    802813                                                    _InferenceVarType name, Type body) { 
    803         TypeInfo info = makeTypeInfo(parenthesized); 
    804         return new FixedPointType(span, info, name, body); 
     814        TypeInfo info = makeTypeInfo(span, parenthesized); 
     815        return new FixedPointType(info, name, body); 
    805816    } 
    806817 
     
    817828    public static UnionType makeUnionType(Span span, boolean parenthesized, 
    818829                                          List<Type> elements) { 
    819         TypeInfo info = makeTypeInfo(parenthesized); 
    820         return new UnionType(span, info, elements); 
     830        TypeInfo info = makeTypeInfo(span, parenthesized); 
     831        return new UnionType(info, elements); 
    821832    } 
    822833 
     
    832843 
    833844    public static _InferenceVarType make_InferenceVarType(Span span, boolean parenthesized, Object id) { 
    834         TypeInfo info = makeTypeInfo(parenthesized); 
    835         return new _InferenceVarType(span, info, id); 
     845        TypeInfo info = makeTypeInfo(span, parenthesized); 
     846        return new _InferenceVarType(info, id); 
    836847    } 
    837848 
     
    867878    public static MatrixType makeMatrixType(Span span, boolean parenthesized, 
    868879                                            Type elem, List<ExtentRange> dim) { 
    869         TypeInfo info = makeTypeInfo(parenthesized); 
    870         return new MatrixType(span, info, elem, dim); 
     880        TypeInfo info = makeTypeInfo(span, parenthesized); 
     881        return new MatrixType(info, elem, dim); 
    871882    } 
    872883 
     
    890901    public static ArrayType makeArrayType(Span span, boolean parenthesized, 
    891902                                          Type elem, Indices indices) { 
    892         TypeInfo info = makeTypeInfo(parenthesized); 
    893         return new ArrayType(span, info, elem, indices); 
     903        TypeInfo info = makeTypeInfo(span, parenthesized); 
     904        return new ArrayType(info, elem, indices); 
    894905    } 
    895906 
     
    911922    public static IntersectionType makeIntersectionType(Span span, boolean parenthesized, 
    912923                                                        List<Type> elems) { 
    913         TypeInfo info = makeTypeInfo(parenthesized); 
    914         return new IntersectionType(span, info, elems); 
     924        TypeInfo info = makeTypeInfo(span, parenthesized); 
     925        return new IntersectionType(info, elems); 
    915926    } 
    916927 
     
    948959        return makeEffect(span, Option.<List<BaseType>>none(), ioEffect); 
    949960    } 
     961 
    950962 
    951963    public static Effect makeEffect(Span span, Option<List<BaseType>> throwsC, 
     
    969981    public static TraitTypeWhere makeTraitTypeWhere(Span span, BaseType type, 
    970982                                                    Option<WhereClause> where) { 
    971         return new TraitTypeWhere(span, type, where); 
     983        SpanInfo info = makeSpanInfo(span); 
     984        return new TraitTypeWhere(info, type, where); 
    972985    } 
    973986 
     
    984997    public static AnonymousFnName makeAnonymousFnName(Span span, 
    985998                                                      Option<APIName> api) { 
    986         return new AnonymousFnName(makeSpanInfo(span), api); 
     999        SpanInfo info = makeSpanInfo(span); 
     1000        return new AnonymousFnName(info, api); 
    9871001    } 
    9881002 
     
    9921006 
    9931007    public static Id makeId(Span span, Option<APIName> apiName, String text) { 
    994         return new Id(span, apiName, text); 
     1008        SpanInfo info = makeSpanInfo(span); 
     1009        return new Id(info, apiName, text); 
    9951010    } 
    9961011 
     
    11241139 
    11251140    public static APIName makeAPIName(Span span, List<Id> apis, String text) { 
    1126         return new APIName(span, apis, text); 
     1141        SpanInfo info = makeSpanInfo(span); 
     1142        return new APIName(info, apis, text); 
    11271143    } 
    11281144 
     
    11571173    public static BoolRef makeBoolRef(Span span, boolean parenthesized, 
    11581174                                      Id name, int depth) { 
    1159         return new BoolRef(span, parenthesized, name, depth); 
     1175        SpanInfo info = makeSpanInfo(span); 
     1176        return new BoolRef(info, parenthesized, name, depth); 
    11601177    } 
    11611178