[Nice-commit] Nice/src/mlsub/typing/lowlevel Engine.java,1.26,1.27
Brought to you by:
bonniot
From: <bo...@us...> - 2003-12-03 21:50:44
|
Update of /cvsroot/nice/Nice/src/mlsub/typing/lowlevel In directory sc8-pr-cvs1:/tmp/cvs-serv1807/src/mlsub/typing/lowlevel Modified Files: Engine.java Log Message: Made Object a super-type of every monotype. Index: Engine.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/lowlevel/Engine.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** Engine.java 2 Jun 2003 17:58:27 -0000 1.26 --- Engine.java 3 Dec 2003 21:50:41 -0000 1.27 *************** *** 204,208 **** Kind k1 = e1.getKind(), k2 = e2.getKind(); ! if(k1!=null) if(k2!=null) --- 204,212 ---- Kind k1 = e1.getKind(), k2 = e2.getKind(); ! ! // If e2 is Top, this is trivial. ! if (k2 == mlsub.typing.TopMonotype.TopKind.instance) ! return; ! if(k1!=null) if(k2!=null) *************** *** 212,215 **** --- 216,233 ---- else { + /* If a non-rigid type variable was previously compared to some + rigid element, it will have its type. + it is still possible for it to be greater than Top + (and therefore equal to Top). For this, we just need to + forget its previous kind. + */ + if (k1 == mlsub.typing.TopMonotype.TopKind.instance && + e2 instanceof mlsub.typing.MonotypeVar && + ! isRigid(e2)) + { + ((mlsub.typing.MonotypeVar) e2).resetKind(k1); + return; + } + if(dbg) Debug.println("Bad kinding discovered by Engine : "+ *************** *** 262,272 **** else { ! e.setId(-2); // for debugging purposes floating.add(e); } } public static boolean isRigid(Element e) { Kind kind = e.getKind(); if(kind==null) --- 280,295 ---- else { ! e.setId(FLOATING); // for debugging purposes floating.add(e); } } + private static final int FLOATING = -3; + public static boolean isRigid(Element e) { + if (e.getId() == FLOATING) + return false; + Kind kind = e.getKind(); if(kind==null) *************** *** 387,390 **** --- 410,415 ---- throws Unsatisfiable { + boolean toTop = k == mlsub.typing.TopMonotype.TopKind.instance; + Stack s = new Stack(); *************** *** 427,431 **** } else if(leq.e2==e) ! if(leq.e1.getKind()==null) s.push(leq.e1); else --- 452,459 ---- } else if(leq.e2==e) ! // If e is Top, e1 <: e is trivial and can be discarded. ! if (toTop) ! i.remove(); ! else if (leq.e1.getKind() == null) s.push(leq.e1); else |