Changeset 2201

Show
Ignore:
Timestamp:
07/08/08 14:24:07 (5 months ago)
Author:
jrhil47
Message:

[TypeChecker?] Made sure all inference variable are bounded by Bottom and Any

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/StaticJUTest.java

    r2199 r2201  
    4242        "XXXMultipleRefErrors.fss", */ 
    4343        // This test the accumulator which is not desugared yet 
    44          "Sum.fss", 
    45         "DXXGeneratorTuple.fss" 
     44         "Sum.fss" 
    4645        //These are broken until the constraint solver is fixed 
    4746        //"TupleAssignment.fss", 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/ConstraintFormula.java

    r2200 r2201  
    8484import edu.rice.cs.plt.iter.IterUtil; 
    8585import edu.rice.cs.plt.lambda.Lambda; 
     86import edu.rice.cs.plt.lambda.Runnable1; 
    8687import edu.rice.cs.plt.tuple.Option; 
    8788 
     
    145146    /** 
    146147     * This is a prototype class in an attempt to more closely implement the algorithm 
    147      * described in  
     148     * described in the spec 
     149     *  
     150     * We maintain an invariant that if (i1,i2) is in uppers (12,i1) is in lowers. 
    148151     */ 
    149152    public static class SimpleFormula extends ConstraintFormula { 
     
    357360                // Returns a solved constraint formula, solved by doing the steps in 20.2 of spec1 beta 
    358361                private ConstraintFormula solve() { 
     362                         
     363                        Set<_InferenceVarType> ivars = CollectUtil.union(ivarLowerBounds.keySet(), ivarUpperBounds.keySet()); 
     364                         
    359365                        // 1.) for every cycle of constraints of naked prime static variables... 
    360                         Set<_InferenceVarType> ivars = CollectUtil.union(ivarLowerBounds.keySet(), ivarUpperBounds.keySet()); 
    361366                        for( _InferenceVarType ivar : ivars ) { 
    362367                                Option<ConsList<_InferenceVarType>> cycle = 
     
    371376 
    372377                         
    373                         // 3.) If some primed static variable ... 
    374                         Map<_InferenceVarType,Type> lubs = solveHelper(ivars, ivarUpperBounds,  
     378                        //Preprocess: make sure every inference variable is bounded 
     379                         
     380                        final Set<_InferenceVarType> temp = new HashSet<_InferenceVarType>(); 
     381                        temp.addAll(ivars); 
     382                        final NodeDepthFirstVisitor_void v=new NodeDepthFirstVisitor_void(){ 
     383                                @Override 
     384                                public void for_InferenceVarType(_InferenceVarType that) { 
     385                                        temp.add(that); 
     386                                } 
     387                        }; 
     388                        Runnable1<Type> accepter=new Runnable1<Type>(){ 
     389                                public void run(Type arg0) { 
     390                                        arg0.accept(v); 
     391                                } 
     392                        }; 
     393                         
     394                        for(_InferenceVarType ivar: ivars){ 
     395                                if(ivarUpperBounds.containsKey(ivar)){ 
     396                                        Set<Type> potentials = ivarUpperBounds.get(ivar); 
     397                                        IterUtil.run(potentials, accepter); 
     398                                } 
     399                                if(ivarLowerBounds.containsKey(ivar)){ 
     400                                        Set<Type> potentials = ivarLowerBounds.get(ivar); 
     401                                        IterUtil.run(potentials, accepter); 
     402                                } 
     403                        } 
     404                        MultiMap<_InferenceVarType,Type> newuppers = new MultiMap<_InferenceVarType,Type>(ivarUpperBounds); 
     405                        MultiMap<_InferenceVarType,Type> newlowers = new MultiMap<_InferenceVarType,Type>(ivarLowerBounds); 
     406                        for(_InferenceVarType ivar: CollectUtil.complement(temp,ivarUpperBounds.keySet())){ 
     407                                newuppers.putItem(ivar,Types.ANY); 
     408                        } 
     409                        for(_InferenceVarType ivar: CollectUtil.complement(temp,ivarLowerBounds.keySet())){ 
     410                                newlowers.putItem(ivar,Types.BOTTOM); 
     411                        } 
     412                         
     413                        ivars=temp; 
     414                         
     415                        // 2-3 
     416                        Map<_InferenceVarType,Type> lubs = solveHelper(ivars, newuppers,  
    375417                                        new Lambda<Set<Type>,Type>(){ 
    376418                                                public Type value(Set<Type> arg0) { 
     
    378420                                                }}); 
    379421                         
    380                         // 4.) for every naked static prime variable ... 
     422                        // 4-3' 
    381423                        // TODO: check to see if invariant is being violated by not using the new bounds from 
    382424                        // above here where we use ivarLowerbounds. 
    383                         Map<_InferenceVarType,Type> glbs = solveHelper(ivars, ivarLowerBounds, 
     425                        Map<_InferenceVarType,Type> glbs = solveHelper(ivars, newlowers, 
    384426                                        new Lambda<Set<Type>,Type>(){ 
    385427                                                public Type value(Set<Type> arg0) { 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeAnalyzer.java

    r2200 r2201  
    416416        if (cached.isSome()) { 
    417417            result = cached.unwrap(); 
    418             debug.log("found in cache"); 
    419         } 
    420         else  
    421                 if (history.expansions() > MAX_SUBTYPE_EXPANSIONS) { 
     418           debug.log("found in cache"); 
     419           } 
     420        else if (history.expansions() > MAX_SUBTYPE_EXPANSIONS) { 
    422421            result = FALSE; 
    423422            debug.log("reached max subtype expansions"); 
  • trunk/ProjectFortress/static_tests/DXXEqualityTesting.fss

    r2163 r2201  
    2626  end 
    2727 
     28(* blah *) 
     29 
    2830  run(args:String...):() = () 
    2931