Changeset 2022

Show
Ignore:
Timestamp:
06/19/08 18:16:57 (5 months ago)
Author:
sukyoungryu
Message:

[astgen] Deleted a node: FieldRefForSure?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ProjectFortress/astgen/Fortress.ast

    r2019 r2022  
    11201120                    FieldRef(Id field); 
    11211121                    /** 
    1122                      * A field selection, for sure 
    1123                      * (though its implementation might be a getter/setter) 
    1124                      * Names of "field" must be unqualified. 
    1125                      * 
    1126                      * field reference rewritten by interpreter.evaluator.LHSToLValue 
    1127                      */ 
    1128                     FieldRefForSure(Id field); 
    1129                     /** 
    11301122                     * A rewritten field ref (not a getter/setter) 
    11311123                     * also used to disambiguate lexical references to self/parent 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/DesugaringVisitor.java

    r1895 r2022  
    728728//    } 
    729729// 
    730 //    public Node forFieldRefForSureOnly(FieldRefForSure that, Expr obj_result, Id field_result) { 
    731 //        if (that.getObj() == obj_result && that.getField() == field_result) return that; 
    732 //        else return new FieldRefForSure(that.getSpan(), that.isParenthesized(), obj_result, field_result); 
    733 //    } 
    734 // 
    735730//    public Node for_RewriteFieldRefOnly(_RewriteFieldRef that, Expr obj_result, Name field_result) { 
    736731//        if (that.getObj() == obj_result && that.getField() == field_result) return that; 
     
    19311926//    } 
    19321927// 
    1933 //    public Node forFieldRefForSure(FieldRefForSure that) { 
    1934 //        Expr obj_result = (Expr) that.getObj().accept(this); 
    1935 //        Id field_result = (Id) that.getField().accept(this); 
    1936 //        return forFieldRefForSureOnly(that, obj_result, field_result); 
    1937 //    } 
    1938 // 
    19391928//    public Node for_RewriteFieldRef(_RewriteFieldRef that) { 
    19401929//        Expr obj_result = (Expr) that.getObj().accept(this); 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeChecker.java

    r2019 r2022  
    17251725                        } 
    17261726                        @Override 
    1727                         public Option<? extends IdOrOpOrAnonymousName> forFieldRefForSure( 
    1728                                         FieldRefForSure that) { 
    1729                                 return Option.some(that.getField()); 
    1730                         } 
    1731                         @Override 
    17321727                        public Option<? extends IdOrOpOrAnonymousName> forLValueBind( 
    17331728                                        LValueBind that) { 
     
    22732268                        subtypeChecker, function_result, argument_result, result); 
    22742269    } 
    2275      
     2270 
    22762271    @Override 
    22772272        public TypeCheckerResult for_RewriteObjectRefOnly(_RewriteObjectRef that, 
    22782273                        TypeCheckerResult obj_result, 
    22792274                        List<TypeCheckerResult> staticArgs_result) { 
    2280          
     2275 
    22812276        if( obj_result.type().isNone() ) { 
    22822277                return TypeCheckerResult.compose(that, subtypeChecker, obj_result, 
     
    22932288                if( match ) { 
    22942289                        // make a trait type that is GenericType instantiated 
    2295                         Type t = NodeFactory.makeTraitType(uninstantiated_t.getSpan(),  
     2290                        Type t = NodeFactory.makeTraitType(uninstantiated_t.getSpan(), 
    22962291                                        uninstantiated_t.isParenthesized(), uninstantiated_t.getName(), that.getStaticArgs()); 
    22972292                        return TypeCheckerResult.compose(that, t, subtypeChecker, obj_result, 
    2298                                         TypeCheckerResult.compose(that, subtypeChecker, staticArgs_result));                            
     2293                                        TypeCheckerResult.compose(that, subtypeChecker, staticArgs_result)); 
    22992294                } 
    23002295                else { 
     
    23032298                        TypeCheckerResult e_result = new TypeCheckerResult(that, TypeError.make(err, that)); 
    23042299                        return TypeCheckerResult.compose(that, subtypeChecker, obj_result, e_result, 
    2305                                         TypeCheckerResult.compose(that, subtypeChecker, staticArgs_result));                            
     2300                                        TypeCheckerResult.compose(that, subtypeChecker, staticArgs_result)); 
    23062301                } 
    23072302        } 
     
    23102305        } 
    23112306        } 
    2312          
     2307 
    23132308    // Checks the chunk given, and returns the result and a new expression. 
    23142309    // Requires that all TypeCheckerResults passed in actually have a type. 
     
    23172312        assert(!chunk.isEmpty()); 
    23182313        // The non-functions in each chunk, if any, are replaced by a single element consisting of the non-functions grouped 
    2319         // left-associatively into binary juxtapositions.  
     2314        // left-associatively into binary juxtapositions. 
    23202315        Option<Expr> last_non_fn = Option.none(); 
    23212316        List<Expr> fns = new LinkedList<Expr>(); 
     
    23422337        } 
    23432338        // We are done. result_expr must be some or this method wasn't implemented correctly. 
    2344         TypeCheckerResult result = TypeCheckerResult.compose(result_expr.unwrap(), subtypeChecker,  
     2339        TypeCheckerResult result = TypeCheckerResult.compose(result_expr.unwrap(), subtypeChecker, 
    23452340                        IterUtil.asList(IterUtil.pairFirsts(chunk))); 
    23462341        return Pair.make(result, result_expr.unwrap()); 
    23472342    } 
    2348      
     2343 
    23492344    @Override 
    23502345        public TypeCheckerResult forLooseJuxtOnly(LooseJuxt that, 
     
    23552350        // the ordering of association is different. 
    23562351        // Notice also that tightJuxt has to be recursive, but loose juxt is not, due to specification. 
    2357          
     2352 
    23582353        // Did any subexpressions fail to typecheck? 
    23592354        for( TypeCheckerResult r : exprs_result ) { 
    23602355                if( r.type().isNone()) 
    2361                         return TypeCheckerResult.compose(that, subtypeChecker, exprs_result);                   
    2362         } 
    2363          
     2356                        return TypeCheckerResult.compose(that, subtypeChecker, exprs_result); 
     2357        } 
     2358 
    23642359        if( that.getExprs().size() != exprs_result.size() ) { 
    23652360                bug("Number of types don't match number of sub-expressions"); 
     
    23712366                Iterator<Expr> expr_iter = that.getExprs().iterator(); 
    23722367                boolean seen_non_fn = false; 
    2373                 // First the loose juxtaposition is broken into nonempty chunks; wherever there is a non-function element followed  
    2374                 // by a function element, the latter begins a new chunk. Thus a chunk consists of some number (possibly zero) of  
    2375                 // functions followed by some number (possibly zero) of non-functions.  
     2368                // First the loose juxtaposition is broken into nonempty chunks; wherever there is a non-function element followed 
     2369                // by a function element, the latter begins a new chunk. Thus a chunk consists of some number (possibly zero) of 
     2370                // functions followed by some number (possibly zero) of non-functions. 
    23762371                for( TypeCheckerResult r : exprs_result ) { 
    2377                         boolean is_arrow = TypesUtil.isArrows(r.type().unwrap());  
     2372                        boolean is_arrow = TypesUtil.isArrows(r.type().unwrap()); 
    23782373                        if( is_arrow && seen_non_fn ) { 
    23792374                                // finished last chunk 
     
    23992394        List<Expr> new_juxt_exprs = IterUtil.asList(IterUtil.pairSeconds(checked_chunks)); 
    24002395        List<TypeCheckerResult> new_juxt_results = IterUtil.asList(IterUtil.pairFirsts(checked_chunks)); 
    2401          
     2396 
    24022397        if( checked_chunks.size() == 1 ) { 
    24032398                Expr expr = IterUtil.first(new_juxt_exprs); 
     
    24082403        // (1) If any element that remains has type String, then it is a static error if any two adjacent elements are not of type String. 
    24092404        // TODO: Separate pass? 
    2410         // (2) Treat the sequence that remains as a multifix application of the juxtaposition operator. The rules for multifix operators then apply:    
     2405        // (2) Treat the sequence that remains as a multifix application of the juxtaposition operator. The rules for multifix operators then apply: 
    24112406        OpExpr multi_op_expr = new OpExpr(that.getSpan(), that.getMultiJuxt(), new_juxt_exprs); 
    24122407        TypeCheckerResult multi_op_result = multi_op_expr.accept(this); 
  • trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/Evaluator.java

    r2019 r2022  
    9292import com.sun.fortress.nodes.ExtentRange; 
    9393import com.sun.fortress.nodes.FieldRef; 
    94 import com.sun.fortress.nodes.FieldRefForSure; 
    9594import com.sun.fortress.nodes.Link; 
    9695import com.sun.fortress.nodes.MethodInvocation; 
     
    805804    } 
    806805 
    807     @Override 
    808     public FValue forFieldRefForSure(FieldRefForSure x) { 
    809         return forFieldRefCommon(x, x.getField()); 
    810     } 
    811  
    812806    private FValue forFieldRefCommon(AbstractFieldRef x, Name fld) throws FortressException, 
    813807            ProgramError { 
     
    13611355            return ((FieldRef)arf).getField(); 
    13621356        } 
    1363         if (arf instanceof FieldRefForSure) { 
    1364             return ((FieldRefForSure)arf).getField(); 
    1365  
    1366         } 
    13671357        if (arf instanceof _RewriteFieldRef) { 
    13681358            return ((_RewriteFieldRef)arf).getField(); 
  • trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/LHSEvaluator.java

    r1895 r2022  
    4545import com.sun.fortress.interpreter.glue.WellKnownNames; 
    4646import com.sun.fortress.nodes.AbstractFieldRef; 
    47 import com.sun.fortress.nodes.FieldRefForSure; 
    4847import com.sun.fortress.nodes.Name; 
    4948import com.sun.fortress.nodes.NodeAbstractVisitor; 
     
    127126    } 
    128127 
    129     @Override 
    130     public Voidoid forFieldRefForSure(FieldRefForSure x) { 
    131         return forFieldRefCommon(x, x.getField()); 
    132     } 
    133  
    134  
    135  
    136128    LHSEvaluator(Evaluator evaluator, FValue value) { 
    137129        this.evaluator = evaluator; this.value = value; 
  • trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/LHSToLValue.java

    r1983 r2022  
    2424import com.sun.fortress.interpreter.evaluator.values.FObject; 
    2525import com.sun.fortress.interpreter.evaluator.values.FValue; 
    26 import com.sun.fortress.nodes.FieldRefForSure; 
    2726import com.sun.fortress.nodes.NodeAbstractVisitor; 
    2827import com.sun.fortress.nodes.Expr; 
     
    115114 
    116115    @Override 
    117     public LHS forFieldRefForSure(FieldRefForSure x) { 
    118         Expr from = wrapEval(x.getObj(), "Non-object in field selection"); 
    119         // TODO need to generalize to dotted names. 
    120         return new FieldRefForSure(x.getSpan(), false, from, x.getField()); 
    121     } 
    122  
    123  
    124     @Override 
    125116    public LHS for_RewriteFieldRef(_RewriteFieldRef x) { 
    126117        Expr from = wrapEval(x.getObj(), "Non-object in field selection");