[Nice-commit] Nice/src/bossa/syntax typecheck.nice,1.86,1.87
Brought to you by:
bonniot
From: <ar...@us...> - 2003-11-21 14:41:44
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv4821/F:/nice/src/bossa/syntax Modified Files: typecheck.nice Log Message: optimized type checking in closures. Index: typecheck.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typecheck.nice,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -d -r1.86 -r1.87 *** typecheck.nice 21 Nov 2003 00:43:05 -0000 1.86 --- typecheck.nice 21 Nov 2003 14:41:40 -0000 1.87 *************** *** 227,236 **** Node.setCurrentFunction(e); ! enterClosure(); try { typecheck(e.body); } finally { ! exitClosure(); } --- 227,237 ---- Node.setCurrentFunction(e); ! let needExit = enterClosure(); try { typecheck(e.body); } finally { ! if (needExit) ! exitClosure(); } *************** *** 450,467 **** var Stack<List<(MonoSymbol, mlsub.typing.Monotype)>> replacedTypes = new Stack(); ! void enterClosure() { ! Set<MonoSymbol> done = new HashSet(); List<(MonoSymbol, mlsub.typing.Monotype)> replaced = new ArrayList(); //set all for all variables the original type back and store it ! for (int i = 0; i < levels.size(); i++) { (MonoSymbol variable, mlsub.typing.Monotype type) = conditionalTypes.get(i); ! if (!done.contains(variable)) ! { ! replaced.add((variable, variable.type)); ! variable.type = type; ! done.add(variable); ! } } --- 451,466 ---- var Stack<List<(MonoSymbol, mlsub.typing.Monotype)>> replacedTypes = new Stack(); ! boolean enterClosure() { ! if (levels.isEmpty()) ! return false; ! List<(MonoSymbol, mlsub.typing.Monotype)> replaced = new ArrayList(); //set all for all variables the original type back and store it ! for (int i = levels.size(); i-- > 0;) { (MonoSymbol variable, mlsub.typing.Monotype type) = conditionalTypes.get(i); ! replaced.add((variable, variable.type)); ! variable.type = type; } *************** *** 470,473 **** --- 469,474 ---- levels = new Stack(); conditionalTypes = new Stack(); + + return true; } |