[Nice-commit] Nice/src/bossa/syntax tools.nice,1.23,1.24 typecheck.nice,1.78,1.79
Brought to you by:
bonniot
From: <ar...@us...> - 2003-09-28 17:16:46
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv18438/F:/nice/src/bossa/syntax Modified Files: tools.nice typecheck.nice Log Message: Type inference for instanceof in a while loop. Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** tools.nice 27 Aug 2003 09:33:45 -0000 1.23 --- tools.nice 28 Sep 2003 17:16:33 -0000 1.24 *************** *** 93,102 **** } ! ?(MonoSymbol, TypeConstructor) getInstanceof(IfExp ifExp) { ! if (! (ifExp.condition instanceof CallExp)) return null; ! CallExp condition = cast(ifExp.condition); if (! condition.isCallTo("instanceof") || condition.arguments.size() != 2) return null; --- 93,102 ---- } ! ?(MonoSymbol, mlsub.typing.Monotype) getInstanceof(Expression cond) { ! if (! (cond instanceof CallExp)) return null; ! CallExp condition = cast(cond); if (! condition.isCallTo("instanceof") || condition.arguments.size() != 2) return null; *************** *** 120,124 **** return null; ! return (sym, notNull(type.representedType)); } --- 120,138 ---- return null; ! ! TypeConstructor tc = notNull(type.representedType); ! mlsub.typing.Monotype[?] parameters; ! ! if (tc.arity() == 0) ! parameters = null; ! else if (sym.getMonotype() instanceof mlsub.typing.MonotypeConstructor) ! { ! mlsub.typing.MonotypeConstructor mc = cast(sym.getMonotype()); ! parameters = mc.getTP(); ! } ! else ! return null; ! ! return (sym, Monotype.sure(new mlsub.typing.MonotypeConstructor(tc, parameters))); } Index: typecheck.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typecheck.nice,v retrieving revision 1.78 retrieving revision 1.79 diff -C2 -d -r1.78 -r1.79 *** typecheck.nice 17 Sep 2003 00:14:06 -0000 1.78 --- typecheck.nice 28 Sep 2003 17:16:33 -0000 1.79 *************** *** 392,415 **** }); ! ?(MonoSymbol, TypeConstructor) test = getInstanceof(e); if (test != null) { ! (MonoSymbol variable, TypeConstructor tc) = test; ! mlsub.typing.Monotype[?] parameters = null; ! if (tc.arity() == 0) ! parameters = null; ! else if (variable.getMonotype() instanceof mlsub.typing.MonotypeConstructor) ! { ! mlsub.typing.MonotypeConstructor mc = cast(variable.getMonotype()); ! parameters = mc.getTP(); ! } ! else ! test = null; ! ! if (test != null) ! { ! mlsub.typing.Monotype type = Monotype.sure(new mlsub.typing.MonotypeConstructor(tc, parameters)); ! setVarType(variable, now: type, otherBranch: variable.type); ! } } --- 392,400 ---- }); ! ?(MonoSymbol, mlsub.typing.Monotype) test = getInstanceof(notNull(e.condition)); if (test != null) { ! (MonoSymbol variable, mlsub.typing.Monotype type) = test; ! setVarType(variable, now: type, otherBranch: variable.type); } *************** *** 657,660 **** --- 642,652 ---- now: makeSure(variable.type), out: variable.type)); + + ?(MonoSymbol, mlsub.typing.Monotype) test = getInstanceof(notNull(whileExp)); + if (test != null) + { + (MonoSymbol variable, mlsub.typing.Monotype type) = test; + setVarType(variable, now: type, otherBranch: variable.type); + } } |