Changeset 3202
- Timestamp:
- 12/12/08 08:05:55 (12 months ago)
- Location:
- trunk/ProjectFortress
- Files:
-
- 23 modified
-
astgen/Fortress.ast (modified) (5 diffs)
-
src/com/sun/fortress/compiler/Types.java (modified) (5 diffs)
-
src/com/sun/fortress/compiler/desugarer/ObjectExpressionVisitor.java (modified) (1 diff)
-
src/com/sun/fortress/compiler/disambiguator/TypeDisambiguator.java (modified) (2 diffs)
-
src/com/sun/fortress/compiler/typechecker/FnTypeEnv.java (modified) (1 diff)
-
src/com/sun/fortress/compiler/typechecker/ObjectTypeEnv.java (modified) (3 diffs)
-
src/com/sun/fortress/compiler/typechecker/TypeAnalyzer.java (modified) (2 diffs)
-
src/com/sun/fortress/compiler/typechecker/TypeAnalyzerJUTest.java (modified) (3 diffs)
-
src/com/sun/fortress/compiler/typechecker/TypeChecker.java (modified) (1 diff)
-
src/com/sun/fortress/compiler/typechecker/TypeCheckerTestCase.java (modified) (1 diff)
-
src/com/sun/fortress/compiler/typechecker/TypeEnv.java (modified) (1 diff)
-
src/com/sun/fortress/compiler/typechecker/TypesUtil.java (modified) (2 diffs)
-
src/com/sun/fortress/interpreter/evaluator/types/FTypeGeneric.java (modified) (2 diffs)
-
src/com/sun/fortress/interpreter/rewrite/DesugarerVisitor.java (modified) (1 diff)
-
src/com/sun/fortress/interpreter/rewrite/RewriteInPresenceOfTypeInfoVisitor.java (modified) (2 diffs)
-
src/com/sun/fortress/nodes_util/ExprFactory.java (modified) (2 diffs)
-
src/com/sun/fortress/nodes_util/NodeFactory.java (modified) (16 diffs)
-
src/com/sun/fortress/parser/NoNewlineType.rats (modified) (1 diff)
-
src/com/sun/fortress/parser/OtherDecl.rats (modified) (1 diff)
-
src/com/sun/fortress/parser/Type.rats (modified) (4 diffs)
-
src/com/sun/fortress/parser_util/precedence_resolver/TypeResolver.java (modified) (7 diffs)
-
src/com/sun/fortress/syntax_abstractions/phases/TemplateVarRewriterJUTest.java (modified) (10 diffs)
-
src/com/sun/fortress/syntax_abstractions/util/FortressTypeToJavaTypeJUTest.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ProjectFortress/astgen/Fortress.ast
r3200 r3202 1000 1000 * e.g.) T 1001 1001 */ 1002 VarType(int lexicalDepth =-2147483648);1002 VarType(int lexicalDepth); 1003 1003 /** 1004 1004 * a trait (object, alias, or proper trait) type; traits … … 1012 1012 * used during static checking 1013 1013 */ 1014 TraitType(List<StaticArg> args 1015 = Collections.<StaticArg>emptyList(), 1014 TraitType(List<StaticArg> args, 1016 1015 List<StaticParam> staticParams); 1017 1016 /** … … 1037 1036 * e.g.) RR64 Length 1038 1037 */ 1039 TaggedDimType(DimExpr dimExpr, 1040 Option<Expr> unitExpr = Option.<Expr>none()); 1038 TaggedDimType(DimExpr dimExpr, Option<Expr> unitExpr); 1041 1039 /** 1042 1040 * type with unit … … 1067 1065 * It has a varargs parameter if the varargs field is set. 1068 1066 */ 1069 TupleType(List<Type> elements, 1070 Option<Type> varargs = Option.<Type>none(), 1071 List<KeywordType> keywords = Collections.<KeywordType>emptyList()); 1067 TupleType(List<Type> elements, Option<Type> varargs, 1068 List<KeywordType> keywords); 1072 1069 /** 1073 1070 * arrow type … … 1079 1076 * type of a generic function, used during static checking 1080 1077 */ 1081 ArrowType(Type domain, Type range, 1082 Effect effect = FortressUtil.emptyEffect(), 1083 List<StaticParam> staticParams 1084 = Collections.<StaticParam>emptyList(), 1085 Option<WhereClause> whereClause 1086 = Option.<WhereClause>none()); 1078 ArrowType(Type domain, Type range, Effect effect, 1079 List<StaticParam> staticParams, 1080 Option<WhereClause> whereClause); 1087 1081 /** 1088 1082 * inferred type -
trunk/ProjectFortress/src/com/sun/fortress/compiler/Types.java
r3148 r3202 211 211 default: { 212 212 List<Type> l = CollectUtil.makeList(ts); 213 return newTupleType(NodeFactory.makeSpan("impossible", l), l);213 return NodeFactory.makeTupleType(NodeFactory.makeSpan("impossible", l), l); 214 214 } 215 215 } … … 246 246 TupleType _d = (TupleType)d; 247 247 if ( NodeUtil.hasVarargs(_d)) { 248 return new TupleType(NodeFactory.makeSpan(_d.getElements(), _d.getVarargs().unwrap()), _d.getElements(), _d.getVarargs()); 248 return NodeFactory.makeTupleType(NodeFactory.makeSpan(_d.getElements(), _d.getVarargs().unwrap()), 249 false, _d.getElements(), _d.getVarargs(), 250 Collections.<KeywordType>emptyList()); 249 251 } 250 252 else { … … 253 255 case 0: return VOID; 254 256 case 1: return args.get(0); 255 default: return newTupleType(NodeFactory.makeSpan("impossible", args), args);257 default: return NodeFactory.makeTupleType(NodeFactory.makeSpan("impossible", args), args); 256 258 } 257 259 } … … 301 303 @Override public Type forTupleType(TupleType t) { 302 304 if ( ! NodeUtil.hasVarargs(t) ) 303 return new TupleType(NodeFactory.makeSpan(t, keywords), t.getElements(), keywords); 305 return NodeFactory.makeTupleType(NodeFactory.makeSpan(t, keywords), 306 false, t.getElements(), 307 Option.<Type>none(), keywords); 304 308 else 305 return new TupleType(NodeFactory.makeSpan(t, keywords), t.getElements(), t.getVarargs(), 306 keywords); 309 return NodeFactory.makeTupleType(NodeFactory.makeSpan(t, keywords), 310 false, t.getElements(), t.getVarargs(), 311 keywords); 307 312 } 308 313 @Override public Type forType(Type t) { … … 310 315 return t; 311 316 else 312 return new TupleType(NodeFactory.makeSpan(t, keywords), Collections.singletonList(t), keywords); 317 return NodeFactory.makeTupleType(NodeFactory.makeSpan(t, keywords), false, 318 Collections.singletonList(t), 319 Option.<Type>none(), keywords); 313 320 } 314 321 }); -
trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/ObjectExpressionVisitor.java
r3199 r3202 842 842 return new IntArg(span, intRef); 843 843 } else if( NodeUtil.isTypeParam(sParam) ) { 844 VarType varType = newVarType(span, (Id)sParam.getName());844 VarType varType = NodeFactory.makeVarType(span, (Id)sParam.getName()); 845 845 return new TypeArg(span, varType); 846 846 } else { -
trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/TypeDisambiguator.java
r3176 r3202 218 218 return that; 219 219 } 220 return new TraitType(that.getSpan(), n, 221 Collections.<StaticArg>emptyList(), 222 Collections.<StaticParam>emptyList()); 220 return NodeFactory.makeTraitType(that.getSpan(), false, n); 223 221 } 224 222 } … … 260 258 } 261 259 return changed ? 262 new TraitType(that.getSpan(), n, newArgs, 263 Collections.<StaticParam>emptyList()) : that; 260 NodeFactory.makeTraitType(that.getSpan(), n, newArgs) : that; 264 261 } 265 262 } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/FnTypeEnv.java
r3176 r3202 154 154 // Invariant: _fn.params().isSome() 155 155 // Otherwise, _fn should not have been in entries. 156 overloadedTypes.add( new ArrowType(loc,156 overloadedTypes.add(NodeFactory.makeArrowType(loc, false, 157 157 domainFromParams(_fn.parameters()), 158 158 selfType, -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/ObjectTypeEnv.java
r3145 r3202 35 35 import com.sun.fortress.nodes.ArrowType; 36 36 import com.sun.fortress.nodes_util.NodeFactory; 37 import com.sun.fortress.parser_util.FortressUtil; 37 38 38 39 import edu.rice.cs.plt.tuple.Option; … … 78 79 } else { 79 80 // No static params, some normal params 80 type = newArrowType(var.getSpan(),81 type = NodeFactory.makeArrowType(var.getSpan(), 81 82 domainFromParams(decl.getParams().unwrap()), 82 83 NodeFactory.makeTraitType(_var)); … … 89 90 // Some static params, some normal params 90 91 // TODO: handle type variables bound in where clause 91 type = new ArrowType(decl.getSpan(),92 type = NodeFactory.makeArrowType(decl.getSpan(), false, 92 93 domainFromParams(decl.getParams().unwrap()), 93 94 NodeFactory.makeTraitType(_var, TypeEnv.staticParamsToArgs(decl.getStaticParams())), 95 FortressUtil.emptyEffect(), 94 96 decl.getStaticParams(), 95 97 decl.getWhereClause()); -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeAnalyzer.java
r3176 r3202 274 274 List<Type> elts = makeList(skipLast(ts)); 275 275 Type varargs = last(ts); 276 return new TupleType(NodeFactory.makeSpan(elts, varargs), 277 elts, Option.<Type>some(varargs)); 276 return NodeFactory.makeTupleType(NodeFactory.makeSpan(elts, varargs), 277 false, elts, Option.<Type>some(varargs), 278 Collections.<KeywordType>emptyList()); 278 279 } 279 280 } … … 340 341 Iterable<Type> overloads = cross(domains, ranges, new Lambda2<Type, Type, Type>() { 341 342 public Type value(Type d, Type r) { 342 return newArrowType(NodeFactory.makeSetSpan(d,r), d, r, normalEffect);343 return NodeFactory.makeArrowType(NodeFactory.makeSetSpan(d,r), d, r, normalEffect); 343 344 } 344 345 }); -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeAnalyzerJUTest.java
r3184 r3202 521 521 Type r = parseType(s.substring(opIndex+2, effectStart)); 522 522 Effect e = parseEffect(s.substring(effectStart)); 523 return newArrowType(span, d, r, e);523 return NodeFactory.makeArrowType(span, d, r, e); 524 524 } 525 525 … … 548 548 if (varargs) { s = s.substring(0, s.length()-4) + ")"; } 549 549 List<Type> ts = parseTypeList(s, "(", ")"); 550 if (varargs) { return new TupleType(span, ts, Option.<Type>some(ts.remove(ts.size()-1))); } 550 if (varargs) { return NodeFactory.makeTupleType(span, false, ts, 551 Option.<Type>some(ts.remove(ts.size()-1)), 552 Collections.<KeywordType>emptyList()); } 551 553 else if (ts.size() == 0) { return VOID; } 552 554 else if (ts.size() == 1) { return ts.get(0); } 553 else { return newTupleType(span, ts); }555 else { return NodeFactory.makeTupleType(span, ts); } 554 556 } 555 557 … … 597 599 } 598 600 } 599 return new TupleType(span, args, varargs, keys);601 return NodeFactory.makeTupleType(span, false, args, varargs, keys); 600 602 } 601 603 else { -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeChecker.java
r3200 r3202 2401 2401 if(varargs){ 2402 2402 Type var = dlist.remove(dlist.size()-1); 2403 domain = new TupleType(that.getSpan(), dlist, Option.<Type>some(var)); 2403 domain = NodeFactory.makeTupleType(that.getSpan(), false, dlist, 2404 Option.<Type>some(var), 2405 Collections.<KeywordType>emptyList()); 2404 2406 } 2405 2407 else{ -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeCheckerTestCase.java
r3184 r3202 65 65 Type left = parseType(s.substring(0, arrowIndex)); 66 66 Type right = parseType(s.substring(arrowIndex+2)); 67 return newArrowType(span, left, right);67 return NodeFactory.makeArrowType(span, left, right); 68 68 } 69 69 if (s.startsWith("(")) { -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeEnv.java
r3176 r3202 142 142 143 143 protected static ArrowType genericArrowFromDecl(FnDecl decl) { 144 return new ArrowType(decl.getSpan(),144 return NodeFactory.makeArrowType(decl.getSpan(), false, 145 145 domainFromParams(decl.getParams()), 146 146 // all types have been filled in at this point -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypesUtil.java
r3176 r3202 107 107 case 0: return Types.VOID; 108 108 case 1: return _args.get(0); 109 default: return newTupleType(NodeFactory.makeSpan("impossible", _args), _args);109 default: return NodeFactory.makeTupleType(NodeFactory.makeSpan("impossible", _args), _args); 110 110 } 111 111 } … … 431 431 if(constraints.isSome()) { 432 432 ArrowType temp = (ArrowType) that.accept(new StaticTypeReplacer(that.getStaticParams(),static_args)); 433 Type new_type = newArrowType(temp.getSpan(),temp.isParenthesized(),433 Type new_type = NodeFactory.makeArrowType(temp.getSpan(),temp.isParenthesized(), 434 434 temp.getDomain(),temp.getRange(), temp.getEffect(), 435 435 Collections.<StaticParam>emptyList(), -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/types/FTypeGeneric.java
r3176 r3202 146 146 List<StaticArg> statics = paramsToArgs(); 147 147 Id in = NodeFactory.makeId(def.getSpan(), name); 148 TraitType inst_type = new TraitType(NodeFactory.makeSpan(in, statics), in, statics, 149 Collections.<StaticParam>emptyList()); 148 TraitType inst_type = NodeFactory.makeTraitType(NodeFactory.makeSpan(in, statics), 149 false, in, statics, 150 Collections.<StaticParam>emptyList()); 150 151 return inst_type; 151 152 } … … 164 165 private TypeArg idNameToTypeArg(Id idn) { 165 166 return new TypeArg(idn.getSpan(), 166 newVarType(idn.getSpan(), idn));167 NodeFactory.makeVarType(idn.getSpan(), idn)); 167 168 } 168 169 -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/rewrite/DesugarerVisitor.java
r3200 r3202 1119 1119 WellKnownNames.thread)); 1120 1120 List<StaticArg> args = new ArrayList<StaticArg>(); 1121 args.add(new TypeArg(sp, newVarType(sp,1122 NodeFactory.makeId(sp,WellKnownNames.anyTypeLibrary, WellKnownNames.anyTypeName),1123 Environment.TOP_LEVEL)));1121 args.add(new TypeArg(sp,NodeFactory.makeVarType(sp, 1122 NodeFactory.makeId(sp,WellKnownNames.anyTypeLibrary, WellKnownNames.anyTypeName), 1123 Environment.TOP_LEVEL))); 1124 1124 1125 1125 _RewriteFnRef fn = new _RewriteFnRef(s.getSpan(), false, Option.<Type>none(), -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/rewrite/RewriteInPresenceOfTypeInfoVisitor.java
r3192 r3202 32 32 import com.sun.fortress.nodes._RewriteFnRef; 33 33 import com.sun.fortress.nodes_util.ExprFactory; 34 import com.sun.fortress.nodes_util.NodeFactory; 34 35 import static com.sun.fortress.exceptions.InterpreterBug.bug; 35 36 … … 71 72 public Node forTraitType(TraitType it) { 72 73 if (it.getArgs().size() == 0) { 73 return ( newVarType(it.getSpan(), it.getName())).accept(this);74 return (NodeFactory.makeVarType(it.getSpan(), it.getName())).accept(this); 74 75 } 75 76 return super.forTraitType(it); -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/ExprFactory.java
r3200 r3202 42 42 private static FunctionalRef multiJuxt = makeMultiJuxt(); 43 43 private static FunctionalRef infixJuxt = makeInfixJuxt(); 44 p rivatestatic int lexicalDepth = -2147483648;44 public static int lexicalDepth = -2147483648; 45 45 46 46 public static ArrayElement makeArrayElement(Expr elem) { … … 1285 1285 return new Do(span, parenthesized, exprType, fronts); 1286 1286 } 1287 1288 1289 1290 /*1291 public static TupleExpr makeTupleExpr(Span span,1292 boolean parenthesized,1293 Option<Type> exprType,1294 */1295 1296 /***************************************************************************************/1297 1287 1298 1288 public static FloatLiteralExpr makeFloatLiteralExpr(Span span, String s) { -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/NodeFactory.java
r3193 r3202 37 37 38 38 public class NodeFactory { 39 public static int lexicalDepth = -2147483648; 40 39 41 /** 40 42 * For use only when there is no hope of … … 506 508 } 507 509 510 public static ArrowType makeArrowType(Span span, Type domain, Type range, 511 Effect effect) { 512 return makeArrowType(span, false, domain, range, effect, 513 Collections.<StaticParam>emptyList(), 514 Option.<WhereClause>none()); 515 } 516 517 public static ArrowType makeArrowType(Span span, Type domain, Type range) { 518 return makeArrowType(span, domain, range, 519 makeEffect(range.getSpan().getEnd())); 520 } 521 522 public static ArrowType makeArrowType(Span span, boolean parenthesized, 523 Type domain, Type range, Effect effect, 524 List<StaticParam> sparams, 525 Option<WhereClause> where) { 526 return new ArrowType(span, parenthesized, domain, range, effect, 527 sparams, where); 528 } 529 530 public static TupleType makeTupleType(TupleType t, List<Type> tys) { 531 return makeTupleType(t.getSpan(), tys); 532 } 533 534 public static TupleType makeTupleType(List<Type> elements) { 535 return makeTupleType(new Span(), elements); 536 } 537 538 public static TupleType makeTupleType(Span span, List<Type> elements) { 539 return makeTupleType(span, false, elements, Option.<Type>none(), 540 Collections.<KeywordType>emptyList()); 541 } 542 543 public static TupleType makeTupleType(Span span, boolean parenthesized, 544 List<Type> elements, 545 Option<Type> varargs, 546 List<KeywordType> keywords) { 547 return new TupleType(span, parenthesized, elements, varargs, keywords); 548 } 549 550 public static TaggedDimType makeTaggedDimType(TaggedDimType t, Type s, 551 DimExpr u) { 552 return makeTaggedDimType(t.getSpan(), t.isParenthesized(), s, u, 553 t.getUnitExpr()); 554 } 555 556 public static TaggedDimType makeTaggedDimType(Span span, boolean parenthesized, 557 Type elem, DimExpr dim, 558 Option<Expr> unit) { 559 return new TaggedDimType(span, parenthesized, elem, dim, unit); 560 } 561 562 public static TraitType makeTraitType(TraitType original) { 563 return makeTraitType(original.getSpan(), original.isParenthesized(), 564 original.getName(), original.getArgs(), 565 Collections.<StaticParam>emptyList()); 566 567 } 568 569 public static TraitType makeTraitType(TraitType t, 570 List<StaticArg> args) { 571 return makeTraitType(t.getSpan(), t.isParenthesized(), 572 t.getName(), args); 573 } 574 575 public static TraitType makeTraitType(Id name, StaticArg... args) { 576 return makeTraitType(name.getSpan(), false, name, Arrays.asList(args)); 577 } 578 579 /** Signature separates the first element in order to guarantee a non-empty arg list. */ 580 public static TraitType makeTraitType(String nameFirst, String... nameRest) { 581 // System.err.println("Please don't makeTraitType with a bogus span"); 582 return makeTraitType(new Span(), false, makeId(nameFirst, nameRest)); 583 } 584 585 public static TraitType makeTraitType(String name, 586 List<StaticArg> sargs) { 587 // System.err.println("Please don't makeTraitType with a bogus span"); 588 return makeTraitType(new Span(), false, makeId(name), sargs); 589 } 590 591 public static TraitType makeTraitType(Span span, boolean isParenthesized, 592 Id name) { 593 return makeTraitType(span, isParenthesized, name, 594 Collections.<StaticArg>emptyList()); 595 } 596 597 public static TraitType makeTraitType(Span span, boolean isParenthesized, 598 Id name, StaticArg... args) { 599 return makeTraitType(span, isParenthesized, name, Arrays.asList(args)); 600 } 601 602 public static TraitType makeTraitType(Span span, boolean isParenthesized, 603 Id name, List<StaticArg> args) { 604 return makeTraitType(span, isParenthesized, name, args, 605 Collections.<StaticParam>emptyList()); 606 } 607 608 public static TraitType makeTraitType(Span span, Id name, 609 List<StaticArg> args) { 610 return makeTraitType(span, false, name, args, 611 Collections.<StaticParam>emptyList()); 612 } 613 614 public static TraitType makeTraitType(Id name, 615 List<StaticArg> sargs) { 616 return makeTraitType(name.getSpan(), false, name, sargs); 617 } 618 619 public static TraitType makeTraitType(Id name) { 620 return makeTraitType(name.getSpan(), false, name); 621 } 622 623 public static TraitType makeTraitType(Span span, boolean parenthesized, 624 Id name, List<StaticArg> sargs, 625 List<StaticParam> sparams) { 626 return new TraitType(span, parenthesized, name, sargs, sparams); 627 } 628 629 public static VarType makeVarType(String string) { 630 return makeVarType(new Span(), makeId(string)); 631 } 632 633 public static VarType makeVarType(Span span, Id id) { 634 return makeVarType(span, false, id, lexicalDepth); 635 } 636 637 public static VarType makeVarType(Span span, Id id, int depth) { 638 return makeVarType(span, false, id, depth); 639 } 640 641 public static VarType makeVarType(VarType original, int lexicalNestedness) { 642 return makeVarType(original.getSpan(), original.isParenthesized(), 643 original.getName(), lexicalNestedness); 644 } 645 646 public static VarType makeVarType(Span span, boolean parenthesized, 647 Id name, int lexicalDepth) { 648 return new VarType(span, parenthesized, name, lexicalDepth); 649 } 650 508 651 /***************************************************************************/ 509 652 510 /*511 public static Param makeParam(Span span, Id name, Option<Type> type) {512 return new Param(span, name, type);513 }514 515 public static Param makeParam(Span span, List<Modifier> mods, Id name,516 Type type) {517 return new Param(span, name, mods, Option.some(type), Option.<Expr>none());518 }519 520 public static Param makeParam(Span span, List<Modifier> mods, Id name,521 Option<Type> type) {522 return new Param(span, name, mods, type, Option.<Expr>none());523 }524 525 public static LValue makeLValue(Id name, Type type) {526 return new LValue(new Span(name.getSpan(), type.getSpan()),527 name,528 Collections.<Modifier>emptyList(),529 Option.some(type),530 false);531 }532 533 public static LValue makeLValue(Id name, Option<Type> type) {534 return new LValue(name.getSpan(),535 name,536 Collections.<Modifier>emptyList(),537 type,538 false);539 }540 541 public static LValue makeLValue(Param param) {542 return new LValue(param.getSpan(), param.getName(),543 param.getMods(), param.getIdType(), false);544 }545 */546 653 547 654 public static Id makeTemporaryId() { … … 600 707 } 601 708 602 public static TraitType makeTraitType(TraitType t,603 List<StaticArg> args) {604 return new TraitType(t.getSpan(), t.isParenthesized(),605 t.getName(), args,606 Collections.<StaticParam>emptyList());607 }608 609 709 public static TraitTypeWhere makeTraitTypeWhere(BaseType in_type) { 610 710 Span sp = in_type.getSpan(); … … 630 730 } 631 731 632 public static TupleType makeTupleType(TupleType t, List<Type> tys) {633 return new TupleType(t.getSpan(), t.isParenthesized(), tys);634 }635 636 // public static ArgType makeArgType(ArgType t, List<Type> tys, Type varargs) {637 // return new ArgType(t.getSpan(), t.isParenthesized(), tys, varargs);638 // }639 640 732 public static KeywordType makeKeywordType(KeywordType t, Type s) { 641 733 return new KeywordType(t.getSpan(), t.getName(), s); 642 }643 644 public static TaggedDimType makeTaggedDimType(TaggedDimType t, Type s,645 DimExpr u) {646 return new TaggedDimType(t.getSpan(), t.isParenthesized(), s, u,647 t.getUnitExpr());648 734 } 649 735 … … 686 772 } 687 773 688 public static TraitType makeTraitType(Span span, boolean isParenthesized,689 Id name, List<StaticArg> args) {690 return new TraitType(span, isParenthesized, name, args,691 Collections.<StaticParam>emptyList());692 }693 694 public static TraitType makeTraitType(Span span, boolean isParenthesized,695 Id name, StaticArg... args) {696 return makeTraitType(span, isParenthesized, name, Arrays.asList(args));697 }698 699 public static TraitType makeTraitType(Id name, StaticArg... args) {700 return makeTraitType(name.getSpan(), false, name, Arrays.asList(args));701 }702 703 /** Signature separates the first element in order to guarantee a non-empty arg list. */704 public static TraitType makeTraitType(String nameFirst, String... nameRest) {705 // System.err.println("Please don't makeTraitType with a bogus span");706 return makeTraitType(new Span(), false, makeId(nameFirst, nameRest),707 Collections.<StaticArg>emptyList());708 }709 710 public static TraitType makeTraitType(String name,711 List<StaticArg> sargs) {712 // System.err.println("Please don't makeTraitType with a bogus span");713 return new TraitType(new Span(),makeId(name),sargs,714 Collections.<StaticParam>emptyList());715 }716 717 public static TraitType makeTraitType(Id name,718 List<StaticArg> sargs) {719 return new TraitType(name.getSpan(), name, sargs,720 Collections.<StaticParam>emptyList());721 }722 723 public static TraitType makeTraitType(Id name) {724 return new TraitType(name.getSpan(), name, Collections.<StaticArg>emptyList(),725 Collections.<StaticParam>emptyList());726 }727 728 774 public static IntersectionType makeIntersectionType(Type t1, Type t2) { 729 775 return new IntersectionType(FortressUtil.spanTwo(t1, t2), Arrays.asList(t1, t2)); … … 741 787 return new UnionType(FortressUtil.spanAll(types),CollectUtil.makeList(types)); 742 788 } 743 744 // public static ArrowType makeArrowType(Span span, Type domain,745 // Type range,746 // Option<List<BaseType>> throws_) {747 // Option<List<Type>> throwsAsTypeList =748 // throws_.isSome() ?749 // Option.<List<Type>>some(new ArrayList<Type>(throws_.unwrap())) :750 // Option.<List<Type>>none();751 // return new ArrowType(span, domain, range, throwsAsTypeList);752 // }753 754 public static ArrowType makeArrowType(Span span, Type domain, Type range) {755 return new ArrowType(span, domain, range, makeEffect(range.getSpan().getEnd()));756 }757 758 // public static AbstractArrowType makeGenericArrowType(Span span,759 // List<StaticParam> staticParams,760 // Type domain,761 // Type range,762 // Option<List<BaseType>> throws_,763 // WhereClause where) {764 // if (staticParams.isEmpty() && where.getConstraints().isEmpty() && where.getBindings().isEmpty()) {765 // return makeArrowType(span, domain, range, throws_);766 // }767 // Option<List<Type>> throwsAsTypeList =768 // throws_.isSome() ?769 // Option.<List<Type>>some(new ArrayList<Type>(throws_.unwrap())) :770 // Option.<List<Type>>none();771 // return new _RewriteGenericArrowType(span, domain, range,772 // throwsAsTypeList, staticParams, where);773 // }774 775 // public static AbstractArrowType makeGenericArrowType(776 // Span span,777 // List<StaticParam> staticParams,778 // Type domain,779 // Type range) {780 // if (staticParams.isEmpty()) {781 // return makeArrowType(span, domain, range, Option.<List<BaseType>>none());782 // }783 // return new _RewriteGenericArrowType(span, domain, range,784 // Option.<List<Type>>none(), staticParams, new WhereClause());785 // }786 789 787 790 public static Type makeDomain(Span span, List<Type> elements, … … 795 798 return elements.get(0); 796 799 else 797 return newTupleType(span, elements);800 return makeTupleType(span, elements); 798 801 } else 799 return new TupleType(span, elements, varargs, keywords);802 return makeTupleType(span, false, elements, varargs, keywords); 800 803 } 801 804 … … 996 999 }; 997 1000 998 public static VarType makeVarType(String string) {999 return makeVarType(new Span(), makeId(string));1000 }1001 1002 public static VarType makeVarType(Span span, Id id) {1003 return new VarType(span, id);1004 }1005 1006 1001 public static MatrixType makeMatrixType(Span span, Type element, 1007 1002 ExtentRange dimension) { … … 1189 1184 } 1190 1185 1191 public static TupleType makeTupleType(List<Type> elements) {1192 return new TupleType(new Span(), elements);1193 }1194 1195 public static TupleType makeTupleType(Span span, List<Type> elements) {1196 return new TupleType(span, elements);1197 }1198 1199 1186 public static TupleType makeVoidType(Span span) { 1200 return newTupleType(span, false, Collections.<Type>emptyList(),1187 return makeTupleType(span, false, Collections.<Type>emptyList(), 1201 1188 Option.<Type>none(), 1202 1189 Collections.<KeywordType>emptyList()); … … 1208 1195 1209 1196 public static TypeArg makeTypeArg(Span span, String string) { 1210 return new TypeArg(span, newVarType(span, makeId(span, string)));1197 return new TypeArg(span, makeVarType(span, makeId(span, string))); 1211 1198 } 1212 1199 … … 1214 1201 Span span = new Span(); 1215 1202 return new TypeArg(span, 1216 newVarType(span, makeId(span, string)));1203 makeVarType(span, makeId(span, string))); 1217 1204 } 1218 1205 … … 1364 1351 return ty.accept(new NodeAbstractVisitor<Type>() { 1365 1352 public Type forArrowType(ArrowType t) { 1366 return new ArrowType(t.getSpan(), true, t.getDomain(), 1367 t.getRange(), t.getEffect()); 1353 return makeArrowType(t.getSpan(), true, t.getDomain(), 1354 t.getRange(), t.getEffect(), 1355 t.getStaticParams(), t.getWhereClause()); 1368 1356 } 1369 1357 public Type forArrayType(ArrayType t) { … … 1372 1360 } 1373 1361 public Type forVarType(VarType t) { 1374 return new VarType(t.getSpan(), true, t.getName());1362 return makeVarType(t.getSpan(), true, t.getName(), t.getLexicalDepth()); 1375 1363 } 1376 1364 public Type forMatrixType(MatrixType t) { … … 1379 1367 } 1380 1368 public Type forTraitType(TraitType t) { 1381 return newTraitType(t.getSpan(), true, t.getName(),1369 return makeTraitType(t.getSpan(), true, t.getName(), 1382 1370 t.getArgs(), t.getStaticParams()); 1383 1371 } 1384 1372 public Type forTupleType(TupleType t) { 1385 return newTupleType(t.getSpan(), true, t.getElements(),1373 return makeTupleType(t.getSpan(), true, t.getElements(), 1386 1374 t.getVarargs(), t.getKeywords()); 1387 1375 } 1388 1376 public Type forTaggedDimType(TaggedDimType t) { 1389 return newTaggedDimType(t.getSpan(), true, t.getElemType(),1377 return makeTaggedDimType(t.getSpan(), true, t.getElemType(), 1390 1378 t.getDimExpr(), t.getUnitExpr()); 1391 1379 } … … 1434 1422 public static NamedType makeNamedType(APIName api, NamedType type) { 1435 1423 if (type instanceof VarType) { 1436 return new VarType(type.getSpan(), 1437 type.isParenthesized(), 1438 makeId(api, type.getName())); 1424 return makeVarType(type.getSpan(), 1425 type.isParenthesized(), 1426 makeId(api, type.getName()), 1427 lexicalDepth); 1439 1428 } 1440 1429 else { // type instanceof TraitType 1441 1430 TraitType _type = (TraitType)type; 1442 return newTraitType(_type.getSpan(),1431 return makeTraitType(_type.getSpan(), 1443 1432 _type.isParenthesized(), 1444 1433 makeId(api, _type.getName()), … … 1449 1438 1450 1439 public static TraitType makeGenericSingletonType(Id name, List<StaticParam> params) { 1451 return new TraitType(name.getSpan(), name, Collections.<StaticArg>emptyList(), params); 1452 } 1453 1454 public static VarType makeVarType(VarType original, int lexicalNestedness) { 1455 return new VarType(original.getSpan(), original.isParenthesized(), original.getName(), lexicalNestedness); 1456 } 1457 1458 public static TraitType makeTraitType(TraitType original) { 1459 return new TraitType(original.getSpan(), original.isParenthesized(), 1460 original.getName(), original.getArgs(), 1461 Collections.<StaticParam>emptyList()); 1462 1440 return makeTraitType(name.getSpan(), false, name, 1441 Collections.<StaticArg>emptyList(), params); 1463 1442 } 1464 1443 -
trunk/ProjectFortress/src/com/sun/fortress/parser/NoNewlineType.rats
r3123 r3202 43 43 if (ty instanceof TaggedDimType) { 44 44 TaggedDimType _ty = (TaggedDimType)ty; 45 yyValue = new TaggedDimType(_ty.getSpan(), _ty.getElemType(),46 _ty.getDimExpr(), Option.some(a2));45 yyValue = NodeFactory.makeTaggedDimType(_ty.getSpan(), false, _ty.getElemType(), 46 _ty.getDimExpr(), Option.some(a2)); 47 47 } else { 48 48 yyValue = syntaxError(ty.getSpan(), -
trunk/ProjectFortress/src/com/sun/fortress/parser/OtherDecl.rats
r3186 r3202 52 52 if ( a1 instanceof Id ) { 53 53 dim = NodeFactory.makeDimDecl(span, (Id)a1, Option.wrap(a2)); 54 ty = newVarType(a1.getSpan(), (Id)a1);54 ty = NodeFactory.makeVarType(a1.getSpan(), (Id)a1); 55 55 } else { 56 56 log(span, a1 + " is not a valid dimension name."); 57 57 Id id = NodeFactory.bogusId(span); 58 58 dim = NodeFactory.makeDimDecl(span, id, Option.wrap(a2)); 59 ty = newVarType(a1.getSpan(), id);59 ty = NodeFactory.makeVarType(a1.getSpan(), id); 60 60 } 61 61 if ( a4 instanceof Id ) { -
trunk/ProjectFortress/src/com/sun/fortress/parser/Type.rats
r3167 r3202 41 41 if (ty instanceof TaggedDimType) { 42 42 TaggedDimType _ty = (TaggedDimType)ty; 43 yyValue = new TaggedDimType(_ty.getSpan(), _ty.getElemType(),44 _ty.getDimExpr(), Option.some(a2));43 yyValue = NodeFactory.makeTaggedDimType(_ty.getSpan(), false, _ty.getElemType(), 44 _ty.getDimExpr(), Option.some(a2)); 45 45 } else { 46 46 yyValue = syntaxError(ty.getSpan(), … … 209 209 / a1:Id a2:StaticArgs? 210 210 { if (a2 == null) 211 yyValue = new VarType(createSpan(yyStart,yyCount), a1); 212 else yyValue = new TraitType(createSpan(yyStart,yyCount),a1,a2, 213 Collections.<StaticParam>emptyList()); 211 yyValue = NodeFactory.makeVarType(createSpan(yyStart,yyCount), a1); 212 else yyValue = NodeFactory.makeTraitType(createSpan(yyStart,yyCount),a1,a2); 214 213 }; 215 214 … … 343 342 public Type run(Type base) { 344 343 DimExpr dim = TypeResolver.resolveOpsDim(a1); 345 return new TaggedDimType(createSpan(yyStart,yyCount), (Type)base,346 NodeFactory.makeInParentheses(dim),347 Option.<Expr>none());344 return NodeFactory.makeTaggedDimType(createSpan(yyStart,yyCount), false, 345 (Type)base, NodeFactory.makeInParentheses(dim), 346 Option.<Expr>none()); 348 347 }}; 349 348 }; … … 353 352 { yyValue = new Action<Type>() { 354 353 public Type run(Type base) { 355 return new TaggedDimType(createSpan(yyStart,yyCount), (Type)base,356 new DimRef(a1.getSpan(), a1),357 Option.<Expr>none());354 return NodeFactory.makeTaggedDimType(createSpan(yyStart,yyCount), false, 355 (Type)base, new DimRef(a1.getSpan(), a1), 356 Option.<Expr>none()); 358 357 }}; 359 358 }; -
trunk/ProjectFortress/src/com/sun/fortress/parser_util/precedence_resolver/TypeResolver.java
r3167 r3202 77 77 DimExpr dim = new DimBinaryOp(span, true, dimToDim(expr0.getDimExpr()), 78 78 dimToDim(expr2), product(span)); 79 return newTaggedDimType(span, true,80 typeToType(expr0.getElemType()), dim,81 expr0.getUnitExpr());79 return NodeFactory.makeTaggedDimType(span, true, 80 typeToType(expr0.getElemType()), dim, 81 expr0.getUnitExpr()); 82 82 } 83 83 … … 87 87 DimExpr dim = new DimBinaryOp(span, true, dimToDim(expr0.getDimExpr()), 88 88 dimToDim(expr2), quotient(span)); 89 return newTaggedDimType(span, true,90 typeToType(expr0.getElemType()), dim,91 expr0.getUnitExpr());89 return NodeFactory.makeTaggedDimType(span, true, 90 typeToType(expr0.getElemType()), dim, 91 expr0.getUnitExpr()); 92 92 } 93 93 … … 99 99 return makeProductDim(span, (TaggedDimType)first, dim); 100 100 } else { 101 return new TaggedDimType(span, true, typeToType(first), dim); 101 return NodeFactory.makeTaggedDimType(span, true, typeToType(first), dim, 102 Option.<Expr>none()); 102 103 } 103 104 } catch (TypeConvertFailure x) { … … 250 251 Type first = frame.getArg(); 251 252 if (isTypeOp(op)) { 252 return new ArrowType(spanTwo(first, last), true, 253 first, 254 typeToType(last), frame.getEffect()); 253 return NodeFactory.makeArrowType(spanTwo(first, last), first, 254 typeToType(last), frame.getEffect()); 255 255 } else { // !(isTypeOp(op)) 256 256 try { … … 614 614 } 615 615 public Type forTaggedDimType(TaggedDimType t) { 616 return newTaggedDimType(t.getSpan(), true,617 typeToType(t.getElemType()),618 makeInParentheses(dimToDim(t.getDimExpr())),619 t.getUnitExpr());616 return NodeFactory.makeTaggedDimType(t.getSpan(), true, 617 typeToType(t.getElemType()), 618 makeInParentheses(dimToDim(t.getDimExpr())), 619 t.getUnitExpr()); 620 620 } 621 621 }); … … 722 722 return dim.accept(new NodeAbstractVisitor<Type>() { 723 723 public Type forDimRef(DimRef d) { 724 return new VarType(d.getSpan(), 725 d.isParenthesized(), 726 d.getName()); 724 return NodeFactory.makeVarType(d.getSpan(), 725 d.isParenthesized(), 726 d.getName(), 727 NodeFactory.lexicalDepth); 727 728 } 728 729 public Type forDimBinaryOp(DimBinaryOp d) { 729 730 try { 730 return new TaggedDimType(d.getSpan(), 731 d.isParenthesized(), 732 makeInParentheses(dimToType(d.getLeft())), 733 dimToDim(d.getRight())); 731 return NodeFactory.makeTaggedDimType(d.getSpan(), 732 d.isParenthesized(), 733 makeInParentheses(dimToType(d.getLeft())), 734 dimToDim(d.getRight()), 735 Option.<Expr>none()); 734 736 } catch (TypeConvertFailure e) { 735 737 return error(e.getMessage()); … … 754 756 if (ty instanceof TaggedDimType) { 755 757 TaggedDimType _ty = (TaggedDimType)ty; 756 return newTaggedDimType(_ty.getSpan(),757 _ty.isParenthesized(),758 canonicalizeType(_ty.getElemType()),759 canonicalizeDim(_ty.getDimExpr()),760 _ty.getUnitExpr());758 return NodeFactory.makeTaggedDimType(_ty.getSpan(), 759 _ty.isParenthesized(), 760 canonicalizeType(_ty.getElemType()), 761 canonicalizeDim(_ty.getDimExpr()), 762 _ty.getUnitExpr()); 761 763 } else return ty; 762 764 } -
trunk/ProjectFortress/src/com/sun/fortress/syntax_abstractions/phases/TemplateVarRewriterJUTest.java
r3071 r3202 44 44 Id expr = NodeFactory.makeId("Expr"); 45 45 Map<Id,BaseType> typemap = new HashMap<Id,BaseType>(); 46 typemap.put(expr, newVarType(span, expr));46 typemap.put(expr, NodeFactory.makeVarType(span, expr)); 47 47 NTEnv ntEnv = EnvFactory.makeTestingNTEnv(typemap); 48 48 theNTEnv = ntEnv; … … 66 66 public void testRewriteVars2() { 67 67 Map<Id, BaseType> vars = new HashMap<Id, BaseType>(); 68 vars.put(NodeFactory.makeId("foo"), newVarType(span, NodeFactory.makeId(span, "Expr")));68 vars.put(NodeFactory.makeId("foo"), NodeFactory.makeVarType(span, NodeFactory.makeId(span, "Expr"))); 69 69 TemplateVarRewriter tvr = new TemplateVarRewriter(emptyGapEnv, vars); 70 70 String r = tvr.rewriteVars("foo"); 71 assertTrue(r.startsWith(TemplateVarRewriter.GAPSYNTAXPREFIX) && 71 assertTrue(r.startsWith(TemplateVarRewriter.GAPSYNTAXPREFIX) && 72 72 r.endsWith(TemplateVarRewriter.GAPSYNTAXSUFFIX)); 73 73 } … … 75 75 public void testRewriteVars3() { 76 76 Map<Id, BaseType> vars = new HashMap<Id, BaseType>(); 77 VarType expr = newVarType(span, NodeFactory.makeId(span, "Expr"));78 vars.put(NodeFactory.makeId("foo"), expr); 79 vars.put(NodeFactory.makeId("bar"), expr); 77 VarType expr = NodeFactory.makeVarType(span, NodeFactory.makeId(span, "Expr")); 78 vars.put(NodeFactory.makeId("foo"), expr); 79 vars.put(NodeFactory.makeId("bar"), expr); 80 80 vars.put(NodeFactory.makeId("Baz"), expr); 81 81 FreshName.reset(); … … 95 95 public void testRewriteVars4() { 96 96 Map<Id, BaseType> vars = new HashMap<Id, BaseType>(); 97 VarType expr = newVarType(NodeFactory.makeId("Expr"));98 vars.put(NodeFactory.makeId("foo"), expr); 99 vars.put(NodeFactory.makeId("bar"), expr); 97 VarType expr = NodeFactory.makeVarType(NodeFactory.makeId("Expr")); 98 vars.put(NodeFactory.makeId("foo"), expr); 99 vars.put(NodeFactory.makeId("bar"), expr); 100 100 vars.put(NodeFactory.makeId("Baz"), expr); 101 101 FreshName.reset(); … … 113 113 Map<Id, BaseType> vars = new HashMap<Id, BaseType>(); 114 114 TemplateVarRewriter tvr = new TemplateVarRewriter(emptyGapEnv, vars); 115 VarType expr = newVarType(NodeFactory.makeId("Expr"));116 vars.put(NodeFactory.makeId("foo"), expr); 117 vars.put(NodeFactory.makeId("bar"), expr); 115 VarType expr = NodeFactory.makeVarType(NodeFactory.makeId("Expr")); 116 vars.put(NodeFactory.makeId("foo"), expr); 117 vars.put(NodeFactory.makeId("bar"), expr); 118 118 vars.put(NodeFactory.makeId("Baz"), expr); 119 119 FreshName.reset(); … … 130 130 Map<Id, BaseType> vars = new HashMap<Id, BaseType>(); 131 131 TemplateVarRewriter tvr = new TemplateVarRewriter(emptyGapEnv, vars); 132 VarType expr = newVarType(NodeFactory.makeId("Expr"));133 vars.put(NodeFactory.makeId("foo"), expr); 134 vars.put(NodeFactory.makeId("bar"), expr); 135 vars.put(NodeFactory.makeId("Baz"), expr); 132 VarType expr = NodeFactory.makeVarType(NodeFactory.makeId("Expr")); 133 vars.put(NodeFactory.makeId("foo"), expr); 134 vars.put(NodeFactory.makeId("bar"), expr); 135 vars.put(NodeFactory.makeId("Baz"), expr); 136 136 vars.put(NodeFactory.makeId("Boz"), expr); 137 137 FreshName.reset(); … … 150 150 Map<Id, BaseType> vars = new HashMap<Id, BaseType>(); 151 151 TemplateVarRewriter tvr = new TemplateVarRewriter(emptyGapEnv, vars); 152 VarType expr = newVarType(span, NodeFactory.makeId(span, "Expr"));152 VarType expr = NodeFactory.makeVarType(span, NodeFactory.makeId(span, "Expr")); 153 153 vars.put(NodeFactory.makeId("foo"), expr); 154 154 String r = tvr.rewriteVars("foo fooo foo"); … … 164 164 Map<Id, BaseType> vars = new HashMap<Id, BaseType>(); 165 165 TemplateVarRewriter tvr = new TemplateVarRewriter(emptyGapEnv, vars); 166 VarType expr = newVarType(span, NodeFactory.makeId(span, "Expr"));166 VarType expr = NodeFactory.makeVarType(span, NodeFactory.makeId(span, "Expr")); 167 167 vars.put(NodeFactory.makeId("foo"), expr); 168 168 vars.put(NodeFactory.makeId("bar"), expr); … … 174 174 Map<Id, BaseType> vars = new HashMap<Id, BaseType>(); 175 175 TemplateVarRewriter tvr = new TemplateVarRewriter(emptyGapEnv, vars); 176 VarType expr = newVarType(span, NodeFactory.makeId(span, "Expr"));176 VarType expr = NodeFactory.makeVarType(span, NodeFactory.makeId(span, "Expr")); 177 177 vars.put(NodeFactory.makeId("e"), expr); 178 178 String r = tvr.rewriteVars("(e \" world\""); … … 186 186 Map<Id, BaseType> vars = new HashMap<Id, BaseType>(); 187 187 TemplateVarRewriter tvr = new TemplateVarRewriter(emptyGapEnv, vars); 188 VarType expr = newVarType(span, NodeFactory.makeId(span, "Expr"));188 VarType expr = NodeFactory.makeVarType(span, NodeFactory.makeId(span, "Expr")); 189 189 vars.put(NodeFactory.makeId("e"), expr); 190 190 String r = tvr.rewriteVars("\"e\""); -
trunk/ProjectFortress/src/com/sun/fortress/syntax_abstractions/util/FortressTypeToJavaTypeJUTest.java
r3144 r3202 38 38 private Span span = NodeFactory.makeSpan("bogus"); 39 39 40 private VarType stringType = newVarType(span, NodeFactory.makeId("FortressBuiltin", "String"));40 private VarType stringType = NodeFactory.makeVarType(span, NodeFactory.makeId("FortressBuiltin", "String")); 41 41 private String stringTypeResult = "String"; 42 private VarType fortressASTType = newVarType(span, NodeFactory.makeId("FortressAst", "Decl"));42 private VarType fortressASTType = NodeFactory.makeVarType(span, NodeFactory.makeId("FortressAst", "Decl")); 43 43 private String fortressASTTypeResult = "Decl"; 44 44 … … 47 47 List<StaticArg> args = new LinkedList<StaticArg>(); 48 48 args.add(new TypeArg(span, typeArg)); 49 return new TraitType(span, name, args, Collections.<StaticParam>emptyList());49 return NodeFactory.makeTraitType(span, name, args); 50 50 } 51 51

