Changeset 3096

Show
Ignore:
Timestamp:
11/24/08 22:51:08 (12 months ago)
Author:
sukyoungryu
Message:

[ast refactoring] Remove distinctions between AbsTraitDecl/TraitDecl? and AbsObjectDecl/ObjectDecl?.

Location:
trunk
Files:
31 modified

Legend:

Unmodified
Added
Removed
  • trunk/Library/FortressSyntax.fsi

    r3095 r3096  
    4545  native grammar TraitObject (* rename to TraitsAndObjectDecls *) 
    4646    TraitDecl : TraitDecl 
    47     AbsTraitDecl : AbsTraitDecl 
     47    AbsTraitDecl : TraitDecl 
    4848    ObjectDecl : ObjectDecl 
    49     AbsObjectDecl : AbsObjectDecl 
     49    AbsObjectDecl : ObjectDecl 
    5050  end 
    5151 
  • trunk/ProjectFortress/astgen/Fortress.ast

    r3095 r3096  
    220220         * Name must be unqualified. 
    221221         */ 
    222         abstract TraitObjectAbsDeclOrDecl(List<Modifier> mods 
     222        abstract TraitObjectDecl(List<Modifier> mods 
    223223                                     = Collections.<Modifier>emptyList(), 
    224224                                 Id name, 
     
    233233            /** 
    234234             * 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; 
    285280            /** 
    286281             * 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; 
    336325        /** 
    337326         * variable declaration in components or APIs 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/IndexBuilder.java

    r3095 r3096  
    149149            new HashMap<String, GrammarIndex>(); 
    150150        NodeAbstractVisitor_void handleDecl = new NodeAbstractVisitor_void() { 
    151             @Override public void forAbsTraitDecl(AbsTraitDecl d) { 
     151            @Override public void forTraitDecl(TraitDecl d) { 
    152152                buildTrait(d, typeConses, functions); 
    153153            } 
    154             @Override public void forAbsObjectDecl(AbsObjectDecl d) { 
     154            @Override public void forObjectDecl(ObjectDecl d) { 
    155155                buildObject(d, typeConses, functions, variables); 
    156156            } 
     
    269269     * to the given relation. 
    270270     */ 
    271     private void buildTrait(TraitAbsDeclOrDecl ast, 
     271    private void buildTrait(TraitDecl ast, 
    272272            Map<Id, TypeConsIndex> typeConses, 
    273273            final Relation<IdOrOpOrAnonymousName, Function> functions) { 
     
    305305     * put it in the appropriate map. 
    306306     */ 
    307     private void buildObject(ObjectAbsDeclOrDecl ast, 
     307    private void buildObject(ObjectDecl ast, 
    308308            Map<Id, TypeConsIndex> typeConses, 
    309309            final Relation<IdOrOpOrAnonymousName, Function> functions, 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/PreDisambiguationDesugaringVisitor.java

    r3093 r3096  
    7575 
    7676    @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     @Override 
    9477        public Node forTraitDeclOnly(TraitDecl that, 
    9578                                     List<Modifier> mods, 
     
    10689        return super.forTraitDeclOnly(that, mods, name, staticParams, extendsClause, 
    10790                                      where, excludes, comprises, decls); 
    108     } 
    109  
    110     @Override 
    111         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); 
    12491    } 
    12592 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/ExprDisambiguator.java

    r3095 r3096  
    3131import com.sun.fortress.nodes.APIName; 
    3232import com.sun.fortress.nodes.Decl; 
    33 import com.sun.fortress.nodes.AbsObjectDecl; 
    34 import com.sun.fortress.nodes.AbsTraitDecl; 
     33import com.sun.fortress.nodes.ObjectDecl; 
    3534import com.sun.fortress.nodes.VarDecl; 
    3635import com.sun.fortress.nodes.Accumulator; 
     
    3938import com.sun.fortress.nodes.BoolParam; 
    4039import com.sun.fortress.nodes.Catch; 
     40import com.sun.fortress.nodes.Component; 
    4141import com.sun.fortress.nodes.Contract; 
    4242import com.sun.fortress.nodes.DimDecl; 
     
    134134    private List<StaticError> _errors; 
    135135    private Option<Id> _innerMostLabel; 
     136    private boolean inComponent = false; 
    136137 
    137138    public ExprDisambiguator(NameEnv env, List<StaticError> errors) { 
     
    500501 
    501502    /** 
    502      * When recurring on an AbsTraitDecl, we first need to extend the 
    503      * environment with all the newly bound static parameters that can 
    504      * 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 methods 
    513         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 should 
    531             // not be referred to without explicit receivers in most (all?) cases. But the 
    532             // 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     /** 
    551503     * When recurring on an ObjExpr, we first need to extend the 
    552504     * environment with all the newly bound variables and methods 
     
    668620    } 
    669621 
     622    @Override public Node forComponent(final Component that) { 
     623        inComponent = true; 
     624        return super.forComponent( that ); 
     625    } 
     626 
    670627    /** 
    671628     * When recurring on a TraitDecl, we first need to extend the 
     
    690647        Set<IdOrOpOrAnonymousName> inheritedMethods = inherited.second(); 
    691648 
     649        // Do not extend the environment with "fields", getters, or setters in a trait. 
     650        // References to all three must have an explicit receiver. 
    692651        v = this. 
    693652            extendWithVars(extractStaticExprVars(that.getStaticParams())). 
     
    703662            extendWithFns(gettersAndSetters); 
    704663 
     664        if ( ! inComponent ) 
     665            v.checkForShadowingVars(vars); 
     666 
    705667        return forTraitDeclOnly(that, 
    706668                                v.recurOnListOfModifier(that.getMods()), 
     
    714676    } 
    715677 
    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 
    719680     * 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. 
    721682     * TODO: Handle variables bound in where clauses. 
    722683     * TODO: Insert inherited method names into the environment. 
    723684     */ 
    724     @Override public Node forAbsObjectDecl(final AbsObjectDecl that) { 
     685    @Override public Node forObjectDecl(final ObjectDecl that) { 
    725686        ExprDisambiguator v = this.extendWithVars(extractStaticExprVars(that.getStaticParams())); 
    726687        List<TraitTypeWhere> extendsClause = v.recurOnListOfTraitTypeWhere(that.getExtendsClause()); 
     
    731692        Set<IdOrOpOrAnonymousName> gettersAndSetters = declNames.second(); 
    732693        // 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(extractStaticExprVars 
    743                                 (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 should 
    750             // not be referred to without explicit receivers in most (all?) cases. But the 
    751             // 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 the 
    771      * environment with all the newly bound static parameters that can 
    772      * 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 methods 
    781         Triple<Set<Id>,Set<IdOrOpOrAnonymousName>, Set<IdOrOpOrAnonymousName>> declNames = extractDeclNames(that.getDecls()); 
    782         Set<Id> vars = declNames.first(); 
    783         Set<IdOrOpOrAnonymousName> gettersAndSetters = declNames.second(); 
    784694        Set<IdOrOpOrAnonymousName> fns = declNames.third(); 
    785695 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/SelfParamDisambiguator.java

    r2163 r3096  
    2222import com.sun.fortress.compiler.typechecker.TypeEnv; 
    2323import com.sun.fortress.compiler.typechecker.TypesUtil; 
    24 import com.sun.fortress.nodes.AbsObjectDecl; 
    25 import com.sun.fortress.nodes.AbsTraitDecl; 
     24import com.sun.fortress.nodes.ObjectDecl; 
    2625import com.sun.fortress.nodes.Expr; 
    2726import com.sun.fortress.nodes.Id; 
     
    4443 * At parse-time, methods that take the 'self' parameter may not have a 
    4544 * type for that parameter. However, at disambiguation time, we can give 
    46  * it one.<br>  
     45 * it one.<br> 
    4746 * {@code trait Foo f(self) : () end} 
    4847 * becomes 
     
    5453 */ 
    5554public class SelfParamDisambiguator extends NodeUpdateVisitor { 
    56          
    57         @Override 
    58         public Node forAbsObjectDecl(AbsObjectDecl that) { 
    59         // Add a type to self parameters of methods 
    60                 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         @Override 
    67         public Node forAbsTraitDecl(AbsTraitDecl that) { 
    68         // Add a type to self parameters of methods 
    69                 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  
    7555        @Override 
    7656        public Node forObjectDecl(ObjectDecl that) { 
     
    9070                return super.forTraitDecl(that_new); 
    9171        } 
    92          
    93          
    94          
     72 
     73 
     74 
    9575    @Override 
    9676        public Node forObjectExpr(ObjectExpr that) { 
     
    10383        /** 
    10484     * Replaces Parameters whose name is 'self' with a parameter with 
    105      * the explicit type given.  
    106      *  
     85     * the explicit type given. 
     86     * 
    10787     * @param that 
    10888     * @param self_type 
    10989     */ 
    11090    private Node replaceSelfParamsWithType(Node that, final Type self_type) { 
    111          
     91 
    11292        NodeUpdateVisitor replacer = new NodeUpdateVisitor() { 
    11393                        int traitNestingDepth = 0; 
     
    123103                                new_type = type_result; 
    124104 
    125                         return new NormalParam(that.getSpan(),  
     105                        return new NormalParam(that.getSpan(), 
    126106                                       that.getMods(), 
    127107                                       that.getName(), 
     
    129109                                       that.getDefaultExpr()); 
    130110                        } 
    131                  
     111 
    132112                        // end recurrance here 
    133                         @Override public Node forObjectDecl(ObjectDecl that) {  
     113                        @Override public Node forObjectDecl(ObjectDecl that) { 
    134114                                return (++traitNestingDepth) > 1 ? that : super.forObjectDecl(that); 
    135115                        } 
    136                         @Override public Node forTraitDecl(TraitDecl that) {  
     116                        @Override public Node forTraitDecl(TraitDecl that) { 
    137117                                return (++traitNestingDepth) > 1 ? that : super.forTraitDecl(that); 
    138118                        } 
    139                         @Override public Node forObjectExpr(ObjectExpr that) {  
     119                        @Override public Node forObjectExpr(ObjectExpr that) { 
    140120                                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); 
    147121                        } 
    148122        }; 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/TypeDisambiguator.java

    r3095 r3096  
    3030import com.sun.fortress.exceptions.StaticError; 
    3131import com.sun.fortress.nodes.APIName; 
    32 import com.sun.fortress.nodes.AbsObjectDecl; 
    33 import com.sun.fortress.nodes.AbsTraitDecl; 
     32import com.sun.fortress.nodes.ObjectDecl; 
    3433import com.sun.fortress.nodes.AnyType; 
    3534import com.sun.fortress.nodes.ArrowType; 
     
    132131 
    133132    /** 
    134      * When recurring on an AbsTraitDecl, we first need to extend the 
    135      * 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     /** 
    152133     * When recurring on a TraitDecl, we first need to extend the 
    153134     * environment with all the newly bound static parameters. 
     
    164145                v.recurOnListOfBaseType(that.getExcludes()), 
    165146                v.recurOnOptionOfListOfBaseType(that.getComprises()), 
    166                 v.recurOnListOfDecl(that.getDecls())); 
    167     } 
    168  
    169  
    170     /** 
    171      * When recurring on an AbsObjectDecl, we first need to extend the 
    172      * 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()), 
    186147                v.recurOnListOfDecl(that.getDecls())); 
    187148    } 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/index/ObjectTraitIndex.java

    r2455 r3096  
    2828import com.sun.fortress.nodes.IdOrOpOrAnonymousName; 
    2929import com.sun.fortress.nodes.NodeUpdateVisitor; 
    30 import com.sun.fortress.nodes.ObjectAbsDeclOrDecl; 
     30import com.sun.fortress.nodes.ObjectDecl; 
    3131import com.sun.fortress.nodes.VarDecl; 
    3232 
     
    3838/** Wraps an object declaration. */ 
    3939public class ObjectTraitIndex extends TraitIndex { 
    40      
     40 
    4141    private final Option<Constructor> _constructor; 
    4242    private final Map<Id, Variable> _fields; 
    4343    private final Set<VarDecl> _fieldInitializers; 
    44      
    45     public ObjectTraitIndex(ObjectAbsDeclOrDecl ast, 
     44 
     45    public ObjectTraitIndex(ObjectDecl ast, 
    4646                            Option<Constructor> constructor, 
    4747                            Map<Id, Variable> fields, 
     
    5757        _fieldInitializers = fieldInitializers; 
    5858    } 
    59      
     59 
    6060    public Option<Constructor> constructor() { 
    6161        return _constructor; 
    6262    } 
    63      
     63 
    6464    public Map<Id, Variable> fields() { 
    6565        return Collections.unmodifiableMap(this._fields); 
    6666    } 
    67      
     67 
    6868    public Set<VarDecl> fieldInitializers() { 
    6969        return Collections.unmodifiableSet(_fieldInitializers); 
     
    8181                        new_fields.put(entry.getKey(), var.acceptNodeUpdateVisitor(v)); 
    8282                } 
    83                                                      
     83 
    8484                Set<VarDecl> new_field_ini = new HashSet<VarDecl>(); 
    8585                for( VarDecl vd : this.fieldInitializers() ) { 
    8686                        new_field_ini.add((VarDecl)vd.accept(v)); 
    8787                } 
    88                  
     88 
    8989                Map<Id,Method> new_getters = new HashMap<Id,Method>(); 
    9090                for( Map.Entry<Id, Method> entry : this.getters().entrySet() ) { 
     
    9292                        new_getters.put(entry.getKey(), (Method)var.acceptNodeUpdateVisitor(v)); 
    9393                } 
    94                  
     94 
    9595                Map<Id,Method> new_setters = new HashMap<Id,Method>(); 
    9696                for( Map.Entry<Id, Method> entry : this.setters().entrySet() ) { 
     
    9898                        new_setters.put(entry.getKey(), (Method)var.acceptNodeUpdateVisitor(v)); 
    9999                } 
    100                  
     100 
    101101                Set<Function> new_coercions = new HashSet<Function>(); 
    102102                for( Function vd : this.coercions() ) { 
    103103                        new_coercions.add((Function)vd.acceptNodeUpdateVisitor(v)); 
    104104                } 
    105                  
     105 
    106106                Iterator<Pair<IdOrOpOrAnonymousName, Method>> iter_1 = this.dottedMethods().iterator(); 
    107107                Set<Pair<IdOrOpOrAnonymousName, Method>> new_dm = new HashSet<Pair<IdOrOpOrAnonymousName, Method>>(); 
     
    111111                } 
    112112                Relation<IdOrOpOrAnonymousName, Method> new_dotted = CollectUtil.makeRelation(new_dm); 
    113                  
     113 
    114114                Iterator<Pair<IdOrOpOrAnonymousName, FunctionalMethod>> iter_2 = this.functionalMethods().iterator(); 
    115115                Set<Pair<IdOrOpOrAnonymousName, FunctionalMethod>> new_fm = new HashSet<Pair<IdOrOpOrAnonymousName, FunctionalMethod>>(); 
     
    119119                } 
    120120                Relation<IdOrOpOrAnonymousName, FunctionalMethod> new_functional = CollectUtil.makeRelation(new_fm); 
    121                  
    122                 return new ObjectTraitIndex((ObjectAbsDeclOrDecl)this.ast().accept(v), 
     121 
     122                return new ObjectTraitIndex((ObjectDecl)this.ast().accept(v), 
    123123                                                    new_constr, 
    124124                                                    new_fields, 
     
    130130                                                    new_functional); 
    131131        } 
    132      
     132 
    133133} 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/index/ProperTraitIndex.java

    r2455 r3096  
    2727import com.sun.fortress.nodes.IdOrOpOrAnonymousName; 
    2828import com.sun.fortress.nodes.NodeUpdateVisitor; 
    29 import com.sun.fortress.nodes.TraitAbsDeclOrDecl; 
     29import com.sun.fortress.nodes.TraitDecl; 
    3030import com.sun.fortress.nodes.Type; 
    3131import com.sun.fortress.useful.NI; 
     
    3838public class ProperTraitIndex extends TraitIndex { 
    3939 
    40         public ProperTraitIndex(TraitAbsDeclOrDecl ast, 
     40        public ProperTraitIndex(TraitDecl ast, 
    4141                        Map<Id, Method> getters, 
    4242                        Map<Id, Method> setters, 
     
    9393                Relation<IdOrOpOrAnonymousName, FunctionalMethod> new_functional = CollectUtil.makeRelation(new_fm); 
    9494 
    95                 return new ProperTraitIndex((TraitAbsDeclOrDecl)this.ast().accept(v), 
     95                return new ProperTraitIndex((TraitDecl)this.ast().accept(v), 
    9696                                new_getters, 
    9797                                new_setters, 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/index/TraitIndex.java

    r2909 r3096  
    2525import edu.rice.cs.plt.tuple.Pair; 
    2626import edu.rice.cs.plt.iter.IterUtil; 
    27 import com.sun.fortress.nodes.TraitObjectAbsDeclOrDecl; 
     27import com.sun.fortress.nodes.TraitObjectDecl; 
    2828import com.sun.fortress.nodes.TraitTypeWhere; 
    2929import com.sun.fortress.nodes.StaticParam; 
     
    3838 */ 
    3939public abstract class TraitIndex extends TypeConsIndex { 
    40      
    41     private final TraitObjectAbsDeclOrDecl _ast; 
     40 
     41    private final TraitObjectDecl _ast; 
    4242    private final Map<Id, Method> _getters; 
    4343    private final Map<Id, Method> _setters; 
     
    4545    private final Relation<IdOrOpOrAnonymousName, Method> _dottedMethods; 
    4646    private final Relation<IdOrOpOrAnonymousName, FunctionalMethod> _functionalMethods; 
    47      
    48     public TraitIndex(TraitObjectAbsDeclOrDecl ast, 
     47 
     48    public TraitIndex(TraitObjectDecl ast, 
    4949                      Map<Id, Method> getters, 
    5050                      Map<Id, Method> setters, 
     
    5959        _functionalMethods = functionalMethods; 
    6060    } 
    61      
    62     public TraitObjectAbsDeclOrDecl ast() { return _ast; } 
    63      
     61 
     62    public TraitObjectDecl ast() { return _ast; } 
     63 
    6464    public List<StaticParam> staticParameters() { return _ast.getStaticParams(); } 
    65      
     65 
    6666    public List<Id> hiddenParameters() { return Collections.emptyList(); } 
    67      
     67 
    6868    /** 
    6969     * Return all subtype relationships described by parameter bounds and where clauses. 
     
    7272     */ 
    7373    public Iterable<Pair<Type, Type>> typeConstraints() { return IterUtil.empty(); } 
    74      
     74 
    7575    public List<TraitTypeWhere> extendsTypes() { 
    7676        return _ast.getExtendsClause(); 
    7777    } 
    78      
     78 
    7979    public Map<Id, Method> getters() { 
    8080        return _getters; 
    8181    } 
    82      
     82 
    8383    public Map<Id, Method> setters() { 
    8484        return _setters; 
    8585    } 
    86      
     86 
    8787    public Set<Function> coercions() { 
    8888        return _coercions; 
    8989    } 
    90      
     90 
    9191    public Relation<IdOrOpOrAnonymousName, Method> dottedMethods() { 
    9292        return _dottedMethods; 
    9393    } 
    94      
     94 
    9595    public Relation<IdOrOpOrAnonymousName, FunctionalMethod> functionalMethods() { 
    9696        return _functionalMethods; 
    9797    } 
    98      
     98 
    9999} 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/ObjectTypeEnv.java

    r2466 r3096  
    2929import com.sun.fortress.nodes.IdOrOpOrAnonymousName; 
    3030import com.sun.fortress.nodes.Node; 
    31 import com.sun.fortress.nodes.ObjectAbsDeclOrDecl; 
     31import com.sun.fortress.nodes.ObjectDecl; 
    3232import com.sun.fortress.nodes.StaticParam; 
    3333import com.sun.fortress.nodes.Type; 
     
    6161        // Api-less name used for look-up only. 
    6262        Id no_api_var = removeApi(_var); 
    63          
     63 
    6464        if (!entries.containsKey(no_api_var)) { return parent.binding(var); } 
    6565        TypeConsIndex typeCons = entries.get(no_api_var); 
    66          
     66 
    6767        // TODO: This seems wrong... If they were looking for an Object, but found some 
    6868        // other kind of type, isn't there some way we could return a better error message? 
    6969        if (!(typeCons instanceof ObjectTraitIndex)) { return parent.binding(var); } 
    7070        ObjectTraitIndex objIndex = (ObjectTraitIndex)typeCons; 
    71          
     71 
    7272        Type type; 
    73         ObjectAbsDeclOrDecl decl = (ObjectAbsDeclOrDecl)objIndex.ast(); 
     73        ObjectDecl decl = (ObjectDecl)objIndex.ast(); 
    7474        if (decl.getStaticParams().isEmpty()) { 
    7575            if (decl.getParams().isNone()) { 
     
    8989                // Some static params, some normal params 
    9090                // TODO: handle type variables bound in where clause 
    91                 type =  
     91                type = 
    9292                        new _RewriteGenericArrowType(decl.getSpan(), decl.getStaticParams(), 
    9393                                                 domainFromParams(decl.getParams().unwrap()), 
     
    9797        } 
    9898 
    99         return Option.some(new BindingLookup(var, type, decl.getMods()));    
     99        return Option.some(new BindingLookup(var, type, decl.getMods())); 
    100100    } 
    101101 
     
    120120        // Api-less name used for look-up only. 
    121121        Id no_api_var = removeApi(_var); 
    122          
     122 
    123123        if (!entries.containsKey(no_api_var)) { return parent.declarationSite(var); } 
    124124        TypeConsIndex typeCons = entries.get(no_api_var); 
    125          
     125 
    126126        // TODO: This seems wrong... If they were looking for an Object, but found some 
    127127        // other kind of type, isn't there some way we could return a better error message? 
    128128        if (!(typeCons instanceof ObjectTraitIndex)) { return parent.declarationSite(var); } 
    129129        ObjectTraitIndex objIndex = (ObjectTraitIndex)typeCons; 
    130          
     130 
    131131        return Option.<Node>some(objIndex.ast()); 
    132132        } 
     
    134134        @Override 
    135135        public TypeEnv replaceAllIVars(Map<_InferenceVarType, Type> ivars) { 
    136                  
     136 
    137137                Map<Id, TypeConsIndex> new_entries = new HashMap<Id, TypeConsIndex>(); 
    138138                InferenceVarReplacer rep = new InferenceVarReplacer(ivars); 
    139                  
     139 
    140140                for( Map.Entry<Id, TypeConsIndex> entry : entries.entrySet() ) { 
    141141                        TypeConsIndex tc = entry.getValue(); 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/SubtypeCheckerJUTest.java

    r3093 r3096  
    392392            extendsClause.add(new TraitTypeWhere(span, supT, Option.<WhereClause>none())); 
    393393        } 
    394         TraitAbsDeclOrDecl ast; 
     394        TraitDecl ast; 
    395395        List<StaticParam> sparams = Collections.<StaticParam>emptyList(); 
    396396        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()); 
    400400        } 
    401401        else { 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeAnalyzerJUTest.java

    r3093 r3096  
    465465            extendsClause.add(new TraitTypeWhere(span, supT, Option.<WhereClause>none())); 
    466466        } 
    467         TraitAbsDeclOrDecl ast; 
     467        TraitDecl ast; 
    468468        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()); 
    473473        } 
    474474        else { 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeCheckerTestCase.java

    r3071 r3096  
    4040import com.sun.fortress.nodes.StaticArg; 
    4141import com.sun.fortress.nodes.StaticParam; 
    42 import com.sun.fortress.nodes.TraitAbsDeclOrDecl; 
    4342import com.sun.fortress.nodes.TraitDecl; 
    4443import com.sun.fortress.nodes.BaseType; 
     
    6059 
    6160    private static Span span = NodeFactory.makeSpan("TypeCheckerTestCase bogus"); 
    62      
     61 
    6362    public static Type parseType(String s) { 
    6463        s = s.trim(); 
     
    110109            extendsClause.add(new TraitTypeWhere(span, supT, Option.<WhereClause>none())); 
    111110        } 
    112         TraitAbsDeclOrDecl 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()); 
    115114        return new ProperTraitIndex(ast, 
    116115                                    Collections.<Id, Method>emptyMap(), 
  • trunk/ProjectFortress/src/com/sun/fortress/interpreter/Driver.java

    r3095 r3096  
    5858import com.sun.fortress.interpreter.glue.WellKnownNames; 
    5959import com.sun.fortress.nodes.APIName; 
    60 import com.sun.fortress.nodes.AbsObjectDecl; 
    61 import com.sun.fortress.nodes.AbsTraitDecl; 
    6260import com.sun.fortress.nodes.AbstractArrowType; 
    6361import com.sun.fortress.nodes.AliasedAPIName; 
     
    7876import com.sun.fortress.nodes.NodeAbstractVisitor_void; 
    7977import com.sun.fortress.nodes.NodeVisitor_void; 
    80 import com.sun.fortress.nodes.ObjectAbsDeclOrDecl; 
    8178import com.sun.fortress.nodes.ObjectDecl; 
    8279import com.sun.fortress.nodes.SyntaxDecl; 
    8380import com.sun.fortress.nodes.SyntaxDef; 
    8481import com.sun.fortress.nodes.TestDecl; 
    85 import com.sun.fortress.nodes.TraitAbsDeclOrDecl; 
    8682import com.sun.fortress.nodes.TraitDecl; 
    8783import com.sun.fortress.nodes_util.NodeFactory; 
  • trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BuildApiEnvironment.java

    r3095 r3096  
    2929import com.sun.fortress.nodes.VarDecl; 
    3030import com.sun.fortress.nodes.FnDecl; 
    31 import com.sun.fortress.nodes.AbsObjectDecl; 
    32 import com.sun.fortress.nodes.AbsTraitDecl; 
     31import com.sun.fortress.nodes.ObjectDecl; 
     32import com.sun.fortress.nodes.TraitDecl; 
    3333import com.sun.fortress.nodes.Id; 
    3434import com.sun.fortress.nodes.IdOrOpOrAnonymousName; 
     
    6262 
    6363    @Override 
    64     public Boolean forAbsObjectDecl(AbsObjectDecl x) { 
     64    public Boolean forObjectDecl(ObjectDecl x) { 
    6565        Boolean change = Boolean.FALSE; 
    66         // super.forAbsObjectDecl(x); 
     66        // super.forObjectDecl(x); 
    6767        if (getPass() == 1) { 
    6868            String fname = NodeUtil.stringName(x.getName()); 
     
    102102 
    103103    @Override 
    104     public Boolean forAbsTraitDecl(AbsTraitDecl x) { 
     104    public Boolean forTraitDecl(TraitDecl x) { 
    105105        Boolean change = Boolean.FALSE; 
    106         // super.forAbsTraitDecl(x); 
     106        // super.forTraitDecl(x); 
    107107        if (getPass() == 1) { 
    108108            String fname = NodeUtil.stringName(x.getName()); 
  • trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BuildEnvironments.java

    r3095 r3096  
    522522    } 
    523523 
    524     private void makeGenericSingleton(ObjectAbsDeclOrDecl x, Environment e, Id name, 
     524    private void makeGenericSingleton(ObjectDecl x, Environment e, Id name, 
    525525            String fname, FTraitOrObjectOrGeneric ft) { 
    526526        GenericConstructor gen = new GenericConstructor(e, x, name); 
     
    800800     * (non-Javadoc) 
    801801     * 
    802      * @see com.sun.fortress.interpreter.nodes.NodeVisitor#forTraitDecl(com.sun.fortress.interpreter.nodes.AbsTraitDecl) 
    803      */ 
    804     @Override 
    805     public Boolean forAbsTraitDecl(AbsTraitDecl x) { 
    806         return bug("BuildEnvironments.forAbsTraitDecl should not be called"); 
    807     } 
    808  
    809     /* 
    810      * (non-Javadoc) 
    811      * 
    812802     * @see com.sun.fortress.interpreter.nodes.NodeVisitor#forTraitDef(com.sun.fortress.interpreter.nodes.TraitDecl) 
    813803     */ 
     
    882872     * @param interior 
    883873     */ 
    884     public void finishTrait(TraitAbsDeclOrDecl x, FTypeTrait ftt, Environment interior) { 
     874    public void finishTrait(TraitDecl x, FTypeTrait ftt, Environment interior) { 
    885875        List<BaseType> extends_ = NodeUtil.getTypes(x.getExtendsClause()); 
    886876        // TODO What if I don't 
     
    991981    } 
    992982 
    993     public void finishObjectTrait(ObjectAbsDeclOrDecl x, FTypeObject ftt) { 
     983    public void finishObjectTrait(ObjectDecl x, FTypeObject ftt) { 
    994984        List<BaseType> extends_ = NodeUtil.getTypes(x.getExtendsClause()); 
    995985        finishObjectTrait(extends_, null, x.getWhere(), ftt, containing, x); 
     
    10911081    } 
    10921082 
    1093     /* 
    1094      * (non-Javadoc) 
    1095      * 
    1096      * @see com.sun.fortress.interpreter.nodes.NodeVisitor#forAbsObjectDecl(com.sun.fortress.interpreter.nodes.AbsObjectDecl) 
    1097      */ 
    1098     @Override 
    1099     public Boolean forAbsObjectDecl(AbsObjectDecl x) { 
    1100         return bug("BuildEnvironments.forAbsObjectDecl should not be called"); 
    1101  
    1102     } 
    1103  
    11041083    public Environment getBindingEnv() { 
    11051084        return bindInto; 
  • trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BuildTopLevelEnvironments.java

    r3093 r3096  
    3131import com.sun.fortress.nodes.APIName; 
    3232import com.sun.fortress.nodes.Decl; 
    33 import com.sun.fortress.nodes.AbsTraitDecl; 
    3433import com.sun.fortress.nodes.AliasedAPIName; 
    3534import com.sun.fortress.nodes.Api; 
     
    247246 
    248247        /* (non-Javadoc) 
    249          * @see com.sun.fortress.interpreter.nodes.NodeVisitor#forAbsTraitDecl(com.sun.fortress.interpreter.nodes.AbsTraitDecl) 
    250          */ 
    251         @Override 
    252         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 level 
    259                     Environment interior = ftt.getWithin(); 
    260                     ftt.getMembers(); 
    261             } 
    262             return null; 
    263         } 
    264  
    265         /* (non-Javadoc) 
    266248         * @see com.sun.fortress.interpreter.nodes.NodeVisitor#forTraitDecl(com.sun.fortress.interpreter.nodes.TraitDecl) 
    267249         */ 
  • trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/EvalVarsEnvironment.java

    r3095 r3096  
    1818package com.sun.fortress.interpreter.evaluator; 
    1919 
    20 import com.sun.fortress.nodes.AbsObjectDecl; 
    21 import com.sun.fortress.nodes.AbsTraitDecl; 
     20import com.sun.fortress.nodes.ObjectDecl; 
    2221import com.sun.fortress.nodes.Api; 
    2322import com.sun.fortress.nodes.Component; 
     
    104103 
    105104    /* (non-Javadoc) 
    106      * @see com.sun.fortress.interpreter.evaluator.BuildEnvironments#forObjectDecl(com.sun.fortress.interpreter.nodes.AbsObjectDecl) 
    107      */ 
    108     @Override 
    109     public Boolean forAbsObjectDecl(AbsObjectDecl x) { 
    110         return null; 
    111  
    112     } 
    113  
    114     /* (non-Javadoc) 
    115105     * @see com.sun.fortress.interpreter.evaluator.BuildEnvironments#forObjectDef(com.sun.fortress.interpreter.nodes.ObjectDecl) 
    116106     */ 
    117107    @Override 
    118108    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     @Override 
    127     public Boolean forAbsTraitDecl(AbsTraitDecl x) { 
    128109        return null; 
    129110 
  • trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/ScoutVisitor.java

    r3095 r3096  
    2020 
    2121import com.sun.fortress.interpreter.evaluator.values.Overload; 
    22 import com.sun.fortress.nodes.AbsObjectDecl; 
    23 import com.sun.fortress.nodes.AbsTraitDecl; 
     22import com.sun.fortress.nodes.ObjectDecl; 
    2423import com.sun.fortress.nodes.ArrayType; 
    2524import com.sun.fortress.nodes.ArrowType; 
     
    3029import com.sun.fortress.nodes.MatrixType; 
    3130import com.sun.fortress.nodes.NodeAbstractVisitor_void; 
    32 import com.sun.fortress.nodes.ObjectAbsDeclOrDecl; 
    3331import com.sun.fortress.nodes.ObjectDecl; 
    34 import com.sun.fortress.nodes.TraitAbsDeclOrDecl; 
     32import com.sun.fortress.nodes.ObjectDecl; 
    3533import com.sun.fortress.nodes.TraitDecl; 
    36 import com.sun.fortress.nodes.TraitObjectAbsDeclOrDecl; 
     34import com.sun.fortress.nodes.TraitObjectDecl; 
    3735import com.sun.fortress.nodes.BaseType; 
    3836import com.sun.fortress.nodes.TraitTypeWhere; 
     
    4442 
    4543public class ScoutVisitor extends NodeAbstractVisitor_void { 
    46     /* (non-Javadoc) 
    47      * @see com.sun.fortress.nodes.NodeAbstractVisitor_void#forAbsObjectDecl(com.sun.fortress.nodes.AbsObjectDecl) 
    48      */ 
    49     @Override 
    50     public void forAbsObjectDecl(AbsObjectDecl that) { 
    51         // TODO Auto-generated method stub 
    52         super.forAbsObjectDecl(that); 
    53     } 
    54  
    55     /* (non-Javadoc) 
    56      * @see com.sun.fortress.nodes.NodeAbstractVisitor_void#forAbsTraitDecl(com.sun.fortress.nodes.AbsTraitDecl) 
    57      */ 
    58     @Override 
    59     public void forAbsTraitDecl(AbsTraitDecl that) { 
    60         // TODO Auto-generated method stub 
    61         super.forAbsTraitDecl(that); 
    62     } 
    63  
    6444    /* (non-Javadoc) 
    6545     * @see com.sun.fortress.nodes.NodeAbstractVisitor_void#forArrayType(com.sun.fortress.nodes.ArrayType) 
     
    126106 
    127107    /* (non-Javadoc) 
    128      * @see com.sun.fortress.nodes.NodeAbstractVisitor_void#forObjectAbsDeclOrDecl(com.sun.fortress.nodes.ObjectAbsDeclOrDecl) 
    129      */ 
    130     @Override 
    131     public void forObjectAbsDeclOrDecl(ObjectAbsDeclOrDecl that) { 
    132         // TODO Auto-generated method stub 
    133         super.forObjectAbsDeclOrDecl(that); 
    134     } 
    135  
    136     /* (non-Javadoc) 
    137108     * @see com.sun.fortress.nodes.NodeAbstractVisitor_void#forObjectDecl(com.sun.fortress.nodes.ObjectDecl) 
    138109     */ 
     
    141112        // TODO Auto-generated method stub 
    142113        super.forObjectDecl(that); 
    143     } 
    144  
    145     /* (non-Javadoc) 
    146      * @see com.sun.fortress.nodes.NodeAbstractVisitor_void#forTraitAbsDeclOrDecl(com.sun.fortress.nodes.TraitAbsDeclOrDecl) 
    147      */ 
    148     @Override 
    149     public void forTraitAbsDeclOrDecl(TraitAbsDeclOrDecl that) { 
    150         // TODO Auto-generated method stub 
    151         super.forTraitAbsDeclOrDecl(that); 
    152114    } 
    153115 
     
    162124 
    163125    /* (non-Javadoc) 
    164      * @see com.sun.fortress.nodes.NodeAbstractVisitor_void#forTraitObjectAbsDeclOrDecl(com.sun.fortress.nodes.TraitObjectAbsDeclOrDecl) 
     126     * @see com.sun.fortress.nodes.NodeAbstractVisitor_void#forTraitObjectDecl(com.sun.fortress.nodes.TraitObjectDecl) 
    165127     */ 
    166128    @Override 
    167     public void forTraitObjectAbsDeclOrDecl(TraitObjectAbsDeclOrDecl that) { 
     129    public void forTraitObjectDecl(TraitObjectDecl that) { 
    168130        // TODO Auto-generated method stub 
    169         super.forTraitObjectAbsDeclOrDecl(that); 
     131        super.forTraitObjectDecl(that); 
    170132    } 
    171133 
  • trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/types/FTraitOrObjectOrGeneric.java

    r3095 r3096  
    3333import com.sun.fortress.nodes.Modifier; 
    3434import com.sun.fortress.nodes.ModifierValue; 
    35 import com.sun.fortress.nodes.TraitObjectAbsDeclOrDecl; 
     35import com.sun.fortress.nodes.TraitObjectDecl; 
    3636import com.sun.fortress.nodes_util.NodeComparator; 
    3737import com.sun.fortress.nodes_util.NodeUtil; 
     
    4646        this.decl = def; 
    4747        boolean isValueType = false; 
    48         if (def instanceof TraitObjectAbsDeclOrDecl) 
    49             for (Modifier mod : ((TraitObjectAbsDeclOrDecl) def).getMods()) 
     48        if (def instanceof TraitObjectDecl) 
     49            for (Modifier mod : ((TraitObjectDecl) def).getMods()) 
    5050                if (mod instanceof ModifierValue) { 
    5151                    isValueType = true; 
  • trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/types/FTypeGeneric.java

    r3093 r3096  
    4747import com.sun.fortress.nodes.StaticArg; 
    4848import com.sun.fortress.nodes.StaticParam; 
    49 import com.sun.fortress.nodes.TraitAbsDeclOrDecl; 
    50 import com.sun.fortress.nodes.TraitObjectAbsDeclOrDecl; 
     49import com.sun.fortress.nodes.TraitDecl; 
     50import com.sun.fortress.nodes.TraitObjectDecl; 
    5151import com.sun.fortress.nodes.TraitType; 
    5252import com.sun.fortress.nodes.Type; 
     
    105105    } 
    106106 
    107     public FTypeGeneric(FTypeGeneric orig, TraitObjectAbsDeclOrDecl new_def) { 
     107    public FTypeGeneric(FTypeGeneric orig, TraitObjectDecl new_def) { 
    108108        super(orig.getName(), orig.getWithin(), orig.getDecl()); 
    109109        genericAt = orig.getDef(); 
     
    257257                //OprInstantiater oi = new OprInstantiater(substitutions); 
    258258 
    259                 TraitObjectAbsDeclOrDecl new_def = 
    260                     (TraitObjectAbsDeclOrDecl)oi.visit((TraitObjectAbsDeclOrDecl)FTypeGeneric.this.getDef()); 
     259                TraitObjectDecl new_def = 
     260                    (TraitObjectDecl)oi.visit((TraitObjectDecl)FTypeGeneric.this.getDef()); 
    261261 
    262262                FTypeGeneric replacement = 
     
    280280        FTraitOrObject rval; 
    281281 
    282         if (gen.def instanceof TraitAbsDeclOrDecl) { 
    283             TraitAbsDeclOrDecl td = (TraitAbsDeclOrDecl) gen.def; 
     282        if (gen.def instanceof TraitDecl) { 
     283            TraitDecl td = (TraitDecl) gen.def; 
    284284            FTypeTraitInstance ftt = new FTypeTraitInstance(td.getName().getText(), 
    285285                                                    clenv, gen, bind_args, key_args, gen.members); 
  • trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/values/GenericSingleton.java

    r1800 r3096  
    2525import com.sun.fortress.interpreter.evaluator.types.FType; 
    2626import com.sun.fortress.nodes.IdOrOpOrAnonymousName; 
    27 import com.sun.fortress.nodes.ObjectAbsDeclOrDecl; 
     27import com.sun.fortress.nodes.ObjectDecl; 
    2828import com.sun.fortress.nodes.StaticArg; 
    2929import com.sun.fortress.nodes.StaticParam; 
     
    3434public class GenericSingleton extends FValue implements Factory1P<List<FType>, FObject, HasAt> { 
    3535 
    36     ObjectAbsDeclOrDecl odecl; 
     36    ObjectDecl odecl; 
    3737    FType t; 
    3838    GenericConstructor genericConstructor; 
    3939 
    40     public GenericSingleton(ObjectAbsDeclOrDecl odecl, FType t, GenericConstructor gc) { 
     40    public GenericSingleton(ObjectDecl odecl, FType t, GenericConstructor gc) { 
    4141        super(); 
    4242        this.odecl = odecl; 
  • trunk/ProjectFortress/src/com/sun/fortress/interpreter/rewrite/DesugarerVisitor.java

    r3095 r3096  
    4646import com.sun.fortress.nodes_util.Span; 
    4747import com.sun.fortress.nodes.APIName; 
    48 import com.sun.fortress.nodes.AbsTraitDecl; 
    4948import com.sun.fortress.nodes.AbstractNode; 
    5049import com.sun.fortress.nodes.AbstractObjectExpr; 
     
    9998import com.sun.fortress.nodes.TestDecl; 
    10099import com.sun.fortress.nodes.TightJuxt; 
    101 import com.sun.fortress.nodes.TraitAbsDeclOrDecl; 
    102100import com.sun.fortress.nodes.BaseType; 
    103101import com.sun.fortress.nodes.TraitDecl; 
    104 import com.sun.fortress.nodes.TraitObjectAbsDeclOrDecl; 
     102import com.sun.fortress.nodes.TraitObjectDecl; 
    105103import com.sun.fortress.nodes.TraitType; 
    106104import com.sun.fortress.nodes.TupleExpr; 
     
    199197     */ 
    200198    private class Trait extends Local { 
    201         TraitAbsDeclOrDecl defOrDecl; 
     199        TraitDecl defOrDecl; 
    202200        Map<String, Thing> env; 
    203         Trait(TraitAbsDeclOrDecl dod, Map<String, Thing> env) { defOrDecl = dod; this.env = env; } 
     201        Trait(TraitDecl dod, Map<String, Thing> env) { defOrDecl = dod; this.env = env; } 
    204202        public String toString() { return "Trait="+defOrDecl; } 
    205203 
     
    10321030 
    10331031    @Override 
    1034     public Node forAbsTraitDecl(AbsTraitDecl td) { 
    1035         List<Decl> defs = td.getDecls(); 
    1036         List<StaticParam> tparams = td.getStaticParams(); 
    1037         // TODO wip 
    1038         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     @Override 
    10531032    public Node forTraitDecl(TraitDecl td) { 
    10541033        List<Decl> defs = td.getDecls(); 
     
    12611240     * @param td 
    12621241     */ 
    1263     private void accumulateMembersFromExtends(TraitAbsDeclOrDecl td) { 
     1242    private void accumulateMembersFromExtends(TraitDecl td) { 
    12641243        accumulateMembersFromExtends(NodeUtil.getTypes(td.getExtendsClause()), 
    12651244                rewrites); 
     
    13011280    private void defsToLocals(List<Decl> defs) { 
    13021281        for (Decl d : defs) { 
    1303             if (d instanceof TraitAbsDeclOrDecl) { 
     1282            if (d instanceof TraitDecl) { 
    13041283                String s = d.stringName(); 
    1305                 TraitAbsDeclOrDecl dod = (TraitAbsDeclOrDecl) d; 
     1284                TraitDecl dod = (TraitDecl) d; 
    13061285                type_rewrites_put(s, new Trait(dod, rewrites)); 
    13071286            } else if (d instanceof ObjectDecl) { 
     
    13351314    private void functionalMethodsOfDefsToLocals(List<Decl> defs) { 
    13361315        for (Decl d : defs) { 
    1337             if (d instanceof TraitObjectAbsDeclOrDecl) { 
    1338                 TraitObjectAbsDeclOrDecl dod = (TraitObjectAbsDeclOrDecl) d; 
     1316            if (d instanceof TraitObjectDecl) { 
     1317                TraitObjectDecl dod = (TraitObjectDecl) d; 
    13391318                List <Decl> tdecls = dod.getDecls(); 
    13401319                handlePossibleFM(tdecls); 
     
    15591538                    if (th instanceof Trait) { 
    15601539                        Trait tr = (Trait) th; 
    1561                         TraitAbsDeclOrDecl tdod = tr.defOrDecl; 
     1540                        TraitDecl tdod = tr.defOrDecl; 
    15621541                        if (!(visited.contains(tdod))) { 
    15631542                            visited.add(tdod); 
  • trunk/ProjectFortress/src/com/sun/fortress/interpreter/rewrite/OprInstantiaterVisitor.java

    r3092 r3096  
    3131import com.sun.fortress.nodes.StaticArg; 
    3232import com.sun.fortress.nodes.StaticParam; 
    33 import com.sun.fortress.nodes.TraitObjectAbsDeclOrDecl; 
     33import com.sun.fortress.nodes.TraitObjectDecl; 
    3434import com.sun.fortress.nodes.Type; 
    3535import com.sun.fortress.nodes_util.ExprFactory; 
     
    4444    Map<String, String> subst; 
    4545 
    46     public TraitObjectAbsDeclOrDecl visit(TraitObjectAbsDeclOrDecl toadod) { 
    47         return (TraitObjectAbsDeclOrDecl) toadod.accept(this); 
     46    public TraitObjectDecl visit(TraitObjectDecl toadod) { 
     47        return (TraitObjectDecl) toadod.accept(this); 
    4848    } 
    49      
     49 
    5050    public OprInstantiaterVisitor(Map<String, String> subst) { 
    5151        this.subst = subst; 
     
    6868        final Option<Type> otype = op.getExprType(); 
    6969        final Type type = otype.isNone() ? null : otype.unwrap(); 
    70          
     70 
    7171        OpName n_originalName = (OpName) recur(originalName); 
    7272        List<OpName> n_ops = recurOnListOfOpName(ops); 
    7373        List<StaticArg> n_args = recurOnListOfStaticArg(args); 
    7474        Type n_type = type == null ? (Type) null : (Type) recur(type); 
    75          
     75 
    7676        if (args != n_args || originalName != n_originalName || ops != n_ops || type != n_type) { 
    7777            return new OpRef(op.getSpan(), op.isParenthesized(), Option.wrap(n_type), n_args, Environment.TOP_LEVEL, 
    7878                    n_originalName, n_ops); 
    7979        } 
    80          
     80 
    8181        return op; 
    8282    } 
     
    8989        } else return opp; 
    9090    } 
    91      
    92      
     91 
     92 
    9393    @Override 
    9494    public List<StaticParam> recurOnListOfStaticParam(List<StaticParam> that) { 
  • trunk/ProjectFortress/src/com/sun/fortress/nodes_util/ApiMaker.java

    r3095 r3096  
    119119            List<Decl> absDecls = declsToDecls(that.getDecls()); 
    120120            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)); 
    130130        } else return Option.<Node>none(); 
    131131    } 
     
    136136            List<Decl> absDecls = declsToDecls(that.getDecls()); 
    137137            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)); 
    148148        } else return Option.<Node>none(); 
    149149    } 
  • trunk/ProjectFortress/src/com/sun/fortress/nodes_util/ErrorMsgMaker.java

    r3095 r3096  
    6262    } 
    6363 
    64     public String forTraitObjectAbsDeclOrDecl(TraitObjectAbsDeclOrDecl node) { 
     64    public String forTraitObjectDecl(TraitObjectDecl node) { 
    6565        return node.getClass().getSimpleName() + " " + node.getName() + " at " + node.getSpan().begin.at(); 
    6666    } 
  • trunk/ProjectFortress/src/com/sun/fortress/nodes_util/NodeUtil.java

    r3095 r3096  
    384384        } 
    385385            @Override 
    386         public String forObjectAbsDeclOrDecl(ObjectAbsDeclOrDecl node) { 
     386        public String forObjectDecl(ObjectDecl node) { 
    387387            return node.getName().getText(); 
    388388        } 
     
    392392        } 
    393393            @Override 
    394         public String forTraitAbsDeclOrDecl(TraitAbsDeclOrDecl node) { 
     394        public String forTraitDecl(TraitDecl node) { 
    395395            return node.getName().getText(); 
    396396        } 
     
    451451                return new IterableOnceForLValueList(d.getLhs()); 
    452452            } 
    453             public IterableOnce<String> forObjectAbsDeclOrDecl(ObjectAbsDeclOrDecl d) { 
     453            public IterableOnce<String> forObjectDecl(ObjectDecl d) { 
    454454                return new UnitIterable<String>(d.getName().getText()); 
    455455            } 
     
    470470                return new UnitIterable<String>(d.getName().getText()); 
    471471            } 
    472             public IterableOnce<String> forTraitAbsDeclOrDecl(TraitAbsDeclOrDecl d) { 
     472            public IterableOnce<String> forTraitDecl(TraitDecl d) { 
    473473                return new UnitIterable<String>(d.getName().getText()); 
    474474            } 
  • trunk/ProjectFortress/src/com/sun/fortress/parser/TraitObject.rats

    r3093 r3096  
    309309     ((s trait)? s Id)? 
    310310 */ 
    311 AbsTraitDecl AbsTraitDecl = 
     311TraitDecl AbsTraitDecl = 
    312312     a1:Mods? a2:TraitHeaderFront a3:AbsTraitClauses 
    313313     a4:(w AbsGoInATrait)? w end a5:((s trait)? s Id)? 
     
    318318       if (a1 == null) a1 = FortressUtil.emptyModifiers(); 
    319319       if (a4 == null) a4 = Collections.<Decl>emptyList(); 
    320        yyValue = new AbsTraitDecl 
     320       yyValue = new TraitDecl 
    321321           (span, a1, a2.getName(), 
    322322            a2.getStaticParams(), a2.getExtendsClause(), a3.getWhere(), 
     
    421421                     ((s object)? s Id)? 
    422422 */ 
    423 AbsObjectDecl AbsObjectDecl = 
     423ObjectDecl AbsObjectDecl = 
    424424     a1:Mods? a2:ObjectHeader a3:(w AbsGoInAnObject)? w end 
    425425     a4:((s object)? s Id)? 
     
    434434       Option<List<Param>> params = a2.getParams(); 
    435435       FortressUtil.checkNoWrapped(params); 
    436        yyValue = new AbsObjectDecl 
     436       yyValue = new ObjectDecl 
    437437           (span, a1, a2.getName(), 
    438438            a2.getStaticParams(), a2.getExtendsClause(), fhc.getWhereClause(), 
  • trunk/ProjectFortress/src/com/sun/fortress/parser_util/SyntaxChecker.java

    r3095 r3096  
    8484    } 
    8585 
    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  
    10086    public void forTraitDecl(TraitDecl that) { 
    10187        inTrait = true; 
    10288        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            } 
    110106        } 
    111107        super.forTraitDecl( that ); 
    112108        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; 
    127109    } 
    128110 
     
    130112        inObject = true; 
    131113        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            } 
    139131        } 
    140132        super.forObjectDecl( that ); 
  • trunk/ProjectFortress/src/com/sun/fortress/tools/FortressAstToConcrete.java

    r3095 r3096  
    4949    private boolean _unqualified; 
    5050    private boolean _unmangle; 
     51    private boolean inComponent = false; 
    5152    private int width = 50; 
    5253    private Set<String> locals = new HashSet<String>(); 
     
    279280                                             List<String> decls_result, 
    280281                                             List<String> objectExprs) { 
     282        inComponent = true; 
    281283        // note objectExprs parameter is a temporary hack. 
    282284        StringBuilder s = new StringBuilder(); 
     
    302304                                       List<String> imports_result, 
    303305                                       List<String> decls_result) { 
     306        inComponent = false; 
    304307        //increaseIndent(); 
    305308        StringBuilder s = new StringBuilder(); 
     
    374377            s.append( " as " ).append(alias_result.unwrap()); 
    375378        } 
    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             else 
    407                 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  
    417379        return s.toString(); 
    418380    } 
     
    444406    } 
    445407 
    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        } 
    459425    } 
    460426 
     
    481447            s.append(" ").append( where_result.unwrap() ); 
    482448        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        } 
    484461        if ( ! decls_result.isEmpty() ) { 
    485462            s.append( "\n" ); 
     
    493470    } 
    494471 
    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        } 
    552491    } 
    553492