Changeset 3096
- Timestamp:
- 11/24/08 22:51:08 (12 months ago)
- Location:
- trunk
- Files:
-
- 31 modified
-
Library/FortressSyntax.fsi (modified) (1 diff)
-
ProjectFortress/astgen/Fortress.ast (modified) (2 diffs)
-
ProjectFortress/src/com/sun/fortress/compiler/IndexBuilder.java (modified) (3 diffs)
-
ProjectFortress/src/com/sun/fortress/compiler/desugarer/PreDisambiguationDesugaringVisitor.java (modified) (2 diffs)
-
ProjectFortress/src/com/sun/fortress/compiler/disambiguator/ExprDisambiguator.java (modified) (9 diffs)
-
ProjectFortress/src/com/sun/fortress/compiler/disambiguator/SelfParamDisambiguator.java (modified) (7 diffs)
-
ProjectFortress/src/com/sun/fortress/compiler/disambiguator/TypeDisambiguator.java (modified) (3 diffs)
-
ProjectFortress/src/com/sun/fortress/compiler/index/ObjectTraitIndex.java (modified) (9 diffs)
-
ProjectFortress/src/com/sun/fortress/compiler/index/ProperTraitIndex.java (modified) (3 diffs)
-
ProjectFortress/src/com/sun/fortress/compiler/index/TraitIndex.java (modified) (5 diffs)
-
ProjectFortress/src/com/sun/fortress/compiler/typechecker/ObjectTypeEnv.java (modified) (6 diffs)
-
ProjectFortress/src/com/sun/fortress/compiler/typechecker/SubtypeCheckerJUTest.java (modified) (1 diff)
-
ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeAnalyzerJUTest.java (modified) (1 diff)
-
ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeCheckerTestCase.java (modified) (3 diffs)
-
ProjectFortress/src/com/sun/fortress/interpreter/Driver.java (modified) (2 diffs)
-
ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BuildApiEnvironment.java (modified) (3 diffs)
-
ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BuildEnvironments.java (modified) (5 diffs)
-
ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BuildTopLevelEnvironments.java (modified) (2 diffs)
-
ProjectFortress/src/com/sun/fortress/interpreter/evaluator/EvalVarsEnvironment.java (modified) (2 diffs)
-
ProjectFortress/src/com/sun/fortress/interpreter/evaluator/ScoutVisitor.java (modified) (6 diffs)
-
ProjectFortress/src/com/sun/fortress/interpreter/evaluator/types/FTraitOrObjectOrGeneric.java (modified) (2 diffs)
-
ProjectFortress/src/com/sun/fortress/interpreter/evaluator/types/FTypeGeneric.java (modified) (4 diffs)
-
ProjectFortress/src/com/sun/fortress/interpreter/evaluator/values/GenericSingleton.java (modified) (2 diffs)
-
ProjectFortress/src/com/sun/fortress/interpreter/rewrite/DesugarerVisitor.java (modified) (8 diffs)
-
ProjectFortress/src/com/sun/fortress/interpreter/rewrite/OprInstantiaterVisitor.java (modified) (4 diffs)
-
ProjectFortress/src/com/sun/fortress/nodes_util/ApiMaker.java (modified) (2 diffs)
-
ProjectFortress/src/com/sun/fortress/nodes_util/ErrorMsgMaker.java (modified) (1 diff)
-
ProjectFortress/src/com/sun/fortress/nodes_util/NodeUtil.java (modified) (4 diffs)
-
ProjectFortress/src/com/sun/fortress/parser/TraitObject.rats (modified) (4 diffs)
-
ProjectFortress/src/com/sun/fortress/parser_util/SyntaxChecker.java (modified) (2 diffs)
-
ProjectFortress/src/com/sun/fortress/tools/FortressAstToConcrete.java (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Library/FortressSyntax.fsi
r3095 r3096 45 45 native grammar TraitObject (* rename to TraitsAndObjectDecls *) 46 46 TraitDecl : TraitDecl 47 AbsTraitDecl : AbsTraitDecl47 AbsTraitDecl : TraitDecl 48 48 ObjectDecl : ObjectDecl 49 AbsObjectDecl : AbsObjectDecl49 AbsObjectDecl : ObjectDecl 50 50 end 51 51 -
trunk/ProjectFortress/astgen/Fortress.ast
r3095 r3096 220 220 * Name must be unqualified. 221 221 */ 222 abstract TraitObject AbsDeclOrDecl(List<Modifier> mods222 abstract TraitObjectDecl(List<Modifier> mods 223 223 = Collections.<Modifier>emptyList(), 224 224 Id name, … … 233 233 /** 234 234 * trait declaration in components or APIs 235 */ 236 abstract TraitAbsDeclOrDecl(List<BaseType> excludes 237 = Collections.<BaseType>emptyList(), 238 Option<List<BaseType>> comprises 239 = Option.<List<BaseType>>none(), 240 List<Decl> decls); 241 /** 242 * trait declaration in APIs 243 * AbsTraitDecl ::= AbsTraitMods? TraitHeaderFront AbsTraitClauses 244 * AbsGoInATrait? end 245 * TraitHeaderFront ::= trait Id StaticParams? ExtendsWhere? 246 * ExtendsWhere ::= extends TraitTypeWheres 247 * AbsTraitClause ::= Excludes | AbsComprises | Where 248 * Excludes ::= excludes TraitTypes 249 * AbsComprises ::= comprises ComprisingTypes 250 * ComprisingTypes ::= TraitType | { ComprisingTypeList } 251 * ComprisingTypeList ::= ... 252 * | TraitType(, TraitType)*(, ...)? 253 * AbsGoInATrait ::= AbsCoercions? AbsGoFrontInATrait AbsGoBackInATrait? 254 * | AbsCoercions? AbsGoBackInATrait 255 * | AbsCoercions 256 * AbsGoesFrontInATrait ::= ApiFldDecl 257 * | AbsGetterSetterDecl 258 * | PropertyDecl 259 * AbsGoesBackInATrait ::= AbsMdDecl 260 * | PropertyDecl 261 * e.g.) trait List[\alpha\] comprises {Cons[\alpha\],Empty[\alpha\]} 262 * cons(x: alph): List[\alpha\] 263 * end 264 */ 265 AbsTraitDecl(List<Decl> decls) implements Decl; 266 /** 267 * trait declaration in components 268 * TraitDecl ::= TraitMods? TraitHeaderFront TraitClauses GoInATrait? 269 * end 270 * TraitClause ::= Excludes | Comprises | Where 271 * Comprises ::= comprises TraitTypes 272 * GoInATrait ::= Coercions? GoFrontInATrait GoBackInATrait? 273 * | Coercions? GoBackInATrait 274 * | Coercions 275 * GoesFrontInATrait ::= AbsFldDecl 276 * | GetterSetterDecl 277 * | PropertyDecl 278 * GoesBackInATrait ::= MdDecl 279 * | PropertyDecl 280 * e.g.) trait List[\alpha\] comprises {Cons[\alpha\],Empty[\alpha\]} 281 * cons(x: alph): List[\alpha\] = Cons[\alph\](x, self) 282 * end 283 */ 284 TraitDecl(List<Decl> decls) implements GenericDecl; 235 * 236 * trait declaration in APIs 237 * AbsTraitDecl ::= AbsTraitMods? TraitHeaderFront AbsTraitClauses 238 * AbsGoInATrait? end 239 * TraitHeaderFront ::= trait Id StaticParams? ExtendsWhere? 240 * ExtendsWhere ::= extends TraitTypeWheres 241 * AbsTraitClause ::= Excludes | AbsComprises | Where 242 * Excludes ::= excludes TraitTypes 243 * AbsComprises ::= comprises ComprisingTypes 244 * ComprisingTypes ::= TraitType | { ComprisingTypeList } 245 * ComprisingTypeList ::= ... 246 * | TraitType(, TraitType)*(, ...)? 247 * AbsGoInATrait ::= AbsCoercions? AbsGoFrontInATrait AbsGoBackInATrait? 248 * | AbsCoercions? AbsGoBackInATrait 249 * | AbsCoercions 250 * AbsGoesFrontInATrait ::= ApiFldDecl 251 * | AbsGetterSetterDecl 252 * | PropertyDecl 253 * AbsGoesBackInATrait ::= AbsMdDecl 254 * | PropertyDecl 255 * e.g.) trait List[\alpha\] comprises {Cons[\alpha\],Empty[\alpha\]} 256 * cons(x: alph): List[\alpha\] 257 * end 258 * 259 * trait declaration in components 260 * TraitDecl ::= TraitMods? TraitHeaderFront TraitClauses GoInATrait? 261 * end 262 * TraitClause ::= Excludes | Comprises | Where 263 * Comprises ::= comprises TraitTypes 264 * GoInATrait ::= Coercions? GoFrontInATrait GoBackInATrait? 265 * | Coercions? GoBackInATrait 266 * | Coercions 267 * GoesFrontInATrait ::= AbsFldDecl 268 * | GetterSetterDecl 269 * | PropertyDecl 270 * GoesBackInATrait ::= MdDecl 271 * | PropertyDecl 272 * e.g.) trait List[\alpha\] comprises {Cons[\alpha\],Empty[\alpha\]} 273 * cons(x: alph): List[\alpha\] = Cons[\alph\](x, self) 274 * end 275 */ 276 TraitDecl(List<BaseType> excludes = Collections.<BaseType>emptyList(), 277 Option<List<BaseType>> comprises 278 = Option.<List<BaseType>>none(), 279 List<Decl> decls) implements GenericDecl; 285 280 /** 286 281 * object declaration in components or APIs 287 */ 288 abstract ObjectAbsDeclOrDecl(Option<List<Param>> params 289 = Option.<List<Param>>none(), 290 Option<List<BaseType>> throwsClause 291 = Option.<List<BaseType>>none(), 292 Option<Contract> contract 293 = Option.<Contract>none(), 294 List<Decl> decls) 295 implements GenericDeclWithParams; 296 /** 297 * object declaration in APIs 298 * AbsObjectDecl ::= AbsObjectMods? ObjectHeader AbsGoInAnObject? end 299 * ObjectHeader ::= object Id StaticParams? ObjectValParam? 300 * ExtendsWhere? FnClauses 301 * FnClauses ::= Throws? Where? Contract 302 * Throws ::= throws MayTraitTypes 303 * ObjectValParam ::= ( ObjectParams? ) 304 * ObjectParams ::= (ObjectParam ,)* ObjectKeyword(, ObjectKeyword)* 305 * | ObjectParam (, ObjectParam)* 306 * ObjectKeyword ::= ObjectParam = Expr 307 * ObjectParam ::= ParamFldMods? Param 308 * | var Param 309 * AbsGoInAnObject ::= AbsCoercions? AbsGoFrontInAnObject AbsGoBackInAnObject? 310 * | AbsCoercions? AbsGoBackInAnObject 311 * | AbsCoercions 312 * AbsGoesFrontInAnObject ::= ApiFldDecl 313 * | AbsGetterSetterDecl 314 * | PropertyDecl 315 * AbsGoesBackInAnObject ::= AbsMdDecl 316 * | PropertyDecl 317 * e.g.) object Empty[\alph\]() extends List[\alpha\] end 318 */ 319 AbsObjectDecl(List<Decl> decls) implements Decl; 320 /** 321 * object declaration in components 322 * ObjectDecl ::= ObjectMods? ObjectHeader GoInAnObject? end 323 * GoInAnObject ::= Coercions? GoFrontInAnObject GoBackInAnObject? 324 * | Coercions? GoBackInAnObject 325 * | Coercions 326 * GoesFrontInAnObject ::= FldDecl 327 * | GetterSetterDecl 328 * | PropertyDecl 329 * GoesBackInAnObject ::= MdDef 330 * | PropertyDecl 331 * e.g.) object Empty[\alph\]() extends List[\alpha\] 332 * length() = 0 333 * end 334 */ 335 ObjectDecl(List<Decl> decls) implements GenericDeclWithParams; 282 * 283 * object declaration in APIs 284 * AbsObjectDecl ::= AbsObjectMods? ObjectHeader AbsGoInAnObject? end 285 * ObjectHeader ::= object Id StaticParams? ObjectValParam? 286 * ExtendsWhere? FnClauses 287 * FnClauses ::= Throws? Where? Contract 288 * Throws ::= throws MayTraitTypes 289 * ObjectValParam ::= ( ObjectParams? ) 290 * ObjectParams ::= (ObjectParam ,)* ObjectKeyword(, ObjectKeyword)* 291 * | ObjectParam (, ObjectParam)* 292 * ObjectKeyword ::= ObjectParam = Expr 293 * ObjectParam ::= ParamFldMods? Param 294 * | var Param 295 * AbsGoInAnObject ::= AbsCoercions? AbsGoFrontInAnObject AbsGoBackInAnObject? 296 * | AbsCoercions? AbsGoBackInAnObject 297 * | AbsCoercions 298 * AbsGoesFrontInAnObject ::= ApiFldDecl 299 * | AbsGetterSetterDecl 300 * | PropertyDecl 301 * AbsGoesBackInAnObject ::= AbsMdDecl 302 * | PropertyDecl 303 * e.g.) object Empty[\alph\]() extends List[\alpha\] end 304 * 305 * object declaration in components 306 * ObjectDecl ::= ObjectMods? ObjectHeader GoInAnObject? end 307 * GoInAnObject ::= Coercions? GoFrontInAnObject GoBackInAnObject? 308 * | Coercions? GoBackInAnObject 309 * | Coercions 310 * GoesFrontInAnObject ::= FldDecl 311 * | GetterSetterDecl 312 * | PropertyDecl 313 * GoesBackInAnObject ::= MdDef 314 * | PropertyDecl 315 * e.g.) object Empty[\alph\]() extends List[\alpha\] 316 * length() = 0 317 * end 318 */ 319 ObjectDecl(Option<List<Param>> params = Option.<List<Param>>none(), 320 Option<List<BaseType>> throwsClause 321 = Option.<List<BaseType>>none(), 322 Option<Contract> contract = Option.<Contract>none(), 323 List<Decl> decls) 324 implements GenericDeclWithParams; 336 325 /** 337 326 * variable declaration in components or APIs -
trunk/ProjectFortress/src/com/sun/fortress/compiler/IndexBuilder.java
r3095 r3096 149 149 new HashMap<String, GrammarIndex>(); 150 150 NodeAbstractVisitor_void handleDecl = new NodeAbstractVisitor_void() { 151 @Override public void for AbsTraitDecl(AbsTraitDecl d) {151 @Override public void forTraitDecl(TraitDecl d) { 152 152 buildTrait(d, typeConses, functions); 153 153 } 154 @Override public void for AbsObjectDecl(AbsObjectDecl d) {154 @Override public void forObjectDecl(ObjectDecl d) { 155 155 buildObject(d, typeConses, functions, variables); 156 156 } … … 269 269 * to the given relation. 270 270 */ 271 private void buildTrait(Trait AbsDeclOrDecl ast,271 private void buildTrait(TraitDecl ast, 272 272 Map<Id, TypeConsIndex> typeConses, 273 273 final Relation<IdOrOpOrAnonymousName, Function> functions) { … … 305 305 * put it in the appropriate map. 306 306 */ 307 private void buildObject(Object AbsDeclOrDecl ast,307 private void buildObject(ObjectDecl ast, 308 308 Map<Id, TypeConsIndex> typeConses, 309 309 final Relation<IdOrOpOrAnonymousName, Function> functions, -
trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/PreDisambiguationDesugaringVisitor.java
r3093 r3096 75 75 76 76 @Override 77 public Node forAbsTraitDeclOnly(AbsTraitDecl that,78 List<Modifier> mods,79 Id name,80 List<StaticParam> staticParams,81 List<TraitTypeWhere> extendsClause,82 Option<WhereClause> where,83 List<BaseType> excludes,84 Option<List<BaseType>> comprises,85 List<Decl> decls) {86 if (!that.getName().equals(anyTypeId)) {87 extendsClause = rewriteExtendsClause(that, extendsClause);88 }89 return super.forAbsTraitDeclOnly(that, mods, name, staticParams, extendsClause,90 where, excludes, comprises, decls);91 }92 93 @Override94 77 public Node forTraitDeclOnly(TraitDecl that, 95 78 List<Modifier> mods, … … 106 89 return super.forTraitDeclOnly(that, mods, name, staticParams, extendsClause, 107 90 where, excludes, comprises, decls); 108 }109 110 @Override111 public Node forAbsObjectDeclOnly(AbsObjectDecl that,112 List<Modifier> mods,113 Id name,114 List<StaticParam> staticParams,115 List<TraitTypeWhere> extendsClause,116 Option<WhereClause> where,117 Option<List<Param>> params,118 Option<List<BaseType>> throwsClause,119 Option<Contract> contract,120 List<Decl> decls) {121 extendsClause = rewriteExtendsClause(that, extendsClause);122 return super.forAbsObjectDeclOnly(that, mods, name, staticParams, extendsClause,123 where, params, throwsClause, contract, decls);124 91 } 125 92 -
trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/ExprDisambiguator.java
r3095 r3096 31 31 import com.sun.fortress.nodes.APIName; 32 32 import com.sun.fortress.nodes.Decl; 33 import com.sun.fortress.nodes.AbsObjectDecl; 34 import com.sun.fortress.nodes.AbsTraitDecl; 33 import com.sun.fortress.nodes.ObjectDecl; 35 34 import com.sun.fortress.nodes.VarDecl; 36 35 import com.sun.fortress.nodes.Accumulator; … … 39 38 import com.sun.fortress.nodes.BoolParam; 40 39 import com.sun.fortress.nodes.Catch; 40 import com.sun.fortress.nodes.Component; 41 41 import com.sun.fortress.nodes.Contract; 42 42 import com.sun.fortress.nodes.DimDecl; … … 134 134 private List<StaticError> _errors; 135 135 private Option<Id> _innerMostLabel; 136 private boolean inComponent = false; 136 137 137 138 public ExprDisambiguator(NameEnv env, List<StaticError> errors) { … … 500 501 501 502 /** 502 * When recurring on an AbsTraitDecl, we first need to extend the503 * environment with all the newly bound static parameters that can504 * be used in an expression context.505 * TODO: Handle variables bound in where clauses.506 * TODO: Insert inherited method names into the environment.507 */508 @Override public Node forAbsTraitDecl(final AbsTraitDecl that) {509 ExprDisambiguator v = this.extendWithVars(extractStaticExprVars(that.getStaticParams()));510 List<TraitTypeWhere> extendsClause = v.recurOnListOfTraitTypeWhere(that.getExtendsClause());511 512 // Include trait declarations and inherited methods513 Triple<Set<Id>,Set<IdOrOpOrAnonymousName>, Set<IdOrOpOrAnonymousName>> declNames =514 extractDeclNames(that.getDecls());515 Set<Id> vars = declNames.first();516 Set<IdOrOpOrAnonymousName> gettersAndSetters = declNames.second();517 Set<IdOrOpOrAnonymousName> fns = declNames.third();518 519 Pair<Set<Id>, Set<IdOrOpOrAnonymousName>> inherited = inheritedMethods(extendsClause);520 Set<Id> inheritedGettersAndSetters = inherited.first();521 Set<IdOrOpOrAnonymousName> inheritedMethods = inherited.second();522 523 // Do not extend the environment with "fields", getters, or setters in a trait.524 // References to all three must have an explicit receiver.525 v = this.526 extendWithVars(extractStaticExprVars(that.getStaticParams())).527 extendWithFns(inheritedMethods).528 extendWithSelf(that.getSpan()).529 extendWithFns(fns).530 // TODO The following two extensions are problematic; getters and setters should531 // not be referred to without explicit receivers in most (all?) cases. But the532 // libraries break horribly if we leave them off.533 extendWithFns(inheritedGettersAndSetters).534 extendWithFns(gettersAndSetters);535 536 v.checkForShadowingVars(vars);537 538 return forAbsTraitDeclOnly(that,539 v.recurOnListOfModifier(that.getMods()),540 (Id) that.getName().accept(v),541 v.recurOnListOfStaticParam(that.getStaticParams()),542 extendsClause,543 v.recurOnOptionOfWhereClause(that.getWhere()),544 v.recurOnListOfBaseType(that.getExcludes()),545 v.recurOnOptionOfListOfBaseType(that.getComprises()),546 v.recurOnListOfDecl(that.getDecls()));547 }548 549 550 /**551 503 * When recurring on an ObjExpr, we first need to extend the 552 504 * environment with all the newly bound variables and methods … … 668 620 } 669 621 622 @Override public Node forComponent(final Component that) { 623 inComponent = true; 624 return super.forComponent( that ); 625 } 626 670 627 /** 671 628 * When recurring on a TraitDecl, we first need to extend the … … 690 647 Set<IdOrOpOrAnonymousName> inheritedMethods = inherited.second(); 691 648 649 // Do not extend the environment with "fields", getters, or setters in a trait. 650 // References to all three must have an explicit receiver. 692 651 v = this. 693 652 extendWithVars(extractStaticExprVars(that.getStaticParams())). … … 703 662 extendWithFns(gettersAndSetters); 704 663 664 if ( ! inComponent ) 665 v.checkForShadowingVars(vars); 666 705 667 return forTraitDeclOnly(that, 706 668 v.recurOnListOfModifier(that.getMods()), … … 714 676 } 715 677 716 717 /** 718 * When recurring on an AbsObjectDecl, we first need to extend the 678 /** 679 * When recurring on an ObjectDecl, we first need to extend the 719 680 * environment with all the newly bound static parameters that can 720 * be used in an expression context .681 * be used in an expression context, along with all the object parameters. 721 682 * TODO: Handle variables bound in where clauses. 722 683 * TODO: Insert inherited method names into the environment. 723 684 */ 724 @Override public Node for AbsObjectDecl(final AbsObjectDecl that) {685 @Override public Node forObjectDecl(final ObjectDecl that) { 725 686 ExprDisambiguator v = this.extendWithVars(extractStaticExprVars(that.getStaticParams())); 726 687 List<TraitTypeWhere> extendsClause = v.recurOnListOfTraitTypeWhere(that.getExtendsClause()); … … 731 692 Set<IdOrOpOrAnonymousName> gettersAndSetters = declNames.second(); 732 693 // fns does not contain getters and setters 733 Set<IdOrOpOrAnonymousName> fns = declNames.third();734 735 Set<Id> params = extractParamNames(that.getParams());736 Set<Id> fields = CollectUtil.union(params, vars);737 738 Pair<Set<Id>, Set<IdOrOpOrAnonymousName>> inherited = inheritedMethods(extendsClause);739 Set<Id> inheritedGettersAndSetters = inherited.first();740 Set<IdOrOpOrAnonymousName> inheritedMethods = inherited.second();741 742 v = this.extendWithVars(extractStaticExprVars743 (that.getStaticParams())).744 extendWithSelf(that.getSpan()).745 extendWithVars(params).746 extendWithVars(vars).747 extendWithFns(inheritedMethods).748 extendWithFns(fns).749 // TODO The following two extensions are problematic; getters and setters should750 // not be referred to without explicit receivers in most (all?) cases. But the751 // libraries break horribly if we leave them off.752 extendWithFns(inheritedGettersAndSetters, fields).753 extendWithFns(gettersAndSetters, fields);754 755 return forAbsObjectDeclOnly(that,756 v.recurOnListOfModifier(that.getMods()),757 (Id) that.getName().accept(v),758 v.recurOnListOfStaticParam(that.getStaticParams()),759 extendsClause,760 v.recurOnOptionOfWhereClause(that.getWhere()),761 v.recurOnOptionOfListOfParam(that.getParams()),762 v.recurOnOptionOfListOfBaseType(that.getThrowsClause()),763 v.recurOnOptionOfContract(that.getContract()),764 v.recurOnListOfDecl(that.getDecls()));765 }766 767 768 769 /**770 * When recurring on an ObjectDecl, we first need to extend the771 * environment with all the newly bound static parameters that can772 * be used in an expression context, along with all the object parameters.773 * TODO: Handle variables bound in where clauses.774 * TODO: Insert inherited method names into the environment.775 */776 @Override public Node forObjectDecl(final ObjectDecl that) {777 ExprDisambiguator v = this.extendWithVars(extractStaticExprVars(that.getStaticParams()));778 List<TraitTypeWhere> extendsClause = v.recurOnListOfTraitTypeWhere(that.getExtendsClause());779 780 // Include trait declarations and inherited methods781 Triple<Set<Id>,Set<IdOrOpOrAnonymousName>, Set<IdOrOpOrAnonymousName>> declNames = extractDeclNames(that.getDecls());782 Set<Id> vars = declNames.first();783 Set<IdOrOpOrAnonymousName> gettersAndSetters = declNames.second();784 694 Set<IdOrOpOrAnonymousName> fns = declNames.third(); 785 695 -
trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/SelfParamDisambiguator.java
r2163 r3096 22 22 import com.sun.fortress.compiler.typechecker.TypeEnv; 23 23 import com.sun.fortress.compiler.typechecker.TypesUtil; 24 import com.sun.fortress.nodes.AbsObjectDecl; 25 import com.sun.fortress.nodes.AbsTraitDecl; 24 import com.sun.fortress.nodes.ObjectDecl; 26 25 import com.sun.fortress.nodes.Expr; 27 26 import com.sun.fortress.nodes.Id; … … 44 43 * At parse-time, methods that take the 'self' parameter may not have a 45 44 * type for that parameter. However, at disambiguation time, we can give 46 * it one.<br> 45 * it one.<br> 47 46 * {@code trait Foo f(self) : () end} 48 47 * becomes … … 54 53 */ 55 54 public class SelfParamDisambiguator extends NodeUpdateVisitor { 56 57 @Override58 public Node forAbsObjectDecl(AbsObjectDecl that) {59 // Add a type to self parameters of methods60 Type self_type = NodeFactory.makeTraitType(that.getName(),61 TypeEnv.staticParamsToArgs(that.getStaticParams()));62 AbsObjectDecl that_new = (AbsObjectDecl)this.replaceSelfParamsWithType(that, self_type);63 return super.forAbsObjectDecl(that_new);64 }65 66 @Override67 public Node forAbsTraitDecl(AbsTraitDecl that) {68 // Add a type to self parameters of methods69 Type self_type = NodeFactory.makeTraitType(that.getName(),70 TypeEnv.staticParamsToArgs(that.getStaticParams()));71 AbsTraitDecl that_new = (AbsTraitDecl)this.replaceSelfParamsWithType(that, self_type);72 return super.forAbsTraitDecl(that_new);73 }74 75 55 @Override 76 56 public Node forObjectDecl(ObjectDecl that) { … … 90 70 return super.forTraitDecl(that_new); 91 71 } 92 93 94 72 73 74 95 75 @Override 96 76 public Node forObjectExpr(ObjectExpr that) { … … 103 83 /** 104 84 * Replaces Parameters whose name is 'self' with a parameter with 105 * the explicit type given. 106 * 85 * the explicit type given. 86 * 107 87 * @param that 108 88 * @param self_type 109 89 */ 110 90 private Node replaceSelfParamsWithType(Node that, final Type self_type) { 111 91 112 92 NodeUpdateVisitor replacer = new NodeUpdateVisitor() { 113 93 int traitNestingDepth = 0; … … 123 103 new_type = type_result; 124 104 125 return new NormalParam(that.getSpan(), 105 return new NormalParam(that.getSpan(), 126 106 that.getMods(), 127 107 that.getName(), … … 129 109 that.getDefaultExpr()); 130 110 } 131 111 132 112 // end recurrance here 133 @Override public Node forObjectDecl(ObjectDecl that) { 113 @Override public Node forObjectDecl(ObjectDecl that) { 134 114 return (++traitNestingDepth) > 1 ? that : super.forObjectDecl(that); 135 115 } 136 @Override public Node forTraitDecl(TraitDecl that) { 116 @Override public Node forTraitDecl(TraitDecl that) { 137 117 return (++traitNestingDepth) > 1 ? that : super.forTraitDecl(that); 138 118 } 139 @Override public Node forObjectExpr(ObjectExpr that) { 119 @Override public Node forObjectExpr(ObjectExpr that) { 140 120 return (++traitNestingDepth) > 1 ? that : super.forObjectExpr(that); 141 }142 @Override public Node forAbsObjectDecl(AbsObjectDecl that) {143 return (++traitNestingDepth) > 1 ? that : super.forAbsObjectDecl(that);144 }145 @Override public Node forAbsTraitDecl(AbsTraitDecl that) {146 return (++traitNestingDepth) > 1 ? that : super.forAbsTraitDecl(that);147 121 } 148 122 }; -
trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/TypeDisambiguator.java
r3095 r3096 30 30 import com.sun.fortress.exceptions.StaticError; 31 31 import com.sun.fortress.nodes.APIName; 32 import com.sun.fortress.nodes.AbsObjectDecl; 33 import com.sun.fortress.nodes.AbsTraitDecl; 32 import com.sun.fortress.nodes.ObjectDecl; 34 33 import com.sun.fortress.nodes.AnyType; 35 34 import com.sun.fortress.nodes.ArrowType; … … 132 131 133 132 /** 134 * When recurring on an AbsTraitDecl, we first need to extend the135 * environment with all the newly bound static parameters.136 */137 @Override public Node forAbsTraitDecl(final AbsTraitDecl that) {138 TypeDisambiguator v = this.extend(that.getStaticParams());139 140 return forAbsTraitDeclOnly(that,141 v.recurOnListOfModifier(that.getMods()),142 (Id) that.getName().accept(v),143 v.recurOnListOfStaticParam(that.getStaticParams()),144 v.recurOnListOfTraitTypeWhere(that.getExtendsClause()),145 v.recurOnOptionOfWhereClause(that.getWhere()),146 v.recurOnListOfBaseType(that.getExcludes()),147 v.recurOnOptionOfListOfBaseType(that.getComprises()),148 v.recurOnListOfDecl(that.getDecls()));149 }150 151 /**152 133 * When recurring on a TraitDecl, we first need to extend the 153 134 * environment with all the newly bound static parameters. … … 164 145 v.recurOnListOfBaseType(that.getExcludes()), 165 146 v.recurOnOptionOfListOfBaseType(that.getComprises()), 166 v.recurOnListOfDecl(that.getDecls()));167 }168 169 170 /**171 * When recurring on an AbsObjectDecl, we first need to extend the172 * environment with all the newly bound static parameters.173 */174 @Override public Node forAbsObjectDecl(final AbsObjectDecl that) {175 TypeDisambiguator v = this.extend(that.getStaticParams());176 177 return forAbsObjectDeclOnly(that,178 v.recurOnListOfModifier(that.getMods()),179 (Id) that.getName().accept(v),180 v.recurOnListOfStaticParam(that.getStaticParams()),181 v.recurOnListOfTraitTypeWhere(that.getExtendsClause()),182 v.recurOnOptionOfWhereClause(that.getWhere()),183 v.recurOnOptionOfListOfParam(that.getParams()),184 v.recurOnOptionOfListOfBaseType(that.getThrowsClause()),185 v.recurOnOptionOfContract(that.getContract()),186 147 v.recurOnListOfDecl(that.getDecls())); 187 148 } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/index/ObjectTraitIndex.java
r2455 r3096 28 28 import com.sun.fortress.nodes.IdOrOpOrAnonymousName; 29 29 import com.sun.fortress.nodes.NodeUpdateVisitor; 30 import com.sun.fortress.nodes.Object AbsDeclOrDecl;30 import com.sun.fortress.nodes.ObjectDecl; 31 31 import com.sun.fortress.nodes.VarDecl; 32 32 … … 38 38 /** Wraps an object declaration. */ 39 39 public class ObjectTraitIndex extends TraitIndex { 40 40 41 41 private final Option<Constructor> _constructor; 42 42 private final Map<Id, Variable> _fields; 43 43 private final Set<VarDecl> _fieldInitializers; 44 45 public ObjectTraitIndex(Object AbsDeclOrDecl ast,44 45 public ObjectTraitIndex(ObjectDecl ast, 46 46 Option<Constructor> constructor, 47 47 Map<Id, Variable> fields, … … 57 57 _fieldInitializers = fieldInitializers; 58 58 } 59 59 60 60 public Option<Constructor> constructor() { 61 61 return _constructor; 62 62 } 63 63 64 64 public Map<Id, Variable> fields() { 65 65 return Collections.unmodifiableMap(this._fields); 66 66 } 67 67 68 68 public Set<VarDecl> fieldInitializers() { 69 69 return Collections.unmodifiableSet(_fieldInitializers); … … 81 81 new_fields.put(entry.getKey(), var.acceptNodeUpdateVisitor(v)); 82 82 } 83 83 84 84 Set<VarDecl> new_field_ini = new HashSet<VarDecl>(); 85 85 for( VarDecl vd : this.fieldInitializers() ) { 86 86 new_field_ini.add((VarDecl)vd.accept(v)); 87 87 } 88 88 89 89 Map<Id,Method> new_getters = new HashMap<Id,Method>(); 90 90 for( Map.Entry<Id, Method> entry : this.getters().entrySet() ) { … … 92 92 new_getters.put(entry.getKey(), (Method)var.acceptNodeUpdateVisitor(v)); 93 93 } 94 94 95 95 Map<Id,Method> new_setters = new HashMap<Id,Method>(); 96 96 for( Map.Entry<Id, Method> entry : this.setters().entrySet() ) { … … 98 98 new_setters.put(entry.getKey(), (Method)var.acceptNodeUpdateVisitor(v)); 99 99 } 100 100 101 101 Set<Function> new_coercions = new HashSet<Function>(); 102 102 for( Function vd : this.coercions() ) { 103 103 new_coercions.add((Function)vd.acceptNodeUpdateVisitor(v)); 104 104 } 105 105 106 106 Iterator<Pair<IdOrOpOrAnonymousName, Method>> iter_1 = this.dottedMethods().iterator(); 107 107 Set<Pair<IdOrOpOrAnonymousName, Method>> new_dm = new HashSet<Pair<IdOrOpOrAnonymousName, Method>>(); … … 111 111 } 112 112 Relation<IdOrOpOrAnonymousName, Method> new_dotted = CollectUtil.makeRelation(new_dm); 113 113 114 114 Iterator<Pair<IdOrOpOrAnonymousName, FunctionalMethod>> iter_2 = this.functionalMethods().iterator(); 115 115 Set<Pair<IdOrOpOrAnonymousName, FunctionalMethod>> new_fm = new HashSet<Pair<IdOrOpOrAnonymousName, FunctionalMethod>>(); … … 119 119 } 120 120 Relation<IdOrOpOrAnonymousName, FunctionalMethod> new_functional = CollectUtil.makeRelation(new_fm); 121 122 return new ObjectTraitIndex((Object AbsDeclOrDecl)this.ast().accept(v),121 122 return new ObjectTraitIndex((ObjectDecl)this.ast().accept(v), 123 123 new_constr, 124 124 new_fields, … … 130 130 new_functional); 131 131 } 132 132 133 133 } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/index/ProperTraitIndex.java
r2455 r3096 27 27 import com.sun.fortress.nodes.IdOrOpOrAnonymousName; 28 28 import com.sun.fortress.nodes.NodeUpdateVisitor; 29 import com.sun.fortress.nodes.Trait AbsDeclOrDecl;29 import com.sun.fortress.nodes.TraitDecl; 30 30 import com.sun.fortress.nodes.Type; 31 31 import com.sun.fortress.useful.NI; … … 38 38 public class ProperTraitIndex extends TraitIndex { 39 39 40 public ProperTraitIndex(Trait AbsDeclOrDecl ast,40 public ProperTraitIndex(TraitDecl ast, 41 41 Map<Id, Method> getters, 42 42 Map<Id, Method> setters, … … 93 93 Relation<IdOrOpOrAnonymousName, FunctionalMethod> new_functional = CollectUtil.makeRelation(new_fm); 94 94 95 return new ProperTraitIndex((Trait AbsDeclOrDecl)this.ast().accept(v),95 return new ProperTraitIndex((TraitDecl)this.ast().accept(v), 96 96 new_getters, 97 97 new_setters, -
trunk/ProjectFortress/src/com/sun/fortress/compiler/index/TraitIndex.java
r2909 r3096 25 25 import edu.rice.cs.plt.tuple.Pair; 26 26 import edu.rice.cs.plt.iter.IterUtil; 27 import com.sun.fortress.nodes.TraitObject AbsDeclOrDecl;27 import com.sun.fortress.nodes.TraitObjectDecl; 28 28 import com.sun.fortress.nodes.TraitTypeWhere; 29 29 import com.sun.fortress.nodes.StaticParam; … … 38 38 */ 39 39 public abstract class TraitIndex extends TypeConsIndex { 40 41 private final TraitObject AbsDeclOrDecl _ast;40 41 private final TraitObjectDecl _ast; 42 42 private final Map<Id, Method> _getters; 43 43 private final Map<Id, Method> _setters; … … 45 45 private final Relation<IdOrOpOrAnonymousName, Method> _dottedMethods; 46 46 private final Relation<IdOrOpOrAnonymousName, FunctionalMethod> _functionalMethods; 47 48 public TraitIndex(TraitObject AbsDeclOrDecl ast,47 48 public TraitIndex(TraitObjectDecl ast, 49 49 Map<Id, Method> getters, 50 50 Map<Id, Method> setters, … … 59 59 _functionalMethods = functionalMethods; 60 60 } 61 62 public TraitObject AbsDeclOrDecl ast() { return _ast; }63 61 62 public TraitObjectDecl ast() { return _ast; } 63 64 64 public List<StaticParam> staticParameters() { return _ast.getStaticParams(); } 65 65 66 66 public List<Id> hiddenParameters() { return Collections.emptyList(); } 67 67 68 68 /** 69 69 * Return all subtype relationships described by parameter bounds and where clauses. … … 72 72 */ 73 73 public Iterable<Pair<Type, Type>> typeConstraints() { return IterUtil.empty(); } 74 74 75 75 public List<TraitTypeWhere> extendsTypes() { 76 76 return _ast.getExtendsClause(); 77 77 } 78 78 79 79 public Map<Id, Method> getters() { 80 80 return _getters; 81 81 } 82 82 83 83 public Map<Id, Method> setters() { 84 84 return _setters; 85 85 } 86 86 87 87 public Set<Function> coercions() { 88 88 return _coercions; 89 89 } 90 90 91 91 public Relation<IdOrOpOrAnonymousName, Method> dottedMethods() { 92 92 return _dottedMethods; 93 93 } 94 94 95 95 public Relation<IdOrOpOrAnonymousName, FunctionalMethod> functionalMethods() { 96 96 return _functionalMethods; 97 97 } 98 98 99 99 } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/ObjectTypeEnv.java
r2466 r3096 29 29 import com.sun.fortress.nodes.IdOrOpOrAnonymousName; 30 30 import com.sun.fortress.nodes.Node; 31 import com.sun.fortress.nodes.Object AbsDeclOrDecl;31 import com.sun.fortress.nodes.ObjectDecl; 32 32 import com.sun.fortress.nodes.StaticParam; 33 33 import com.sun.fortress.nodes.Type; … … 61 61 // Api-less name used for look-up only. 62 62 Id no_api_var = removeApi(_var); 63 63 64 64 if (!entries.containsKey(no_api_var)) { return parent.binding(var); } 65 65 TypeConsIndex typeCons = entries.get(no_api_var); 66 66 67 67 // TODO: This seems wrong... If they were looking for an Object, but found some 68 68 // other kind of type, isn't there some way we could return a better error message? 69 69 if (!(typeCons instanceof ObjectTraitIndex)) { return parent.binding(var); } 70 70 ObjectTraitIndex objIndex = (ObjectTraitIndex)typeCons; 71 71 72 72 Type type; 73 Object AbsDeclOrDecl decl = (ObjectAbsDeclOrDecl)objIndex.ast();73 ObjectDecl decl = (ObjectDecl)objIndex.ast(); 74 74 if (decl.getStaticParams().isEmpty()) { 75 75 if (decl.getParams().isNone()) { … … 89 89 // Some static params, some normal params 90 90 // TODO: handle type variables bound in where clause 91 type = 91 type = 92 92 new _RewriteGenericArrowType(decl.getSpan(), decl.getStaticParams(), 93 93 domainFromParams(decl.getParams().unwrap()), … … 97 97 } 98 98 99 return Option.some(new BindingLookup(var, type, decl.getMods())); 99 return Option.some(new BindingLookup(var, type, decl.getMods())); 100 100 } 101 101 … … 120 120 // Api-less name used for look-up only. 121 121 Id no_api_var = removeApi(_var); 122 122 123 123 if (!entries.containsKey(no_api_var)) { return parent.declarationSite(var); } 124 124 TypeConsIndex typeCons = entries.get(no_api_var); 125 125 126 126 // TODO: This seems wrong... If they were looking for an Object, but found some 127 127 // other kind of type, isn't there some way we could return a better error message? 128 128 if (!(typeCons instanceof ObjectTraitIndex)) { return parent.declarationSite(var); } 129 129 ObjectTraitIndex objIndex = (ObjectTraitIndex)typeCons; 130 130 131 131 return Option.<Node>some(objIndex.ast()); 132 132 } … … 134 134 @Override 135 135 public TypeEnv replaceAllIVars(Map<_InferenceVarType, Type> ivars) { 136 136 137 137 Map<Id, TypeConsIndex> new_entries = new HashMap<Id, TypeConsIndex>(); 138 138 InferenceVarReplacer rep = new InferenceVarReplacer(ivars); 139 139 140 140 for( Map.Entry<Id, TypeConsIndex> entry : entries.entrySet() ) { 141 141 TypeConsIndex tc = entry.getValue(); -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/SubtypeCheckerJUTest.java
r3093 r3096 392 392 extendsClause.add(new TraitTypeWhere(span, supT, Option.<WhereClause>none())); 393 393 } 394 Trait AbsDeclOrDecl ast;394 TraitDecl ast; 395 395 List<StaticParam> sparams = Collections.<StaticParam>emptyList(); 396 396 if (absDecl) { 397 ast = new AbsTraitDecl(span, NodeFactory.makeId(span, name), sparams,398 extendsClause,399 Collections.<Decl>emptyList());397 ast = new TraitDecl(span, NodeFactory.makeId(span, name), sparams, 398 extendsClause, 399 Collections.<Decl>emptyList()); 400 400 } 401 401 else { -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeAnalyzerJUTest.java
r3093 r3096 465 465 extendsClause.add(new TraitTypeWhere(span, supT, Option.<WhereClause>none())); 466 466 } 467 Trait AbsDeclOrDecl ast;467 TraitDecl ast; 468 468 if (absDecl) { 469 ast = new AbsTraitDecl(span, NodeFactory.makeId(span, name),470 Collections.<StaticParam>emptyList(),471 extendsClause,472 Collections.<Decl>emptyList());469 ast = new TraitDecl(span, NodeFactory.makeId(span, name), 470 Collections.<StaticParam>emptyList(), 471 extendsClause, 472 Collections.<Decl>emptyList()); 473 473 } 474 474 else { -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeCheckerTestCase.java
r3071 r3096 40 40 import com.sun.fortress.nodes.StaticArg; 41 41 import com.sun.fortress.nodes.StaticParam; 42 import com.sun.fortress.nodes.TraitAbsDeclOrDecl;43 42 import com.sun.fortress.nodes.TraitDecl; 44 43 import com.sun.fortress.nodes.BaseType; … … 60 59 61 60 private static Span span = NodeFactory.makeSpan("TypeCheckerTestCase bogus"); 62 61 63 62 public static Type parseType(String s) { 64 63 s = s.trim(); … … 110 109 extendsClause.add(new TraitTypeWhere(span, supT, Option.<WhereClause>none())); 111 110 } 112 Trait AbsDeclOrDecl ast = new TraitDecl(span, NodeFactory.makeId(name), sparams,113 extendsClause,114 Collections.<Decl>emptyList());111 TraitDecl ast = new TraitDecl(span, NodeFactory.makeId(name), sparams, 112 extendsClause, 113 Collections.<Decl>emptyList()); 115 114 return new ProperTraitIndex(ast, 116 115 Collections.<Id, Method>emptyMap(), -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/Driver.java
r3095 r3096 58 58 import com.sun.fortress.interpreter.glue.WellKnownNames; 59 59 import com.sun.fortress.nodes.APIName; 60 import com.sun.fortress.nodes.AbsObjectDecl;61 import com.sun.fortress.nodes.AbsTraitDecl;62 60 import com.sun.fortress.nodes.AbstractArrowType; 63 61 import com.sun.fortress.nodes.AliasedAPIName; … … 78 76 import com.sun.fortress.nodes.NodeAbstractVisitor_void; 79 77 import com.sun.fortress.nodes.NodeVisitor_void; 80 import com.sun.fortress.nodes.ObjectAbsDeclOrDecl;81 78 import com.sun.fortress.nodes.ObjectDecl; 82 79 import com.sun.fortress.nodes.SyntaxDecl; 83 80 import com.sun.fortress.nodes.SyntaxDef; 84 81 import com.sun.fortress.nodes.TestDecl; 85 import com.sun.fortress.nodes.TraitAbsDeclOrDecl;86 82 import com.sun.fortress.nodes.TraitDecl; 87 83 import com.sun.fortress.nodes_util.NodeFactory; -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BuildApiEnvironment.java
r3095 r3096 29 29 import com.sun.fortress.nodes.VarDecl; 30 30 import com.sun.fortress.nodes.FnDecl; 31 import com.sun.fortress.nodes. AbsObjectDecl;32 import com.sun.fortress.nodes. AbsTraitDecl;31 import com.sun.fortress.nodes.ObjectDecl; 32 import com.sun.fortress.nodes.TraitDecl; 33 33 import com.sun.fortress.nodes.Id; 34 34 import com.sun.fortress.nodes.IdOrOpOrAnonymousName; … … 62 62 63 63 @Override 64 public Boolean for AbsObjectDecl(AbsObjectDecl x) {64 public Boolean forObjectDecl(ObjectDecl x) { 65 65 Boolean change = Boolean.FALSE; 66 // super.for AbsObjectDecl(x);66 // super.forObjectDecl(x); 67 67 if (getPass() == 1) { 68 68 String fname = NodeUtil.stringName(x.getName()); … … 102 102 103 103 @Override 104 public Boolean for AbsTraitDecl(AbsTraitDecl x) {104 public Boolean forTraitDecl(TraitDecl x) { 105 105 Boolean change = Boolean.FALSE; 106 // super.for AbsTraitDecl(x);106 // super.forTraitDecl(x); 107 107 if (getPass() == 1) { 108 108 String fname = NodeUtil.stringName(x.getName()); -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BuildEnvironments.java
r3095 r3096 522 522 } 523 523 524 private void makeGenericSingleton(Object AbsDeclOrDecl x, Environment e, Id name,524 private void makeGenericSingleton(ObjectDecl x, Environment e, Id name, 525 525 String fname, FTraitOrObjectOrGeneric ft) { 526 526 GenericConstructor gen = new GenericConstructor(e, x, name); … … 800 800 * (non-Javadoc) 801 801 * 802 * @see com.sun.fortress.interpreter.nodes.NodeVisitor#forTraitDecl(com.sun.fortress.interpreter.nodes.AbsTraitDecl)803 */804 @Override805 public Boolean forAbsTraitDecl(AbsTraitDecl x) {806 return bug("BuildEnvironments.forAbsTraitDecl should not be called");807 }808 809 /*810 * (non-Javadoc)811 *812 802 * @see com.sun.fortress.interpreter.nodes.NodeVisitor#forTraitDef(com.sun.fortress.interpreter.nodes.TraitDecl) 813 803 */ … … 882 872 * @param interior 883 873 */ 884 public void finishTrait(Trait AbsDeclOrDecl x, FTypeTrait ftt, Environment interior) {874 public void finishTrait(TraitDecl x, FTypeTrait ftt, Environment interior) { 885 875 List<BaseType> extends_ = NodeUtil.getTypes(x.getExtendsClause()); 886 876 // TODO What if I don't … … 991 981 } 992 982 993 public void finishObjectTrait(Object AbsDeclOrDecl x, FTypeObject ftt) {983 public void finishObjectTrait(ObjectDecl x, FTypeObject ftt) { 994 984 List<BaseType> extends_ = NodeUtil.getTypes(x.getExtendsClause()); 995 985 finishObjectTrait(extends_, null, x.getWhere(), ftt, containing, x); … … 1091 1081 } 1092 1082 1093 /*1094 * (non-Javadoc)1095 *1096 * @see com.sun.fortress.interpreter.nodes.NodeVisitor#forAbsObjectDecl(com.sun.fortress.interpreter.nodes.AbsObjectDecl)1097 */1098 @Override1099 public Boolean forAbsObjectDecl(AbsObjectDecl x) {1100 return bug("BuildEnvironments.forAbsObjectDecl should not be called");1101 1102 }1103 1104 1083 public Environment getBindingEnv() { 1105 1084 return bindInto; -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BuildTopLevelEnvironments.java
r3093 r3096 31 31 import com.sun.fortress.nodes.APIName; 32 32 import com.sun.fortress.nodes.Decl; 33 import com.sun.fortress.nodes.AbsTraitDecl;34 33 import com.sun.fortress.nodes.AliasedAPIName; 35 34 import com.sun.fortress.nodes.Api; … … 247 246 248 247 /* (non-Javadoc) 249 * @see com.sun.fortress.interpreter.nodes.NodeVisitor#forAbsTraitDecl(com.sun.fortress.interpreter.nodes.AbsTraitDecl)250 */251 @Override252 public Boolean forAbsTraitDecl(AbsTraitDecl x) {253 List<StaticParam> staticParams = x.getStaticParams();254 Id name = x.getName();255 256 if (staticParams.isEmpty()) {257 FTypeTrait ftt =258 (FTypeTrait) containing.getRootType(NodeUtil.nameString(name)); // top level259 Environment interior = ftt.getWithin();260 ftt.getMembers();261 }262 return null;263 }264 265 /* (non-Javadoc)266 248 * @see com.sun.fortress.interpreter.nodes.NodeVisitor#forTraitDecl(com.sun.fortress.interpreter.nodes.TraitDecl) 267 249 */ -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/EvalVarsEnvironment.java
r3095 r3096 18 18 package com.sun.fortress.interpreter.evaluator; 19 19 20 import com.sun.fortress.nodes.AbsObjectDecl; 21 import com.sun.fortress.nodes.AbsTraitDecl; 20 import com.sun.fortress.nodes.ObjectDecl; 22 21 import com.sun.fortress.nodes.Api; 23 22 import com.sun.fortress.nodes.Component; … … 104 103 105 104 /* (non-Javadoc) 106 * @see com.sun.fortress.interpreter.evaluator.BuildEnvironments#forObjectDecl(com.sun.fortress.interpreter.nodes.AbsObjectDecl)107 */108 @Override109 public Boolean forAbsObjectDecl(AbsObjectDecl x) {110 return null;111 112 }113 114 /* (non-Javadoc)115 105 * @see com.sun.fortress.interpreter.evaluator.BuildEnvironments#forObjectDef(com.sun.fortress.interpreter.nodes.ObjectDecl) 116 106 */ 117 107 @Override 118 108 public Boolean forObjectDecl(ObjectDecl x) { 119 return null;120 121 }122 123 /* (non-Javadoc)124 * @see com.sun.fortress.interpreter.evaluator.BuildEnvironments#forTraitDecl(com.sun.fortress.interpreter.nodes.AbsTraitDecl)125 */126 @Override127 public Boolean forAbsTraitDecl(AbsTraitDecl x) {128 109 return null; 129 110 -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/ScoutVisitor.java
r3095 r3096 20 20 21 21 import com.sun.fortress.interpreter.evaluator.values.Overload; 22 import com.sun.fortress.nodes.AbsObjectDecl; 23 import com.sun.fortress.nodes.AbsTraitDecl; 22 import com.sun.fortress.nodes.ObjectDecl; 24 23 import com.sun.fortress.nodes.ArrayType; 25 24 import com.sun.fortress.nodes.ArrowType; … … 30 29 import com.sun.fortress.nodes.MatrixType; 31 30 import com.sun.fortress.nodes.NodeAbstractVisitor_void; 32 import com.sun.fortress.nodes.ObjectAbsDeclOrDecl;33 31 import com.sun.fortress.nodes.ObjectDecl; 34 import com.sun.fortress.nodes. TraitAbsDeclOrDecl;32 import com.sun.fortress.nodes.ObjectDecl; 35 33 import com.sun.fortress.nodes.TraitDecl; 36 import com.sun.fortress.nodes.TraitObject AbsDeclOrDecl;34 import com.sun.fortress.nodes.TraitObjectDecl; 37 35 import com.sun.fortress.nodes.BaseType; 38 36 import com.sun.fortress.nodes.TraitTypeWhere; … … 44 42 45 43 public class ScoutVisitor extends NodeAbstractVisitor_void { 46 /* (non-Javadoc)47 * @see com.sun.fortress.nodes.NodeAbstractVisitor_void#forAbsObjectDecl(com.sun.fortress.nodes.AbsObjectDecl)48 */49 @Override50 public void forAbsObjectDecl(AbsObjectDecl that) {51 // TODO Auto-generated method stub52 super.forAbsObjectDecl(that);53 }54 55 /* (non-Javadoc)56 * @see com.sun.fortress.nodes.NodeAbstractVisitor_void#forAbsTraitDecl(com.sun.fortress.nodes.AbsTraitDecl)57 */58 @Override59 public void forAbsTraitDecl(AbsTraitDecl that) {60 // TODO Auto-generated method stub61 super.forAbsTraitDecl(that);62 }63 64 44 /* (non-Javadoc) 65 45 * @see com.sun.fortress.nodes.NodeAbstractVisitor_void#forArrayType(com.sun.fortress.nodes.ArrayType) … … 126 106 127 107 /* (non-Javadoc) 128 * @see com.sun.fortress.nodes.NodeAbstractVisitor_void#forObjectAbsDeclOrDecl(com.sun.fortress.nodes.ObjectAbsDeclOrDecl)129 */130 @Override131 public void forObjectAbsDeclOrDecl(ObjectAbsDeclOrDecl that) {132 // TODO Auto-generated method stub133 super.forObjectAbsDeclOrDecl(that);134 }135 136 /* (non-Javadoc)137 108 * @see com.sun.fortress.nodes.NodeAbstractVisitor_void#forObjectDecl(com.sun.fortress.nodes.ObjectDecl) 138 109 */ … … 141 112 // TODO Auto-generated method stub 142 113 super.forObjectDecl(that); 143 }144 145 /* (non-Javadoc)146 * @see com.sun.fortress.nodes.NodeAbstractVisitor_void#forTraitAbsDeclOrDecl(com.sun.fortress.nodes.TraitAbsDeclOrDecl)147 */148 @Override149 public void forTraitAbsDeclOrDecl(TraitAbsDeclOrDecl that) {150 // TODO Auto-generated method stub151 super.forTraitAbsDeclOrDecl(that);152 114 } 153 115 … … 162 124 163 125 /* (non-Javadoc) 164 * @see com.sun.fortress.nodes.NodeAbstractVisitor_void#forTraitObject AbsDeclOrDecl(com.sun.fortress.nodes.TraitObjectAbsDeclOrDecl)126 * @see com.sun.fortress.nodes.NodeAbstractVisitor_void#forTraitObjectDecl(com.sun.fortress.nodes.TraitObjectDecl) 165 127 */ 166 128 @Override 167 public void forTraitObject AbsDeclOrDecl(TraitObjectAbsDeclOrDecl that) {129 public void forTraitObjectDecl(TraitObjectDecl that) { 168 130 // TODO Auto-generated method stub 169 super.forTraitObject AbsDeclOrDecl(that);131 super.forTraitObjectDecl(that); 170 132 } 171 133 -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/types/FTraitOrObjectOrGeneric.java
r3095 r3096 33 33 import com.sun.fortress.nodes.Modifier; 34 34 import com.sun.fortress.nodes.ModifierValue; 35 import com.sun.fortress.nodes.TraitObject AbsDeclOrDecl;35 import com.sun.fortress.nodes.TraitObjectDecl; 36 36 import com.sun.fortress.nodes_util.NodeComparator; 37 37 import com.sun.fortress.nodes_util.NodeUtil; … … 46 46 this.decl = def; 47 47 boolean isValueType = false; 48 if (def instanceof TraitObject AbsDeclOrDecl)49 for (Modifier mod : ((TraitObject AbsDeclOrDecl) def).getMods())48 if (def instanceof TraitObjectDecl) 49 for (Modifier mod : ((TraitObjectDecl) def).getMods()) 50 50 if (mod instanceof ModifierValue) { 51 51 isValueType = true; -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/types/FTypeGeneric.java
r3093 r3096 47 47 import com.sun.fortress.nodes.StaticArg; 48 48 import com.sun.fortress.nodes.StaticParam; 49 import com.sun.fortress.nodes.Trait AbsDeclOrDecl;50 import com.sun.fortress.nodes.TraitObject AbsDeclOrDecl;49 import com.sun.fortress.nodes.TraitDecl; 50 import com.sun.fortress.nodes.TraitObjectDecl; 51 51 import com.sun.fortress.nodes.TraitType; 52 52 import com.sun.fortress.nodes.Type; … … 105 105 } 106 106 107 public FTypeGeneric(FTypeGeneric orig, TraitObject AbsDeclOrDecl new_def) {107 public FTypeGeneric(FTypeGeneric orig, TraitObjectDecl new_def) { 108 108 super(orig.getName(), orig.getWithin(), orig.getDecl()); 109 109 genericAt = orig.getDef(); … … 257 257 //OprInstantiater oi = new OprInstantiater(substitutions); 258 258 259 TraitObject AbsDeclOrDecl new_def =260 (TraitObject AbsDeclOrDecl)oi.visit((TraitObjectAbsDeclOrDecl)FTypeGeneric.this.getDef());259 TraitObjectDecl new_def = 260 (TraitObjectDecl)oi.visit((TraitObjectDecl)FTypeGeneric.this.getDef()); 261 261 262 262 FTypeGeneric replacement = … … 280 280 FTraitOrObject rval; 281 281 282 if (gen.def instanceof Trait AbsDeclOrDecl) {283 Trait AbsDeclOrDecl td = (TraitAbsDeclOrDecl) gen.def;282 if (gen.def instanceof TraitDecl) { 283 TraitDecl td = (TraitDecl) gen.def; 284 284 FTypeTraitInstance ftt = new FTypeTraitInstance(td.getName().getText(), 285 285 clenv, gen, bind_args, key_args, gen.members); -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/values/GenericSingleton.java
r1800 r3096 25 25 import com.sun.fortress.interpreter.evaluator.types.FType; 26 26 import com.sun.fortress.nodes.IdOrOpOrAnonymousName; 27 import com.sun.fortress.nodes.Object AbsDeclOrDecl;27 import com.sun.fortress.nodes.ObjectDecl; 28 28 import com.sun.fortress.nodes.StaticArg; 29 29 import com.sun.fortress.nodes.StaticParam; … … 34 34 public class GenericSingleton extends FValue implements Factory1P<List<FType>, FObject, HasAt> { 35 35 36 Object AbsDeclOrDecl odecl;36 ObjectDecl odecl; 37 37 FType t; 38 38 GenericConstructor genericConstructor; 39 39 40 public GenericSingleton(Object AbsDeclOrDecl odecl, FType t, GenericConstructor gc) {40 public GenericSingleton(ObjectDecl odecl, FType t, GenericConstructor gc) { 41 41 super(); 42 42 this.odecl = odecl; -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/rewrite/DesugarerVisitor.java
r3095 r3096 46 46 import com.sun.fortress.nodes_util.Span; 47 47 import com.sun.fortress.nodes.APIName; 48 import com.sun.fortress.nodes.AbsTraitDecl;49 48 import com.sun.fortress.nodes.AbstractNode; 50 49 import com.sun.fortress.nodes.AbstractObjectExpr; … … 99 98 import com.sun.fortress.nodes.TestDecl; 100 99 import com.sun.fortress.nodes.TightJuxt; 101 import com.sun.fortress.nodes.TraitAbsDeclOrDecl;102 100 import com.sun.fortress.nodes.BaseType; 103 101 import com.sun.fortress.nodes.TraitDecl; 104 import com.sun.fortress.nodes.TraitObject AbsDeclOrDecl;102 import com.sun.fortress.nodes.TraitObjectDecl; 105 103 import com.sun.fortress.nodes.TraitType; 106 104 import com.sun.fortress.nodes.TupleExpr; … … 199 197 */ 200 198 private class Trait extends Local { 201 Trait AbsDeclOrDecl defOrDecl;199 TraitDecl defOrDecl; 202 200 Map<String, Thing> env; 203 Trait(Trait AbsDeclOrDecl dod, Map<String, Thing> env) { defOrDecl = dod; this.env = env; }201 Trait(TraitDecl dod, Map<String, Thing> env) { defOrDecl = dod; this.env = env; } 204 202 public String toString() { return "Trait="+defOrDecl; } 205 203 … … 1032 1030 1033 1031 @Override 1034 public Node forAbsTraitDecl(AbsTraitDecl td) {1035 List<Decl> defs = td.getDecls();1036 List<StaticParam> tparams = td.getStaticParams();1037 // TODO wip1038 lexicalNestingDepth++;1039 objectNestingDepth++;1040 atTopLevelInsideTraitOrObject = true;1041 defsToMembers(defs);1042 immediateDef = tparamsToLocals(tparams, immediateDef);1043 1044 accumulateMembersFromExtends(td);1045 1046 inTrait = true;1047 AbstractNode n = visitNodeTO(td);1048 inTrait = false;1049 return n;1050 }1051 1052 @Override1053 1032 public Node forTraitDecl(TraitDecl td) { 1054 1033 List<Decl> defs = td.getDecls(); … … 1261 1240 * @param td 1262 1241 */ 1263 private void accumulateMembersFromExtends(Trait AbsDeclOrDecl td) {1242 private void accumulateMembersFromExtends(TraitDecl td) { 1264 1243 accumulateMembersFromExtends(NodeUtil.getTypes(td.getExtendsClause()), 1265 1244 rewrites); … … 1301 1280 private void defsToLocals(List<Decl> defs) { 1302 1281 for (Decl d : defs) { 1303 if (d instanceof Trait AbsDeclOrDecl) {1282 if (d instanceof TraitDecl) { 1304 1283 String s = d.stringName(); 1305 Trait AbsDeclOrDecl dod = (TraitAbsDeclOrDecl) d;1284 TraitDecl dod = (TraitDecl) d; 1306 1285 type_rewrites_put(s, new Trait(dod, rewrites)); 1307 1286 } else if (d instanceof ObjectDecl) { … … 1335 1314 private void functionalMethodsOfDefsToLocals(List<Decl> defs) { 1336 1315 for (Decl d : defs) { 1337 if (d instanceof TraitObject AbsDeclOrDecl) {1338 TraitObject AbsDeclOrDecl dod = (TraitObjectAbsDeclOrDecl) d;1316 if (d instanceof TraitObjectDecl) { 1317 TraitObjectDecl dod = (TraitObjectDecl) d; 1339 1318 List <Decl> tdecls = dod.getDecls(); 1340 1319 handlePossibleFM(tdecls); … … 1559 1538 if (th instanceof Trait) { 1560 1539 Trait tr = (Trait) th; 1561 Trait AbsDeclOrDecl tdod = tr.defOrDecl;1540 TraitDecl tdod = tr.defOrDecl; 1562 1541 if (!(visited.contains(tdod))) { 1563 1542 visited.add(tdod); -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/rewrite/OprInstantiaterVisitor.java
r3092 r3096 31 31 import com.sun.fortress.nodes.StaticArg; 32 32 import com.sun.fortress.nodes.StaticParam; 33 import com.sun.fortress.nodes.TraitObject AbsDeclOrDecl;33 import com.sun.fortress.nodes.TraitObjectDecl; 34 34 import com.sun.fortress.nodes.Type; 35 35 import com.sun.fortress.nodes_util.ExprFactory; … … 44 44 Map<String, String> subst; 45 45 46 public TraitObject AbsDeclOrDecl visit(TraitObjectAbsDeclOrDecl toadod) {47 return (TraitObject AbsDeclOrDecl) toadod.accept(this);46 public TraitObjectDecl visit(TraitObjectDecl toadod) { 47 return (TraitObjectDecl) toadod.accept(this); 48 48 } 49 49 50 50 public OprInstantiaterVisitor(Map<String, String> subst) { 51 51 this.subst = subst; … … 68 68 final Option<Type> otype = op.getExprType(); 69 69 final Type type = otype.isNone() ? null : otype.unwrap(); 70 70 71 71 OpName n_originalName = (OpName) recur(originalName); 72 72 List<OpName> n_ops = recurOnListOfOpName(ops); 73 73 List<StaticArg> n_args = recurOnListOfStaticArg(args); 74 74 Type n_type = type == null ? (Type) null : (Type) recur(type); 75 75 76 76 if (args != n_args || originalName != n_originalName || ops != n_ops || type != n_type) { 77 77 return new OpRef(op.getSpan(), op.isParenthesized(), Option.wrap(n_type), n_args, Environment.TOP_LEVEL, 78 78 n_originalName, n_ops); 79 79 } 80 80 81 81 return op; 82 82 } … … 89 89 } else return opp; 90 90 } 91 92 91 92 93 93 @Override 94 94 public List<StaticParam> recurOnListOfStaticParam(List<StaticParam> that) { -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/ApiMaker.java
r3095 r3096 119 119 List<Decl> absDecls = declsToDecls(that.getDecls()); 120 120 inTrait = false; 121 return Option.<Node>some(new AbsTraitDecl(that.getSpan(),122 that.getMods(),123 that.getName(),124 that.getStaticParams(),125 that.getExtendsClause(),126 that.getWhere(),127 that.getExcludes(),128 that.getComprises(),129 absDecls));121 return Option.<Node>some(new TraitDecl(that.getSpan(), 122 that.getMods(), 123 that.getName(), 124 that.getStaticParams(), 125 that.getExtendsClause(), 126 that.getWhere(), 127 that.getExcludes(), 128 that.getComprises(), 129 absDecls)); 130 130 } else return Option.<Node>none(); 131 131 } … … 136 136 List<Decl> absDecls = declsToDecls(that.getDecls()); 137 137 inObject = false; 138 return Option.<Node>some(new AbsObjectDecl(that.getSpan(),139 that.getMods(),140 that.getName(),141 that.getStaticParams(),142 that.getExtendsClause(),143 that.getWhere(),144 that.getParams(),145 that.getThrowsClause(),146 that.getContract(),147 absDecls));138 return Option.<Node>some(new ObjectDecl(that.getSpan(), 139 that.getMods(), 140 that.getName(), 141 that.getStaticParams(), 142 that.getExtendsClause(), 143 that.getWhere(), 144 that.getParams(), 145 that.getThrowsClause(), 146 that.getContract(), 147 absDecls)); 148 148 } else return Option.<Node>none(); 149 149 } -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/ErrorMsgMaker.java
r3095 r3096 62 62 } 63 63 64 public String forTraitObject AbsDeclOrDecl(TraitObjectAbsDeclOrDecl node) {64 public String forTraitObjectDecl(TraitObjectDecl node) { 65 65 return node.getClass().getSimpleName() + " " + node.getName() + " at " + node.getSpan().begin.at(); 66 66 } -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/NodeUtil.java
r3095 r3096 384 384 } 385 385 @Override 386 public String forObject AbsDeclOrDecl(ObjectAbsDeclOrDecl node) {386 public String forObjectDecl(ObjectDecl node) { 387 387 return node.getName().getText(); 388 388 } … … 392 392 } 393 393 @Override 394 public String forTrait AbsDeclOrDecl(TraitAbsDeclOrDecl node) {394 public String forTraitDecl(TraitDecl node) { 395 395 return node.getName().getText(); 396 396 } … … 451 451 return new IterableOnceForLValueList(d.getLhs()); 452 452 } 453 public IterableOnce<String> forObject AbsDeclOrDecl(ObjectAbsDeclOrDecl d) {453 public IterableOnce<String> forObjectDecl(ObjectDecl d) { 454 454 return new UnitIterable<String>(d.getName().getText()); 455 455 } … … 470 470 return new UnitIterable<String>(d.getName().getText()); 471 471 } 472 public IterableOnce<String> forTrait AbsDeclOrDecl(TraitAbsDeclOrDecl d) {472 public IterableOnce<String> forTraitDecl(TraitDecl d) { 473 473 return new UnitIterable<String>(d.getName().getText()); 474 474 } -
trunk/ProjectFortress/src/com/sun/fortress/parser/TraitObject.rats
r3093 r3096 309 309 ((s trait)? s Id)? 310 310 */ 311 AbsTraitDecl AbsTraitDecl =311 TraitDecl AbsTraitDecl = 312 312 a1:Mods? a2:TraitHeaderFront a3:AbsTraitClauses 313 313 a4:(w AbsGoInATrait)? w end a5:((s trait)? s Id)? … … 318 318 if (a1 == null) a1 = FortressUtil.emptyModifiers(); 319 319 if (a4 == null) a4 = Collections.<Decl>emptyList(); 320 yyValue = new AbsTraitDecl320 yyValue = new TraitDecl 321 321 (span, a1, a2.getName(), 322 322 a2.getStaticParams(), a2.getExtendsClause(), a3.getWhere(), … … 421 421 ((s object)? s Id)? 422 422 */ 423 AbsObjectDecl AbsObjectDecl =423 ObjectDecl AbsObjectDecl = 424 424 a1:Mods? a2:ObjectHeader a3:(w AbsGoInAnObject)? w end 425 425 a4:((s object)? s Id)? … … 434 434 Option<List<Param>> params = a2.getParams(); 435 435 FortressUtil.checkNoWrapped(params); 436 yyValue = new AbsObjectDecl436 yyValue = new ObjectDecl 437 437 (span, a1, a2.getName(), 438 438 a2.getStaticParams(), a2.getExtendsClause(), fhc.getWhereClause(), -
trunk/ProjectFortress/src/com/sun/fortress/parser_util/SyntaxChecker.java
r3095 r3096 84 84 } 85 85 86 public void forAbsTraitDecl(AbsTraitDecl that) {87 inTrait = true;88 List<Modifier> mods = that.getMods();89 for ( Modifier mod : mods ) {90 if ( ! ((mod instanceof ModifierValue) ||91 (mod instanceof ModifierTest)) )92 log(that, "The modifier " + mod + " of the trait " +93 that.getName() + " is not a valid modifier " +94 "for a trait in an API.");95 }96 super.forAbsTraitDecl( that );97 inTrait = false;98 }99 100 86 public void forTraitDecl(TraitDecl that) { 101 87 inTrait = true; 102 88 List<Modifier> mods = that.getMods(); 103 for ( Modifier mod : mods ) { 104 if ( ! ((mod instanceof ModifierPrivate) || 105 (mod instanceof ModifierValue) || 106 (mod instanceof ModifierTest)) ) 107 log(that, "The modifier " + mod + " of the trait " + 108 that.getName() + " is not a valid modifier " + 109 "for a trait in a component."); 89 if ( inComponent ) { 90 for ( Modifier mod : mods ) { 91 if ( ! ((mod instanceof ModifierPrivate) || 92 (mod instanceof ModifierValue) || 93 (mod instanceof ModifierTest)) ) 94 log(that, "The modifier " + mod + " of the trait " + 95 that.getName() + " is not a valid modifier " + 96 "for a trait in a component."); 97 } 98 } else if ( inApi ) { 99 for ( Modifier mod : mods ) { 100 if ( ! ((mod instanceof ModifierValue) || 101 (mod instanceof ModifierTest)) ) 102 log(that, "The modifier " + mod + " of the trait " + 103 that.getName() + " is not a valid modifier " + 104 "for a trait in an API."); 105 } 110 106 } 111 107 super.forTraitDecl( that ); 112 108 inTrait = false; 113 }114 115 public void forAbsObjectDecl(AbsObjectDecl that) {116 inObject = true;117 List<Modifier> mods = that.getMods();118 for ( Modifier mod : mods ) {119 if ( ! ((mod instanceof ModifierValue) ||120 (mod instanceof ModifierTest)) )121 log(that, "The modifier " + mod + " of the object " +122 that.getName() + " is not a valid modifier " +123 "for an object in an API.");124 }125 super.forAbsObjectDecl( that );126 inObject = false;127 109 } 128 110 … … 130 112 inObject = true; 131 113 List<Modifier> mods = that.getMods(); 132 for ( Modifier mod : mods ) { 133 if ( ! ((mod instanceof ModifierPrivate) || 134 (mod instanceof ModifierValue) || 135 (mod instanceof ModifierTest)) ) 136 log(that, "The modifier " + mod + " of the object " + 137 that.getName() + " is not a valid modifier " + 138 "for an object in a component."); 114 if ( inComponent ) { 115 for ( Modifier mod : mods ) { 116 if ( ! ((mod instanceof ModifierPrivate) || 117 (mod instanceof ModifierValue) || 118 (mod instanceof ModifierTest)) ) 119 log(that, "The modifier " + mod + " of the object " + 120 that.getName() + " is not a valid modifier " + 121 "for an object in a component."); 122 } 123 } else { 124 for ( Modifier mod : mods ) { 125 if ( ! ((mod instanceof ModifierValue) || 126 (mod instanceof ModifierTest)) ) 127 log(that, "The modifier " + mod + " of the object " + 128 that.getName() + " is not a valid modifier " + 129 "for an object in an API."); 130 } 139 131 } 140 132 super.forObjectDecl( that ); -
trunk/ProjectFortress/src/com/sun/fortress/tools/FortressAstToConcrete.java
r3095 r3096 49 49 private boolean _unqualified; 50 50 private boolean _unmangle; 51 private boolean inComponent = false; 51 52 private int width = 50; 52 53 private Set<String> locals = new HashSet<String>(); … … 279 280 List<String> decls_result, 280 281 List<String> objectExprs) { 282 inComponent = true; 281 283 // note objectExprs parameter is a temporary hack. 282 284 StringBuilder s = new StringBuilder(); … … 302 304 List<String> imports_result, 303 305 List<String> decls_result) { 306 inComponent = false; 304 307 //increaseIndent(); 305 308 StringBuilder s = new StringBuilder(); … … 374 377 s.append( " as " ).append(alias_result.unwrap()); 375 378 } 376 return s.toString();377 }378 379 @Override public String forAbsTraitDeclOnly(AbsTraitDecl that,380 List<String> mods_result,381 String name_result,382 List<String> staticParams_result,383 List<String> extendsClause_result,384 Option<String> where_result,385 List<String> excludes_result,386 Option<List<String>> comprises_result,387 List<String> decls_result) {388 StringBuilder s = new StringBuilder();389 390 increaseIndent();391 if ( ! mods_result.isEmpty() ) {392 s.append( join(mods_result, " ") );393 s.append( " ");394 }395 s.append( "trait " ).append( name_result );396 inOxfordBrackets(s, staticParams_result);397 s = optCurlyBraces(s, " extends ", extendsClause_result, "");398 if ( where_result.isSome() )399 s.append("\n ").append( where_result.unwrap() );400 s = optCurlyBraces(s, " excludes ", excludes_result, "");401 if ( comprises_result.isSome() ){402 List<String> throws_ = comprises_result.unwrap();403 s.append(" comprises ");404 if ( ! throws_.isEmpty() )405 inCurlyBraces(s, "", throws_);406 else407 s.append( "{ ... }" );408 }409 if ( ! decls_result.isEmpty() ) {410 s.append( "\n" );411 s.append( indent(join(decls_result,"\n")) );412 }413 s.append( "\nend" );414 415 decreaseIndent();416 417 379 return s.toString(); 418 380 } … … 444 406 } 445 407 446 @Override public String forAbsTraitDecl(AbsTraitDecl that) { 447 List<String> mods_result = recurOnListOfModifier(that.getMods()); 448 String name_result = recur(that.getName()); 449 List<String> staticParams_result = recurOnListOfStaticParam(that.getStaticParams()); 450 List<String> extendsClause_result = recurOnListOfTraitTypeWhere(that.getExtendsClause()); 451 Option<String> where_result = recurOnOptionOfWhereClause(that.getWhere()); 452 List<String> excludes_result = recurOnListOfBaseType(that.getExcludes()); 453 Option<List<String>> comprises_result = recurOnOptionOfListOfBaseType(that.getComprises()); 454 List<String> decls_result = myRecurOnListOfDecl(that.getDecls()); 455 return forAbsTraitDeclOnly(that, mods_result, name_result, 456 staticParams_result, extendsClause_result, 457 where_result, excludes_result, comprises_result, 458 decls_result); 408 @Override public String forTraitDecl(TraitDecl that) { 409 if ( inComponent ) 410 return super.forTraitDecl( that ); 411 else { 412 List<String> mods_result = recurOnListOfModifier(that.getMods()); 413 String name_result = recur(that.getName()); 414 List<String> staticParams_result = recurOnListOfStaticParam(that.getStaticParams()); 415 List<String> extendsClause_result = recurOnListOfTraitTypeWhere(that.getExtendsClause()); 416 Option<String> where_result = recurOnOptionOfWhereClause(that.getWhere()); 417 List<String> excludes_result = recurOnListOfBaseType(that.getExcludes()); 418 Option<List<String>> comprises_result = recurOnOptionOfListOfBaseType(that.getComprises()); 419 List<String> decls_result = myRecurOnListOfDecl(that.getDecls()); 420 return forTraitDeclOnly(that, mods_result, name_result, 421 staticParams_result, extendsClause_result, 422 where_result, excludes_result, comprises_result, 423 decls_result); 424 } 459 425 } 460 426 … … 481 447 s.append(" ").append( where_result.unwrap() ); 482 448 s = optCurlyBraces(s, " excludes ", excludes_result, ""); 483 s = optCurlyClause(s, " comprises ", comprises_result); 449 if ( inComponent ) 450 s = optCurlyClause(s, " comprises ", comprises_result); 451 else { 452 if ( comprises_result.isSome() ){ 453 List<String> throws_ = comprises_result.unwrap(); 454 s.append(" comprises "); 455 if ( ! throws_.isEmpty() ) 456 inCurlyBraces(s, "", throws_); 457 else 458 s.append( "{ ... }" ); 459 } 460 } 484 461 if ( ! decls_result.isEmpty() ) { 485 462 s.append( "\n" ); … … 493 470 } 494 471 495 @Override public String forAbsObjectDeclOnly(AbsObjectDecl that, 496 List<String> mods_result, 497 String name_result, 498 List<String> staticParams_result, 499 List<String> extendsClause_result, 500 Option<String> where_result, 501 Option<List<String>> params_result, 502 Option<List<String>> throwsClause_result, 503 Option<String> contract_result, 504 List<String> decls_result) { 505 StringBuilder s = new StringBuilder(); 506 507 increaseIndent(); 508 509 if ( ! mods_result.isEmpty() ) { 510 s.append( join(mods_result, " ") ); 511 s.append( " " ); 512 } 513 s.append( "object " ).append( name_result ); 514 inOxfordBrackets(s, staticParams_result); 515 if ( params_result.isSome() ){ 516 s.append( inParentheses(inParentheses(params_result.unwrap())) ); 517 } 518 s = optCurlyBraces(s, " extends ", extendsClause_result, ""); 519 throwsClause(s, throwsClause_result); 520 if ( where_result.isSome() ) 521 s.append(" ").append( where_result.unwrap() ); 522 if ( contract_result.isSome() ) { 523 s.append( " " ); 524 s.append( contract_result.unwrap() ); 525 } 526 if ( ! decls_result.isEmpty() ) { 527 s.append( "\n" ); 528 s.append( indent(join(decls_result,"\n")) ); 529 } 530 s.append( "\nend" ); 531 532 decreaseIndent(); 533 534 return s.toString(); 535 } 536 537 public String forAbsObjectDecl(AbsObjectDecl that) { 538 List<String> mods_result = recurOnListOfModifier(that.getMods()); 539 String name_result = recur(that.getName()); 540 List<String> staticParams_result = recurOnListOfStaticParam(that.getStaticParams()); 541 List<String> extendsClause_result = recurOnListOfTraitTypeWhere(that.getExtendsClause()); 542 Option<String> where_result = recurOnOptionOfWhereClause(that.getWhere()); 543 Option<List<String>> params_result = recurOnOptionOfListOfParam(that.getParams()); 544 Option<List<String>> throwsClause_result = recurOnOptionOfListOfBaseType(that.getThrowsClause()); 545 Option<String> contract_result = recurOnOptionOfContract(that.getContract()); 546 List<String> decls_result = myRecurOnListOfDecl(that.getDecls()); 547 return forAbsObjectDeclOnly(that, mods_result, name_result, 548 staticParams_result, extendsClause_result, 549 where_result, params_result, 550 throwsClause_result, contract_result, 551 decls_result); 472 public String forObjectDecl(ObjectDecl that) { 473 if ( inComponent ) 474 return super.forObjectDecl( that ); 475 else { 476 List<String> mods_result = recurOnListOfModifier(that.getMods()); 477 String name_result = recur(that.getName()); 478 List<String> staticParams_result = recurOnListOfStaticParam(that.getStaticParams()); 479 List<String> extendsClause_result = recurOnListOfTraitTypeWhere(that.getExtendsClause()); 480 Option<String> where_result = recurOnOptionOfWhereClause(that.getWhere()); 481 Option<List<String>> params_result = recurOnOptionOfListOfParam(that.getParams()); 482 Option<List<String>> throwsClause_result = recurOnOptionOfListOfBaseType(that.getThrowsClause()); 483 Option<String> contract_result = recurOnOptionOfContract(that.getContract()); 484 List<String> decls_result = myRecurOnListOfDecl(that.getDecls()); 485 return forObjectDeclOnly(that, mods_result, name_result, 486 staticParams_result, extendsClause_result, 487 where_result, params_result, 488 throwsClause_result, contract_result, 489 decls_result); 490 } 552 491 } 553 492

