[Nice-commit] Nice/src/mlsub/typing/lowlevel K0.java,1.20,1.21 Engine.java,1.30,1.31
Brought to you by:
bonniot
From: Daniel B. <bo...@us...> - 2004-03-23 20:39:12
|
Update of /cvsroot/nice/Nice/src/mlsub/typing/lowlevel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24136/src/mlsub/typing/lowlevel Modified Files: K0.java Engine.java Log Message: When doing overloading resolution in existential mode, backtrack when the symbol is not applicable. Index: K0.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/lowlevel/K0.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** K0.java 11 Sep 2003 20:01:03 -0000 1.20 --- K0.java 23 Mar 2004 20:28:43 -0000 1.21 *************** *** 1371,1375 **** // backtrack to the situation the last time mark() has been called ! public void backtrack() { if (backup == null) // This can happen for a K0 that has been created on the fly --- 1371,1375 ---- // backtrack to the situation the last time mark() has been called ! public void backtrack(boolean ignore) { if (backup == null) // This can happen for a K0 that has been created on the fly *************** *** 1377,1380 **** --- 1377,1386 ---- return; + if (ignore) + { + backup = backup.previous; + return; + } + S.assume(S.a&& hasBeenInitialized); *************** *** 2133,2137 **** possibilities.clear(x0); } finally { ! backtrack(); backup = savedBackup; } --- 2139,2143 ---- possibilities.clear(x0); } finally { ! backtrack(false); backup = savedBackup; } Index: Engine.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/lowlevel/Engine.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Engine.java 23 Mar 2004 14:45:21 -0000 1.30 --- Engine.java 23 Mar 2004 20:28:43 -0000 1.31 *************** *** 38,49 **** * a matching leave() MUST be issued some time later by the caller. */ ! public static void enter() { if(dbg) Debug.println("Enter"); floating.mark(); soft.mark(); // Once we are in existential mode, we don't mark/backtrack. ! if (existentialLevel > 0) existentialLevel++; else --- 38,50 ---- * a matching leave() MUST be issued some time later by the caller. */ ! public static void enter(boolean tentative) { if(dbg) Debug.println("Enter"); floating.mark(); soft.mark(); + formerFree.mark(); // Once we are in existential mode, we don't mark/backtrack. ! if (!tentative && existentialLevel > 0) existentialLevel++; else *************** *** 102,108 **** * @exception Unsatisfiable if the constraint was not satisfiable. */ ! public static void leave() throws Unsatisfiable { try{ assertFrozens(); --- 103,115 ---- * @exception Unsatisfiable if the constraint was not satisfiable. */ ! public static void leave(boolean tentative, boolean commit) throws Unsatisfiable { + // 'tentative' is only meaningful when in existential mode + tentative &= existentialLevel > 0; + // We only 'commit' in tentative mode + commit &= tentative; + + boolean ok = false; try{ assertFrozens(); *************** *** 125,137 **** } } } finally{ ! backtrack(); } } ! public static void backtrack() { ! if (existentialLevel <= 1) { for(Iterator i = constraints.iterator(); --- 132,149 ---- } } + ok = true; } finally{ ! // Even if commit is true, if an error appeared during leaving ! // then we don't want to keep the changes. ! backtrack(tentative, ok && commit); } } ! public static void backtrack(boolean tentative, boolean commit) { ! floating.backtrack(); ! ! if (existentialLevel <= 1 || tentative) { for(Iterator i = constraints.iterator(); *************** *** 139,152 **** { Engine.Constraint k = (Engine.Constraint) i.next(); ! k.backtrack(); } ! frozenLeqs.backtrack(); } - floating.backtrack(); soft.backtrack(); ! if (existentialLevel > 0) existentialLevel--; } --- 151,182 ---- { Engine.Constraint k = (Engine.Constraint) i.next(); ! k.backtrack(commit); } ! if (! commit) ! frozenLeqs.backtrack(); ! ! if (tentative && !commit) ! { ! // These type variables used to be free. Since we don't commit, ! // we must set them free again! ! try{ ! for (Iterator i = formerFree.iterator(); i.hasNext();) ! { ! Element e = (Element) i.next(); ! e.setKind(null); ! floating.add(e); ! } ! } ! finally{ ! formerFree.endOfIteration(); ! } ! } } soft.backtrack(); + formerFree.backtrack(); ! if (!tentative && existentialLevel > 0) existentialLevel--; } *************** *** 451,454 **** --- 481,487 ---- "\nnew: " + k); + if (e.isExistential()) + formerFree.add(e); + // assert e.getKind()==null k.register(e); *************** *** 616,619 **** --- 649,653 ---- e.setKind(variablesConstraint); variablesConstraint.register(e); + i.remove(); } } *************** *** 621,625 **** floating.endOfIteration(); } - floating.clear(); try { --- 655,658 ---- *************** *** 685,688 **** --- 718,724 ---- private static final BackableList soft = new BackableList(); + /** The elements that have been put into a kind since the last mark. */ + private static final BackableList formerFree = new BackableList(); + /** The constraint of monotype variables */ public static Engine.Constraint variablesConstraint; *************** *** 960,966 **** } ! void backtrack() { ! k0.backtrack(); } --- 996,1002 ---- } ! void backtrack(boolean ignore) { ! k0.backtrack(ignore); } |