Show
Ignore:
Timestamp:
11/06/09 14:37:52 (3 weeks ago)
Author:
jmaessen
Message:

[compiler, tests] Some refactoring on TreapAndTest. Fixed #362 and
added a test for it. Some misc cleanups on AbstractMethodChecker
that didn't make it into the last commit [Still looking to fix this to
avoid O(n2) behavior].

Location:
trunk/ProjectFortress/src/com/sun/fortress
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/codegen/CodeGen.java

    r4315 r4318  
    524524    private void doStatements(List<Expr> stmts) { 
    525525        int onStack = 0; 
     526        if (stmts.isEmpty()) { 
     527            pushVoid(); 
     528            return; 
     529        } 
    526530        for ( Expr e : stmts ) { 
    527531            popAll(onStack); 
     
    555559        inABlock=oldInABlock; 
    556560    } 
     561 
    557562    public void forChainExpr(ChainExpr x) { 
    558563        debug( "forChainExpr", x); 
     
    651656 
    652657        dumpClass( packageAndClassName ); 
    653          
     658 
    654659        try { 
    655660            jos.close(); 
     
    24102415        Type receiverType = exprType(obj); 
    24112416        if (!(receiverType instanceof TraitType)) { 
    2412             sayWhat(x, "receiver type is not TraitType in " + x); 
     2417            sayWhat(x, "receiver type "+receiverType+" is not TraitType in " + x); 
    24132418        } 
    24142419 
     
    24822487    public void for_RewriteFnApp(_RewriteFnApp x) { 
    24832488        debug("for_RewriteFnApp ", x, 
    2484                      " args = ", x.getArgument(), " function = ", x.getFunction(),  
     2489                     " args = ", x.getArgument(), " function = ", x.getFunction(), 
    24852490              " function class = ", x.getFunction()); 
    24862491        // This is a little weird.  If a function takes no arguments the parser gives me a void literal expr 
  • trunk/ProjectFortress/src/com/sun/fortress/scala_src/typechecker/AbstractMethodChecker.scala

    r4309 r4318  
    7474        val inherited = inheritedMethods(traits, extendsC, Set(), typeAnalyzer) 
    7575                        .map(t => t._1.asInstanceOf[IdOrOp].getText) 
    76         for ( d <- decls ; if d.isInstanceOf[FnDecl] ) { 
    77           if ( NU.isFunctionalMethod(NU.getParams(d.asInstanceOf[FnDecl])) && 
    78                ! inherited.exists(NU.getName(d.asInstanceOf[FnDecl]).asInstanceOf[IdOrOp].getText.equals(_)) ) 
    79             error(span, "Object expressions should not define any new " + 
    80                   "functional methods.") 
    81         } 
     76        for { 
     77          d <- decls; 
     78          if d.isInstanceOf[FnDecl]; 
     79          if NU.isFunctionalMethod(NU.getParams(d.asInstanceOf[FnDecl])); 
     80          if !inherited.exists(NU.getName(d.asInstanceOf[FnDecl]).asInstanceOf[IdOrOp] 
     81                               .getText.equals(_)) 
     82        } error(span, "Object expressions should not define any new " + 
     83                      "functional methods.") 
    8284 
    8385      case _ => super.walk(node) 
     
    9597    typeAnalyzer = typeAnalyzer.extend(sparams, None) 
    9698    val toCheck = inheritedAbstractMethods(extendsC) 
    97     for ( (owner, d) <- toCheck ) { 
    98       if ( ! implement(d, decls, owner) ) { 
     99    for ( (owner, d) <- toCheck; if (!implement(d, decls, owner)) ) { 
    99100        error(span, 
    100101              "The inherited abstract method " + d + " from the trait " + owner + 
    101102              "\n    in the object " + name + 
    102103              " is not defined in the component " + componentName + ".") 
    103       } 
    104104    } 
    105105    typeAnalyzer = oldTypeAnalyzer 
     
    129129  private def collectAbstractMethods(name: IdOrOp, decls: List[Decl]) = { 
    130130    val set = new HashSet[FnDecl] 
    131     decls.foreach( (d: Decl) => d match { 
    132                    case fd@SFnDecl(_,SFnHeader(_,mods,_,_,_,_,_,_),_,body,_) => 
    133                      if ( component.typeConses.containsKey(name) ) { 
    134                        if ( ! body.isDefined ) set += fd 
    135                      } else if ( mods.isAbstract ) set += fd 
    136                    case _ => }) 
     131    for ( fd@SFnDecl(_,SFnHeader(_,mods,_,_,_,_,_,_),_,body,_) <- decls ) { 
     132      if ( component.typeConses.containsKey(name) ) { 
     133        if ( ! body.isDefined ) set += fd 
     134      } else if ( mods.isAbstract ) set += fd 
     135    } 
    137136    set 
    138137  }