Changeset 3246
- Timestamp:
- 12/19/08 22:34:31 (11 months ago)
- Location:
- trunk/ProjectFortress
- Files:
-
- 37 modified
-
astgen/Fortress.ast (modified) (3 diffs)
-
src/com/sun/fortress/astgen/EllipsesNode.java (modified) (9 diffs)
-
src/com/sun/fortress/astgen/EllipsesNodeCreator.java (modified) (1 diff)
-
src/com/sun/fortress/astgen/SingleSpanConstructorGenerator.java (modified) (4 diffs)
-
src/com/sun/fortress/astgen/TemplateGapClass.java (modified) (11 diffs)
-
src/com/sun/fortress/astgen/TemplateGapNodeCreator.java (modified) (3 diffs)
-
src/com/sun/fortress/astgen/TemplateVisitorGenerator.java (modified) (12 diffs)
-
src/com/sun/fortress/astgen/TransformationNode.java (modified) (10 diffs)
-
src/com/sun/fortress/astgen/TransformationNodeCreator.java (modified) (1 diff)
-
src/com/sun/fortress/compiler/desugarer/DesugaringVisitor.java (modified) (2 diffs)
-
src/com/sun/fortress/compiler/desugarer/DottedMethodRewriteVisitor.java (modified) (1 diff)
-
src/com/sun/fortress/compiler/desugarer/MutableVarRefRewriteVisitor.java (modified) (1 diff)
-
src/com/sun/fortress/compiler/desugarer/ObjectExpressionVisitor.java (modified) (2 diffs)
-
src/com/sun/fortress/compiler/desugarer/PreDisambiguationDesugaringVisitor.java (modified) (2 diffs)
-
src/com/sun/fortress/compiler/disambiguator/ExprDisambiguator.java (modified) (6 diffs)
-
src/com/sun/fortress/compiler/disambiguator/NonterminalDisambiguator.java (modified) (5 diffs)
-
src/com/sun/fortress/compiler/disambiguator/SelfParamDisambiguator.java (modified) (2 diffs)
-
src/com/sun/fortress/compiler/disambiguator/TypeDisambiguator.java (modified) (8 diffs)
-
src/com/sun/fortress/compiler/typechecker/InferenceVarInserter.java (modified) (6 diffs)
-
src/com/sun/fortress/compiler/typechecker/TypeAnalyzer.java (modified) (1 diff)
-
src/com/sun/fortress/compiler/typechecker/TypeChecker.java (modified) (4 diffs)
-
src/com/sun/fortress/nodes_util/ExprFactory.java (modified) (54 diffs)
-
src/com/sun/fortress/nodes_util/NodeFactory.java (modified) (40 diffs)
-
src/com/sun/fortress/nodes_util/NodeReflection.java (modified) (5 diffs)
-
src/com/sun/fortress/nodes_util/NodeUtil.java (modified) (3 diffs)
-
src/com/sun/fortress/nodes_util/Printer.java (modified) (1 diff)
-
src/com/sun/fortress/nodes_util/RewriteHackList.java (modified) (1 diff)
-
src/com/sun/fortress/nodes_util/Unprinter.java (modified) (3 diffs)
-
src/com/sun/fortress/parser_util/NameAndImportCollector.java (modified) (7 diffs)
-
src/com/sun/fortress/syntax_abstractions/SyntaxAbstractionJUTest.java (modified) (1 diff)
-
src/com/sun/fortress/syntax_abstractions/phases/ComposingSyntaxDefTranslator.java (modified) (1 diff)
-
src/com/sun/fortress/syntax_abstractions/phases/EscapeRewriter.java (modified) (2 diffs)
-
src/com/sun/fortress/syntax_abstractions/phases/RewriteTransformerNames.java (modified) (2 diffs)
-
src/com/sun/fortress/syntax_abstractions/phases/TemplateVarRewriter.java (modified) (2 diffs)
-
src/com/sun/fortress/syntax_abstractions/phases/Transform.java (modified) (3 diffs)
-
src/com/sun/fortress/syntax_abstractions/util/BaseTypeCollector.java (modified) (1 diff)
-
src/com/sun/fortress/tools/FortressAstToConcrete.java (modified) (77 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ProjectFortress/astgen/Fortress.ast
r3238 r3246 77 77 * top-level node interface 78 78 */ 79 interface ASTNode( ignoreForEquals Span span);79 interface ASTNode(ASTNodeInfo info); 80 80 /** 81 81 * with static parameters … … 94 94 * top-level node abstract class 95 95 */ 96 root abstract AbstractNode( ) extends UIDObject;96 root abstract AbstractNode(ASTNodeInfo info) extends UIDObject; 97 97 /** 98 98 * compilation unit declaration … … 1854 1854 * common header for AST nodes 1855 1855 */ 1856 abstract ASTNodeInfo(); 1856 abstract ASTNodeInfo(ignoreForEquals Span span); 1857 /** 1858 * common header for node with Span 1859 */ 1860 SpanInfo(); 1857 1861 /** 1858 1862 * common header for parenthesized node -
trunk/ProjectFortress/src/com/sun/fortress/astgen/EllipsesNode.java
r2690 r3246 37 37 38 38 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 ){ 41 42 super( "_Ellipses" + parent.name(), false, fields(ast), Types.parse(parent.name(), ast), Collections.singletonList(Types.parse("_Ellipses",ast)) ); 43 infoType = in_infoType; 42 44 } 43 45 … … 50 52 return fields(ast); 51 53 } 52 54 53 55 private static List<Field> fields( ASTModel ast ){ 54 56 return new ArrayList<Field>(); … … 97 99 writeSerialize(writer); 98 100 writer.println(""); 99 writeOutputHelp(writer, this.name()); 101 writeOutputHelp(writer, this.name()); 100 102 101 103 // for (CodeGenerator g : gens) { g.generateClassMembers(writer, this); } … … 135 137 writer.startLine("visitor.for"+name+"(this);"); 136 138 writer.unindent(); 137 writer.startLine("}"); 139 writer.startLine("}"); 138 140 } 139 141 … … 148 150 writer.startLine(String.format("private final AbstractNode _%s;", nodeField)); 149 151 /* 150 // writer.startLine("private final Span _span;");151 152 writer.startLine(String.format("private final String _%s;", fieldTransformer)); 152 153 writer.startLine("private final java.util.Map<String,Object> _variables;"); … … 156 157 157 158 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);"); 161 162 writer.startLine(String.format("this._%s = %s;", nodeField, nodeField)); 162 163 writer.unindent(); 163 164 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 */174 165 } 175 166 … … 177 168 writer.startLine("public " + className+"() {"); 178 169 writer.indent(); 179 writer.startLine("super( new Span());");170 writer.startLine("super(NodeFactory.make" + infoType + "());"); 180 171 writer.startLine(String.format("this._%s = null;", nodeField)); 181 172 /* … … 203 194 writer.startLine("}"); 204 195 writer.unindent(); 205 writer.startLine("}"); 196 writer.startLine("}"); 206 197 } 207 198 … … 249 240 writer.startLine("writer.indent();"); 250 241 251 writer.startLine( "Span temp_span = getSpan();");242 writer.startLine(infoType + " temp_info = getInfo();"); 252 243 writer.startLine("writer.startLine();"); 253 writer.startLine("writer.print(\" span= \");");244 writer.startLine("writer.print(\"info = \");"); 254 245 writer.startLine("if (lossless) {"); 255 246 writer.indent(); 256 writer.startLine("writer.printSerialized(temp_ span);");247 writer.startLine("writer.printSerialized(temp_info);"); 257 248 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); }"); 261 252 writer.startLine("writer.unindent();"); 262 253 writer.unindent(); -
trunk/ProjectFortress/src/com/sun/fortress/astgen/EllipsesNodeCreator.java
r3142 r3246 58 58 List<Pair<NodeType, NodeType>> all = new LinkedList<Pair<NodeType, NodeType>>(); 59 59 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 63 71 abstractNode = ast.typeForName("AbstractNode").unwrap(); 64 72 for ( NodeType n : ast.classes() ){ 65 73 if ( n.getClass() == NodeClass.class && 66 74 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); 68 82 all.add( new Pair<NodeType,NodeType>( child, n ) ); 69 83 } -
trunk/ProjectFortress/src/com/sun/fortress/astgen/SingleSpanConstructorGenerator.java
r3142 r3246 29 29 30 30 /** 31 * Produce a single argument constructor which takes a Span , and instantiates31 * Produce a single argument constructor which takes a SpanInfo, and instantiates 32 32 * each field to null, leaving clients to manually instantiate each field correctly. 33 33 */ … … 35 35 36 36 private NodeType abstractNode; 37 private NodeType exprNode; 38 private NodeType typeNode; 37 39 38 40 public SingleSpanConstructorGenerator(ASTModel ast) { 39 41 super(ast); 40 if ( ast.typeForName("AbstractNode").is None() )41 throw new RuntimeException("Fortress.ast does not define AbstractNode!");42 else42 if ( ast.typeForName("AbstractNode").isSome() && 43 ast.typeForName("Expr").isSome() && 44 ast.typeForName("Type").isSome() ) { 43 45 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!"); 44 50 } 45 51 … … 52 58 // boolean allDefaults = true; 53 59 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. 55 61 for (Field f : c.allFields(ast)) { 56 62 //hasSingleSpanConstructor = false; … … 70 76 writer.startLine(" * templateParams."); 71 77 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) {"); 73 84 writer.indent(); 74 writer.startLine("super( span);");85 writer.startLine("super(info);"); 75 86 for (Field f : c.declaredFields(ast)) { 76 87 String init; -
trunk/ProjectFortress/src/com/sun/fortress/astgen/TemplateGapClass.java
r2934 r3246 33 33 public class TemplateGapClass extends NodeClass { 34 34 // 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) { 37 39 super(name, false, fields, superClass, interfaces); 40 infoType = in_infoType; 38 41 // _superClass = superClass; 39 42 } … … 59 62 } 60 63 // 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; 62 70 } 63 71 … … 104 112 writeSerialize(writer); 105 113 writer.println(""); 106 writeOutputHelp(writer, this.name()); 114 writeOutputHelp(writer, this.name()); 107 115 108 116 // for (CodeGenerator g : gens) { g.generateClassMembers(writer, this); } … … 117 125 118 126 private void writeGetters(TabPrintWriter writer, String name) { 119 // writer.startLine("final public Span getSpan() { return _span; }");120 127 writer.startLine("final public Id getGapId() { return _id; }"); 121 128 writer.startLine("final public List<Id> getTemplateParams() { return _templateParams; }"); … … 137 144 writer.startLine("visitor.for"+name+"(this);"); 138 145 writer.unindent(); 139 writer.startLine("}"); 146 writer.startLine("}"); 140 147 } 141 148 … … 149 156 150 157 private void writeFields(TabPrintWriter writer) { 151 // writer.startLine("private final Span _span;");152 158 writer.startLine("private final Id _id;"); 153 159 writer.startLine("private final List<Id> _templateParams;"); … … 155 161 156 162 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);"); 160 166 writer.startLine("this._id = id;"); 161 167 writer.startLine("this._templateParams = templateParams;"); … … 167 173 writer.startLine("public " + className+"() {"); 168 174 writer.indent(); 169 writer.startLine("super( new Span());");175 writer.startLine("super(NodeFactory.make" + infoType + "());"); 170 176 writer.startLine("this._id = null;"); 171 177 writer.startLine("this._templateParams = null;"); … … 196 202 writer.startLine("}"); 197 203 writer.unindent(); 198 writer.startLine("}"); 204 writer.startLine("}"); 199 205 } 200 206 … … 245 251 writer.startLine("writer.indent();"); 246 252 247 writer.startLine( "Span temp_span = getSpan();");253 writer.startLine(infoType + " temp_info = getInfo();"); 248 254 writer.startLine("writer.startLine();"); 249 writer.startLine("writer.print(\" span= \");");255 writer.startLine("writer.print(\"info = \");"); 250 256 writer.startLine("if (lossless) {"); 251 257 writer.indent(); 252 writer.startLine("writer.printSerialized(temp_ span);");258 writer.startLine("writer.printSerialized(temp_info);"); 253 259 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); }"); 257 263 258 264 writer.startLine("Id temp_id = getGapId();"); … … 292 298 @Override 293 299 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; 295 306 } 296 307 -
trunk/ProjectFortress/src/com/sun/fortress/astgen/TemplateGapNodeCreator.java
r3142 r3246 35 35 public class TemplateGapNodeCreator extends CodeGenerator implements Runnable { 36 36 37 private TypeName idType = Types.parse("Id", ast); 38 private TypeName listIdType = Types.parse("List<Id>", ast); 39 37 40 public static List<Field> TEMPLATEGAPFIELDS; { 38 41 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)); 42 44 TEMPLATEGAPFIELDS.add(new Field(idType , "gapId", Option.<String>none(), false, false, true)); 43 TypeName listIdType = Types.parse("List<Id>", ast);44 45 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)); 45 62 } 46 63 … … 58 75 List<Pair<NodeType, NodeType>> templateGaps = new LinkedList<Pair<NodeType, NodeType>>(); 59 76 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() ) { 63 82 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!"); 64 87 for (NodeClass nodeClass: ast.classes()) { 65 88 if ( nodeClass.getClass() == NodeClass.class && … … 67 90 List<TypeName> interfaces = new LinkedList<TypeName>(); 68 91 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 } 70 104 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); 72 108 templateGaps.add(new Pair<NodeType, NodeType>(templateGap, nodeClass)); 73 109 } -
trunk/ProjectFortress/src/com/sun/fortress/astgen/TemplateVisitorGenerator.java
r2690 r3246 37 37 public class TemplateVisitorGenerator extends UpdateVisitorGenerator { 38 38 39 private NodeType exprNode; 40 private NodeType typeNode; 41 39 42 public TemplateVisitorGenerator(ASTModel ast) { 40 43 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!"); 41 50 } 42 51 … … 45 54 // only defined for the "Node" class 46 55 if (!root.name().equals("Node")) { return; } 47 56 48 57 String visitorName = "TemplateUpdateVisitor"; 49 58 TabPrintWriter writer = options.createJavaSourceInOutDir(visitorName); … … 64 73 writer.startLine(" * case has a default implementation."); 65 74 writer.startLine(" */"); 66 writer.startLine("@SuppressWarnings(value={\"unused\"})"); 75 writer.startLine("@SuppressWarnings(value={\"unused\"})"); 67 76 writer.startLine("public abstract class " + visitorName); 68 77 … … 78 87 writer.println(); 79 88 80 89 81 90 writer.startLine("/* Methods to handle a node after recursion. */"); 82 91 for (NodeType t : ast.descendents(root)) { … … 94 103 // outputTemplateForCaseOnly(t, writer, root); 95 104 // } 96 } 105 } 97 106 writer.println(); 98 107 … … 107 116 // } 108 117 } 109 118 110 119 NodeType templateGapInterface = null; 111 120 for (NodeInterface ni: ast.interfaces()) { … … 114 123 } 115 124 } 116 outputForTemplateGapOnly(templateGapInterface, writer, root); 125 outputForTemplateGapOnly(templateGapInterface, writer, root); 117 126 118 127 writer.println(); … … 123 132 writer.println(); 124 133 outputEllipsesDefaultCase(writer, root); 125 134 126 135 // Output helpers 127 136 for (TypeName t : helpers()) { writer.println(); generateHelper(t, writer, root); } 128 137 129 138 writer.unindent(); 130 139 writer.startLine("}"); … … 176 185 if (typeName.name().equals("TemplateGap")) { 177 186 isTemplateGap = true; 178 } 187 } 179 188 } 180 189 … … 207 216 writer.print(");"); 208 217 } 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 231 218 writer.unindent(); 232 219 writer.startLine("}"); … … 257 244 } 258 245 259 protected void output TemplateForCaseOnly(NodeType t, TabPrintWriter writer, NodeType root) {246 protected void outputForTemplateGapOnly(NodeType t, TabPrintWriter writer, NodeType root) { 260 247 // only called for concrete cases; must not delegate 261 248 List<String> params = new LinkedList<String>(); // "type name" strings 262 249 List<String> getters = new LinkedList<String>(); // expressions 263 250 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) { 265 259 getters.add("that." + f.getGetterName() + "()"); 266 260 if (canRecurOn(f.type(), root)) { … … 271 265 else { paramRefs.add(null); } 272 266 } 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 delegate314 List<String> params = new LinkedList<String>(); // "type name" strings315 List<String> getters = new LinkedList<String>(); // expressions316 List<String> paramRefs = new LinkedList<String>(); // variable names or null317 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 }326 267 outputTemplateForCaseHeader("", writer, root.name(), "Only", params); 327 268 writer.indent(); -
trunk/ProjectFortress/src/com/sun/fortress/astgen/TransformationNode.java
r2690 r3246 36 36 public class TransformationNode extends NodeClass { 37 37 38 private String infoType; 39 38 40 /* the field that corresponds to the name of the transformer function. */ 39 41 private final String fieldTransformer = "syntaxTransformer"; 40 42 41 public TransformationNode( NodeClass parent, ASTModel ast ){ 43 public TransformationNode( NodeClass parent, ASTModel ast, 44 String in_infoType ){ 42 45 super( "_SyntaxTransformation" + parent.name(), false, fields(ast), Types.parse(parent.name(), ast), Collections.singletonList(Types.parse("_SyntaxTransformation",ast)) ); 46 infoType = in_infoType; 43 47 } 44 48 … … 51 55 return fields(ast); 52 56 } 53 57 54 58 private static List<Field> fields( ASTModel ast ){ 55 59 /* … … 76 80 writer.startLine(" * @version Generated automatically by ASTGen at "); 77 81 writer.print(new Date()); 78 writer.startLine(" */"); 82 writer.startLine(" */"); 79 83 writer.startLine("@SuppressWarnings(value={\"unused\"})"); 80 84 // Class header … … 104 108 writeSerialize(writer); 105 109 writer.println(""); 106 writeOutputHelp(writer, this.name()); 110 writeOutputHelp(writer, this.name()); 107 111 108 112 // for (CodeGenerator g : gens) { g.generateClassMembers(writer, this); } … … 139 143 writer.startLine("visitor.for"+name+"(this);"); 140 144 writer.unindent(); 141 writer.startLine("}"); 145 writer.startLine("}"); 142 146 } 143 147 … … 150 154 151 155 private void writeFields(TabPrintWriter writer) { 152 // writer.startLine("private final Span _span;");153 156 writer.startLine(String.format("private final String _%s;", fieldTransformer)); 154 157 writer.startLine("private final java.util.Map<String,Level> _variables;"); … … 157 160 158 161 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);"); 162 165 writer.startLine(String.format("this._%s = %s;", fieldTransformer, fieldTransformer)); 163 166 writer.startLine("this._variables = variables;"); … … 170 173 writer.startLine("public " + className+"() {"); 171 174 writer.indent(); 172 writer.startLine("super( new Span());");175 writer.startLine("super(NodeFactory.make" + infoType + "());"); 173 176 writer.startLine(String.format("this._%s = null;", fieldTransformer)); 174 177 writer.startLine("this._variables = null;"); … … 193 196 writer.startLine("}"); 194 197 writer.unindent(); 195 writer.startLine("}"); 198 writer.startLine("}"); 196 199 } 197 200 … … 239 242 writer.startLine("writer.indent();"); 240 243 241 writer.startLine( "Span temp_span = getSpan();");244 writer.startLine(infoType + " temp_info = getInfo();"); 242 245 writer.startLine("writer.startLine();"); 243 writer.startLine("writer.print(\" span= \");");246 writer.startLine("writer.print(\"info = \");"); 244 247 writer.startLine("if (lossless) {"); 245 248 writer.indent(); 246 writer.startLine("writer.printSerialized(temp_ span);");249 writer.startLine("writer.printSerialized(temp_info);"); 247 250 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); }"); 251 254 writer.startLine("writer.unindent();"); 252 255 writer.unindent(); -
trunk/ProjectFortress/src/com/sun/fortress/astgen/TransformationNodeCreator.java
r3142 r3246 58 58 List<Pair<NodeType, NodeType>> all = new LinkedList<Pair<NodeType, NodeType>>(); 59 59 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() ) { 63 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!"); 64 70 for ( NodeType n : ast.classes() ){ 65 71 if ( n.getClass() == NodeClass.class && 66 72 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); 68 80 all.add( new Pair<NodeType,NodeType>( child, n ) ); 69 81 } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/DesugaringVisitor.java
r3243 r3246 536 536 537 537 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); 539 539 } 540 540 … … 557 557 TraitTypeHeader header = NodeFactory.makeTraitTypeHeaderWithDecls(that.getHeader(), gettersAndDecls); 558 558 559 return forTraitDeclOnly(that, header, NodeUtil.getExcludesClause(that),559 return forTraitDeclOnly(that, that.getInfo(), header, NodeUtil.getExcludesClause(that), 560 560 NodeUtil.getComprisesClause(that)); 561 561 } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/DottedMethodRewriteVisitor.java
r3225 r3246 56 56 TraitTypeHeader header = NodeFactory.makeTraitTypeHeaderWithDecls(that.getHeader(), decls_result ); 57 57 58 return super.forObjectDeclOnly(that, header, that.getParams());58 return super.forObjectDeclOnly(that, that.getInfo(), header, that.getParams()); 59 59 } 60 60 -
trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/MutableVarRefRewriteVisitor.java
r3225 r3246 97 97 TraitTypeHeader header = NodeFactory.makeTraitTypeHeaderWithDecls(that.getHeader(), decls_result ); 98 98 99 return super.forObjectDeclOnly(that, header, that.getParams());99 return super.forObjectDeclOnly(that, that.getInfo(), header, that.getParams()); 100 100 } 101 101 -
trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/ObjectExpressionVisitor.java
r3243 r3246 171 171 @Override 172 172 public Node forComponentOnly(Component that, 173 ASTNodeInfo info, 173 174 APIName name_result, 174 175 List<Import> imports_result, … … 176 177 List<APIName> exports_result) { 177 178 decls_result.addAll(newObjectDecls); 178 return super.forComponentOnly(that, name_result,179 return super.forComponentOnly(that, info, name_result, 179 180 imports_result, decls_result, exports_result); 180 181 } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/PreDisambiguationDesugaringVisitor.java
r3225 r3246 91 91 } 92 92 93 return super.forTraitDeclOnly(that, header_result,93 return super.forTraitDeclOnly(that, that.getInfo(), header_result, 94 94 excludesClause_result, 95 95 comprisesClause_result); … … 103 103 header_result = NodeFactory.makeTraitTypeHeader(header_result, 104 104 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); 106 107 } 107 108 -
trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/ExprDisambiguator.java
r3244 r3246 676 676 v.recurOnListOfDecl(NodeUtil.getDecls(that))); 677 677 678 return forTraitDeclOnly(that, header,678 return forTraitDeclOnly(that, that.getInfo(), header, 679 679 v.recurOnListOfBaseType(NodeUtil.getExcludesClause(that)), 680 680 v.recurOnOptionOfListOfBaseType(NodeUtil.getComprisesClause(that))); … … 727 727 v.recurOnListOfDecl(NodeUtil.getDecls(that))); 728 728 729 return forObjectDeclOnly(that, header,729 return forObjectDeclOnly(that, that.getInfo(), header, 730 730 v.recurOnOptionOfListOfParam(NodeUtil.getParams(that))); 731 731 } … … 757 757 // to share its name with a field, so blindly checking for shadowing at this point 758 758 // doesn't work. 759 return forFnDeclOnly(that, header,759 return forFnDeclOnly(that, that.getInfo(), header, 760 760 that.getUnambiguousName(), 761 761 v.recurOnOptionOfExpr(NodeUtil.getBody(that)), … … 824 824 ExprDisambiguator v = this.extendWithVars(Collections.singleton(that.getName())); 825 825 return forCatchOnly(that, 826 that.getInfo(), 826 827 (Id)that.getName().accept(v), 827 828 v.recurOnListOfCatchClause(that.getClauses())); … … 835 836 ExprDisambiguator v = extendWithOutcome(NodeUtil.getSpan(that)); 836 837 return forContractOnly(that, 838 that.getInfo(), 837 839 v.recurOnOptionOfListOfExpr(that.getRequiresClause()), 838 840 v.recurOnOptionOfListOfEnsuresClause(that.getEnsuresClause()), … … 866 868 867 869 return forIfClauseOnly(that, 870 that.getInfo(), 868 871 (GeneratorClause)that.getTestClause().accept(this), 869 872 (Block)that.getBody().accept(e_d)); -
trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/NonterminalDisambiguator.java
r3211 r3246 36 36 import com.sun.fortress.nodes.NonterminalHeader; 37 37 import com.sun.fortress.nodes.NonterminalParameter; 38 import com.sun.fortress.nodes.ASTNodeInfo; 38 39 import com.sun.fortress.nodes.StaticParam; 39 40 import com.sun.fortress.nodes.SyntaxDecl; … … 84 85 @Override 85 86 public Node forNonterminalDefOnly(NonterminalDef that, 87 ASTNodeInfo info, 86 88 Id _name_result, 87 89 List<SyntaxDecl> syntaxDefs_result, … … 91 93 throw new RuntimeException("Type inference is not supported yet!"); 92 94 } 93 return super.forNonterminalDefOnly(that, header_result.getName(), syntaxDefs_result, 95 return super.forNonterminalDefOnly(that, that.getInfo(), 96 header_result.getName(), syntaxDefs_result, 94 97 header_result, astType_result); 95 98 } … … 97 100 @Override 98 101 public Node forNonterminalExtensionDefOnly(NonterminalExtensionDef that, 102 ASTNodeInfo info, 99 103 Id name_result, 100 104 List<SyntaxDecl> syntaxDefs_result) { 101 105 Id name = disambiguateNonterminalName(name_result); 102 return super.forNonterminalExtensionDefOnly(that, name, syntaxDefs_result); 106 return super.forNonterminalExtensionDefOnly(that, that.getInfo(), 107 name, syntaxDefs_result); 103 108 } 104 109 105 110 @Override 106 111 public Node forNonterminalHeaderOnly(NonterminalHeader that, 112 ASTNodeInfo info, 107 113 Id name_result, 108 114 List<NonterminalParameter> params_result, … … 111 117 Option<WhereClause> whereClause_result) { 112 118 Id name = disambiguateNonterminalName(name_result); 113 return super.forNonterminalHeaderOnly(that, name, params_result, 119 return super.forNonterminalHeaderOnly(that, that.getInfo(), 120 name, params_result, 114 121 staticParams_result, type_result, whereClause_result); 115 122 } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/SelfParamDisambiguator.java
r3227 r3246 30 30 import com.sun.fortress.nodes.ObjectExpr; 31 31 import com.sun.fortress.nodes.Param; 32 import com.sun.fortress.nodes.ASTNodeInfo; 32 33 import com.sun.fortress.nodes.TraitDecl; 33 34 import com.sun.fortress.nodes.Type; … … 94 95 int traitNestingDepth = 0; 95 96 @Override 96 public Node forParamOnly(Param that, Id name_result, 97 public Node forParamOnly(Param that, ASTNodeInfo info, 98 Id name_result, 97 99 Option<Type> type_result, 98 100 Option<Expr> defaultExpr_result, -
trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/TypeDisambiguator.java
r3243 r3246 70 70 import com.sun.fortress.nodes.Op; 71 71 import com.sun.fortress.nodes.OpArg; 72 import com.sun.fortress.nodes.ASTNodeInfo; 72 73 import com.sun.fortress.nodes.StaticArg; 73 74 import com.sun.fortress.nodes.StaticParam; … … 154 155 v.recurOnListOfTraitTypeWhere(NodeUtil.getExtendsClause(that)), 155 156 v.recurOnListOfDecl(NodeUtil.getDecls(that))); 156 return forTraitDeclOnly(that, header,157 return forTraitDeclOnly(that, that.getInfo(), header, 157 158 v.recurOnListOfBaseType(NodeUtil.getExcludesClause(that)), 158 159 v.recurOnOptionOfListOfBaseType(NodeUtil.getComprisesClause(that))); … … 174 175 v.recurOnListOfDecl(NodeUtil.getDecls(that))); 175 176 176 return forObjectDeclOnly(that, header,177 return forObjectDeclOnly(that, that.getInfo(), header, 177 178 v.recurOnOptionOfListOfParam(NodeUtil.getParams(that))); 178 179 } … … 194 195 v.recurOnOptionOfType(NodeUtil.getReturnType(that))); 195 196 196 return forFnDeclOnly(that, header,197 return forFnDeclOnly(that, that.getInfo(), header, 197 198 that.getUnambiguousName(), 198 199 v.recurOnOptionOfExpr(NodeUtil.getBody(that)), … … 471 472 472 473 @Override public Node forSuperSyntaxDefOnly(SuperSyntaxDef that, 474 ASTNodeInfo info, 473 475 Id nonterminal_result, Id grammar_result) { 474 476 Id disambiguatedGrammar = handleGrammarName(grammar_result); 475 return new SuperSyntaxDef( NodeUtil.getSpan(that),477 return new SuperSyntaxDef(info, 476 478 that.getModifier(), nonterminal_result, disambiguatedGrammar); 477 479 } 478 480 479 481 @Override 480 public Node forGrammarDeclOnly(GrammarDecl that, Id name_result, 482 public Node forGrammarDeclOnly(GrammarDecl that, 483 ASTNodeInfo info, Id name_result, 481 484 List<Id> extends_result, 482 485 List<GrammarMemberDecl> members_result, … … 487 490 Id name = handleGrammarName(name_result); 488 491 489 GrammarDecl disambiguatedGrammar = new GrammarDecl( NodeUtil.getSpan(that),492 GrammarDecl disambiguatedGrammar = new GrammarDecl(info, 490 493 name, p.first(), members_result, transformers, that.isNativeDef()); 491 494 … … 559 562 // System.err.println("t: "+t); 560 563 return forNonterminalHeaderOnly(that, 564 that.getInfo(), 561 565 (Id) that.getName().accept(v), 562 566 v.recurOnListOfNonterminalParameter(that.getParams()), … … 571 575 @Override 572 576 public Node forTypeArgOnly(final TypeArg arg, 577 ASTNodeInfo info, 573 578 final Type t) { 574 579 if(arg.getTypeArg() instanceof VarType){ -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/InferenceVarInserter.java
r3225 r3246 31 31 import com.sun.fortress.nodes.Param; 32 32 import com.sun.fortress.nodes.StaticParam; 33 import com.sun.fortress.nodes.ASTNodeInfo; 33 34 import com.sun.fortress.nodes.Type; 34 35 import com.sun.fortress.nodes.WhereClause; … … 46 47 47 48 @Override 48 public Node forLValueOnly(LValue that, Id name_result, 49 public Node forLValueOnly(LValue that, ASTNodeInfo info, 50 Id name_result, 49 51 Option<Type> type_result) { 50 52 if( type_result.isNone() ) { … … 72 74 Option<Expr> body_result = recurOnOptionOfExpr(that.getBody()); 73 75 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, 75 77 returnType_result, throwsClause_result, 76 78 where_result, contract_result, unambiguousName_result, … … 79 81 80 82 public Node forFnDeclOnly(FnDecl that, 83 ASTNodeInfo info, 81 84 IdOrOpOrAnonymousName name_result, 82 85 List<StaticParam> staticParams_result, List<Param> params_result, … … 100 103 contract_result, 101 104 params_result, new_ret_type); 102 return super.forFnDeclOnly(that, header, unambiguousName_result,105 return super.forFnDeclOnly(that, info, header, unambiguousName_result, 103 106 body_result, implementsUnambiguousName_result); 104 107 } 105 108 106 109 @Override 107 public Node forParamOnly(Param that, Id name_result,110 public Node forParamOnly(Param that, ASTNodeInfo info, Id name_result, 108 111 Option<Type> type_result, 109 112 Option<Expr> defaultExpr_result, … … 116 119 type_result; 117 120 118 return super.forParamOnly(that, name_result, new_type,121 return super.forParamOnly(that, info, name_result, new_type, 119 122 defaultExpr_result, varargsType_result); 120 123 } else -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeAnalyzer.java
r3239 r3246 356 356 357 357 @Override public Effect forEffectOnly(Effect e, 358 ASTNodeInfo info_result, 358 359 Option<List<BaseType>> normalThrows) { 359 360 if (normalThrows.isNone()) { return e; } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeChecker.java
r3241 r3246 2031 2031 @Override 2032 2032 public TypeCheckerResult forComponentOnly(Component that, 2033 TypeCheckerResult info, 2033 2034 TypeCheckerResult name_result, 2034 2035 List<TypeCheckerResult> imports_result, … … 2053 2054 @Override 2054 2055 public TypeCheckerResult forContractOnly(Contract that, 2056 TypeCheckerResult info, 2055 2057 Option<List<TypeCheckerResult>> requires_result, 2056 2058 Option<List<TypeCheckerResult>> ensures_result, … … 2869 2871 @Override 2870 2872 public TypeCheckerResult forIntArgOnly(IntArg that, 2873 TypeCheckerResult info, 2871 2874 TypeCheckerResult val_result) { 2872 2875 return new TypeCheckerResult(that); … … 3447 3450 @Override 3448 3451 public TypeCheckerResult forIntBaseOnly(IntBase that, 3452 TypeCheckerResult info, 3449 3453 TypeCheckerResult val_result) { 3450 3454 return new TypeCheckerResult(that); -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/ExprFactory.java
r3242 r3246 46 46 public static AmbiguousMultifixOpExpr makeAmbiguousMultifixOpExpr(AmbiguousMultifixOpExpr that, 47 47 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(), 51 50 that.getArgs()); 52 51 } … … 56 55 FunctionalRef multifix_op, 57 56 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, 60 59 args); 61 60 } 62 61 63 public static AmbiguousMultifixOpExpr makeAmbiguousMultifixOpExpr(Span span, 64 ExprInfo info, 62 public static AmbiguousMultifixOpExpr makeAmbiguousMultifixOpExpr(ExprInfo info, 65 63 FunctionalRef infix_op, 66 64 FunctionalRef multifix_op, 67 65 List<Expr> args) { 68 return new AmbiguousMultifixOpExpr( span,info, infix_op, multifix_op, args);66 return new AmbiguousMultifixOpExpr(info, infix_op, multifix_op, args); 69 67 } 70 68 … … 78 76 List<StaticArg> staticArgs, 79 77 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); 82 80 } 83 81 … … 110 108 List<ArrayExpr> elems, 111 109 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, 114 112 outermost); 115 113 } … … 125 123 FunctionalRef infix, Expr front, 126 124 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); 129 127 } 130 128 … … 166 164 List<StaticArg> staticArgs, 167 165 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); 170 168 } 171 169 … … 230 228 Option<Type> ty, FunctionalRef op, 231 229 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); 234 232 } 235 233 … … 281 279 List<Expr> exprs, boolean isFnApp, 282 280 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); 285 283 } 286 284 … … 288 286 Option<Type> ty, Expr expr, 289 287 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, 295 293 Expr expr, 296 294 List<StaticArg> sargs) { 297 return new _RewriteFnRef( span,info, expr, sargs);295 return new _RewriteFnRef(info, expr, sargs); 298 296 } 299 297 … … 384 382 Option<List<FunctionalRef>> overloadings, 385 383 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, 388 386 lexicalDepth, name, names, overloadings, overloadingType); 389 387 } … … 428 426 Option<List<FunctionalRef>> overloadings, 429 427 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, 432 430 lexicalDepth, name, names, overloadings, overloadingType); 433 431 } 434 432 435 433 public static _RewriteObjectExprRef make_RewriteObjectExprRef(_RewriteObjectExpr rwoe) { 436 return new _RewriteObjectExprRef( NodeUtil.getSpan(rwoe),rwoe.getInfo(),434 return new _RewriteObjectExprRef(rwoe.getInfo(), 437 435 rwoe.getGenSymName(), rwoe.getStaticArgs()); 438 436 } … … 515 513 Option<Type> ty, Id varId, 516 514 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, 519 517 lexicalDepth); 520 518 } … … 573 571 String text, 574 572 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); 577 575 } 578 576 … … 587 585 String text, 588 586 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); 591 589 } 592 590 … … 599 597 Option<Type> ty, 600 598 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); 603 601 } 604 602 … … 646 644 Option<Op> op, 647 645 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); 650 648 } 651 649 … … 708 706 List<LValue> lhs, 709 707 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); 712 710 } 713 711 … … 730 728 Expr body) { 731 729 return makeFnExpr(span, false, Option.<Type>none(), 732 newAnonymousFnName(span, Option.<APIName>none()),730 makeAnonymousFnName(span, Option.<APIName>none()), 733 731 Collections.<StaticParam>emptyList(), params, 734 732 returnType, Option.<WhereClause>none(), … … 750 748 Option.<Contract>none(), params, 751 749 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); 754 757 } 755 758 … … 773 776 Option<Id> targetOp, 774 777 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); 777 780 } 778 781 … … 789 792 List<StaticArg> staticArgs, 790 793 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); 793 796 } 794 797 … … 809 812 List<GeneratorClause> gens, 810 813 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); 813 816 } 814 817 … … 834 837 List<TypecaseClause> clauses, 835 838 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); 838 841 } 839 842 … … 859 862 List<KeywordExpr> keywords, 860 863 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); 863 866 } 864 867 … … 879 882 List<BaseType> forbidClause, 880 883 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); 883 886 } 884 887 … … 904 907 Option<Type> ty, 905 908 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); 908 911 } 909 912 … … 960 963 List<StaticArg> staticArgs, 961 964 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, 964 967 implicitTypeParameters, genSymName, 965 968 staticArgs, params); … … 999 1002 Expr rhs, 1000 1003 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); 1003 1006 } 1004 1007 … … 1039 1042 boolean withinDo, 1040 1043 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); 1043 1046 } 1044 1047 … … 1075 1078 public static If makeIf(Span sp, Expr cond, Block _then, Block _else) { 1076 1079 return makeIf(sp, 1077 new IfClause(NodeFactory.makeSpan (cond, _else),1080 new IfClause(NodeFactory.makeSpanInfo(NodeFactory.makeSpan(cond, _else)), 1078 1081 makeGeneratorClause(NodeUtil.getSpan(cond), cond), 1079 1082 _then), … … 1083 1086 public static If makeIf(Span sp, Expr cond, Block _then) { 1084 1087 return makeIf(sp, 1085 new IfClause(NodeFactory.makeSpan (cond, _then),1088 new IfClause(NodeFactory.makeSpanInfo(NodeFactory.makeSpan(cond, _then)), 1086 1089 makeGeneratorClause(NodeUtil.getSpan(cond), cond), 1087 1090 _then)); … … 1093 1096 List<IfClause> clauses, 1094 1097 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); 1097 1100 } 1098 1101 … … 1116 1119 List<CaseClause> clauses, 1117 1120 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, 1120 1123 equalsOp, inOp, clauses, elseClause); 1121 1124 } … … 1123 1126 public static ChainExpr makeChainExpr(Expr e, Op _op, Expr _expr) { 1124 1127 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); 1126 1130 links.add(link); 1127 1131 return makeChainExpr(NodeFactory.makeSpan(e, _expr), e, links); … … 1130 1134 public static ChainExpr makeChainExpr(Span sp, Expr e, Op _op, Expr _expr) { 1131 1135 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)), 1133 1137 makeOpRef(NodeFactory.makeOpInfix(_op)), _expr); 1134 1138 links.add(link); … … 1145 1149 Option<Type> ty, 1146 1150 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); 1149 1153 } 1150 1154 … … 1159 1163 Expr function, 1160 1164 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); 1163 1167 } 1164 1168 … … 1191 1195 Option<Type> ty, 1192 1196 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); 1195 1199 } 1196 1200 … … 1203 1207 Option<Type> ty, 1204 1208 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); 1207 1211 } 1208 1212 … … 1218 1222 List<GeneratorClause> gens, 1219 1223 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); 1222 1226 } 1223 1227 … … 1231 1235 Option<Type> ty, 1232 1236 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); 1235 1239 } 1236 1240 … … 1245 1249 Option<Type> ty, 1246 1250 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); 1249 1253 } 1250 1254 … … 1261 1265 List<Expr> body, 1262 1266 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); 1265 1269 } 1266 1270 … … 1279 1283 Option<Type> ty, 1280 1284 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); 1283 1287 } 1284 1288 … … 1291 1295 Option<Type> ty, 1292 1296 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); 1295 1299 } 1296 1300 … … 1303 1307 int denomBase, 1304 1308 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, 1307 1311 intPart, numerator, denomBase, denomPower); 1308 1312 } … … 1317 1321 Option<Type> ty, 1318 1322 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); 1321 1325 } 1322 1326 … … 1330 1334 Option<Type> ty, 1331 1335 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); 1334 1338 } 1335 1339 … … 1352 1356 GeneratorClause testExpr, 1353 1357 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); 1356 1360 } 1357 1361 … … 1365 1369 Option<Type> ty, 1366 1370 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); 1369 1373 } 1370 1374 … … 1391 1395 Option<Type> ty, 1392 1396 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); 1395 1399 } 1396 1400 … … 1504 1508 1505 1509 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); 1509 1513 } 1510 1514 1511 1515 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); 1513 1517 } 1514 1518 … … 1735 1739 } 1736 1740 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()); 1738 1743 } 1739 1744 … … 1824 1829 1825 1830 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); 1827 1832 } 1828 1833 1829 1834 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); 1831 1836 } 1832 1837 1833 1838 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); 1835 1840 } 1836 1841 1837 1842 public static TemplateGapFnExpr makeTemplateGapFnExpr(Span s, Id id, List<Id> params) { 1838 1843 Expr body = makeVarRef(id); 1839 return new TemplateGapFnExpr( s, id, params);1844 return new TemplateGapFnExpr(NodeFactory.makeExprInfo(s), id, params); 1840 1845 } 1841 1846 1842 1847 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); 1844 1849 } 1845 1850 1846 1851 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); 1848 1853 } 1849 1854 1850 1855 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); 1852 1857 } 1853 1858 1854 1859 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); 1856 1861 } 1857 1862 1858 1863 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); 1860 1865 } 1861 1866 1862 1867 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); 1864 1869 } 1865 1870 1866 1871 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); 1868 1873 } 1869 1874 1870 1875 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); 1872 1877 } 1873 1878 1874 1879 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); 1876 1881 } 1877 1882 1878 1883 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); 1880 1885 } 1881 1886 -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/NodeFactory.java
r3243 r3246 148 148 } 149 149 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 } 151 157 152 158 public static Component makeComponent(Span span, APIName name, … … 162 168 boolean isNative, 163 169 List<APIName> exports) { 164 return new Component( span, name, imports, decls, isNative, exports);170 return new Component(makeSpanInfo(span), name, imports, decls, isNative, exports); 165 171 } 166 172 … … 189 195 190 196 public static AliasedSimpleName makeAliasedSimpleName(IdOrOpOrAnonymousName name) { 191 return newAliasedSimpleName(NodeUtil.getSpan(name), name,197 return makeAliasedSimpleName(NodeUtil.getSpan(name), name, 192 198 Option.<IdOrOpOrAnonymousName>none()); 193 199 } … … 195 201 public static AliasedSimpleName makeAliasedSimpleName(IdOrOpOrAnonymousName name, 196 202 IdOrOpOrAnonymousName alias) { 197 return newAliasedSimpleName(FortressUtil.spanTwo(name, alias), name,203 return makeAliasedSimpleName(FortressUtil.spanTwo(name, alias), name, 198 204 Option.<IdOrOpOrAnonymousName>some(alias)); 199 205 } 200 206 207 public static AliasedSimpleName makeAliasedSimpleName(Span span, 208 IdOrOpOrAnonymousName name, 209 Option<IdOrOpOrAnonymousName> alias) { 210 return new AliasedSimpleName(makeSpanInfo(span), name, alias); 211 } 212 201 213 public static AliasedAPIName makeAliasedAPIName(APIName api) { 202 return newAliasedAPIName(NodeUtil.getSpan(api), api, Option.<Id>none());214 return makeAliasedAPIName(NodeUtil.getSpan(api), api, Option.<Id>none()); 203 215 } 204 216 205 217 public static AliasedAPIName makeAliasedAPIName(APIName api, Id alias) { 206 return newAliasedAPIName(FortressUtil.spanTwo(api, alias), api,218 return makeAliasedAPIName(FortressUtil.spanTwo(api, alias), api, 207 219 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); 208 225 } 209 226 … … 229 246 Option.<Contract>none(), 230 247 extendsC, decls); 231 return new TraitDecl( span, header, excludesC, comprisesC);248 return new TraitDecl(makeSpanInfo(span), header, excludesC, comprisesC); 232 249 } 233 250 … … 278 295 throwsC, contract, extendsC, 279 296 decls); 280 return new ObjectDecl( span, header, params);297 return new ObjectDecl(makeSpanInfo(span), header, params); 281 298 } 282 299 … … 360 377 FnHeader header = makeFnHeader(mods, name, staticParams, whereC, throwsC, 361 378 contract, params, returnType); 362 return new FnDecl( span, header, unambiguousName, body, implementsUnambiguousName);379 return new FnDecl(makeSpanInfo(span), header, unambiguousName, body, implementsUnambiguousName); 363 380 } 364 381 … … 369 386 public static DimDecl makeDimDecl(Span span, Id dim, Option<Type> derived, 370 387 Option<Id> defaultId) { 371 return new DimDecl( span, dim, derived, defaultId);388 return new DimDecl(makeSpanInfo(span), dim, derived, defaultId); 372 389 } 373 390 374 391 public static UnitDecl makeUnitDecl(Span span, boolean si_unit, List<Id> units, 375 392 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); 377 394 } 378 395 … … 466 483 public static LValue makeLValue(Span span, Id name, Modifiers mods, 467 484 Option<Type> type, boolean mutable) { 468 return new LValue( span, name, mods, type, mutable);485 return new LValue(makeSpanInfo(span), name, mods, type, mutable); 469 486 } 470 487 … … 541 558 Option<Type> type, Option<Expr> expr, 542 559 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, 553 581 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, 578 605 List<StaticParam> sparams, 579 606 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); 597 608 } 598 609 … … 613 624 List<StaticParam> sparams, 614 625 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); 617 628 } 618 629 … … 634 645 Option<Type> varargs, 635 646 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); 638 649 } 639 650 … … 647 658 Type elem, DimExpr dim, 648 659 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); 651 662 } 652 663 … … 715 726 Id name, List<StaticArg> sargs, 716 727 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); 719 730 } 720 731 … … 738 749 public static VarType makeVarType(Span span, boolean parenthesized, 739 750 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); 742 753 } 743 754 … … 748 759 public static DimBinaryOp makeDimBinaryOp(Span span, boolean parenthesized, 749 760 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); 752 763 } 753 764 … … 758 769 public static DimUnaryOp makeDimUnaryOp(Span span, boolean parenthesized, 759 770 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); 762 773 } 763 774 … … 769 780 public static DimExponent makeDimExponent(Span span, boolean parenthesized, 770 781 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); 773 784 } 774 785 … … 782 793 783 794 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); 786 797 } 787 798 788 799 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); 791 802 } 792 803 … … 801 812 public static FixedPointType makeFixedPointType(Span span, boolean parenthesized, 802 813 _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); 805 816 } 806 817 … … 817 828 public static UnionType makeUnionType(Span span, boolean parenthesized, 818 829 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); 821 832 } 822 833 … … 832 843 833 844 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); 836 847 } 837 848 … … 867 878 public static MatrixType makeMatrixType(Span span, boolean parenthesized, 868 879 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); 871 882 } 872 883 … … 890 901 public static ArrayType makeArrayType(Span span, boolean parenthesized, 891 902 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); 894 905 } 895 906 … … 911 922 public static IntersectionType makeIntersectionType(Span span, boolean parenthesized, 912 923 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); 915 926 } 916 927 … … 948 959 return makeEffect(span, Option.<List<BaseType>>none(), ioEffect); 949 960 } 961 950 962 951 963 public static Effect makeEffect(Span span, Option<List<BaseType>> throwsC, … … 969 981 public static TraitTypeWhere makeTraitTypeWhere(Span span, BaseType type, 970 982 Option<WhereClause> where) { 971 return new TraitTypeWhere(span, type, where); 983 SpanInfo info = makeSpanInfo(span); 984 return new TraitTypeWhere(info, type, where); 972 985 } 973 986 … … 984 997 public static AnonymousFnName makeAnonymousFnName(Span span, 985 998 Option<APIName> api) { 986 return new AnonymousFnName(makeSpanInfo(span), api); 999 SpanInfo info = makeSpanInfo(span); 1000 return new AnonymousFnName(info, api); 987 1001 } 988 1002 … … 992 1006 993 1007 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); 995 1010 } 996 1011 … … 1124 1139 1125 1140 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); 1127 1143 } 1128 1144 … … 1157 1173 public static BoolRef makeBoolRef(Span span, boolean parenthesized, 1158 1174 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); 1160 1177 } 1161 1178 … …
