nice-commit Mailing List for The Nice Programming Language (Page 50)
Brought to you by:
bonniot
You can subscribe to this list here.
2003 |
Jan
|
Feb
(60) |
Mar
(125) |
Apr
(183) |
May
(140) |
Jun
(227) |
Jul
(141) |
Aug
(181) |
Sep
(75) |
Oct
(89) |
Nov
(187) |
Dec
(162) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(69) |
Feb
(197) |
Mar
(98) |
Apr
(26) |
May
(10) |
Jun
(85) |
Jul
(88) |
Aug
(79) |
Sep
(80) |
Oct
(81) |
Nov
(53) |
Dec
(109) |
2005 |
Jan
(68) |
Feb
(77) |
Mar
(232) |
Apr
(79) |
May
(37) |
Jun
(37) |
Jul
(3) |
Aug
(18) |
Sep
|
Oct
|
Nov
|
Dec
|
2006 |
Jan
(10) |
Feb
|
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(1) |
Dec
(9) |
2007 |
Jan
(2) |
Feb
(8) |
Mar
(2) |
Apr
(5) |
May
|
Jun
|
Jul
|
Aug
(4) |
Sep
|
Oct
|
Nov
(17) |
Dec
(6) |
2008 |
Jan
|
Feb
(3) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Daniel B. <bo...@us...> - 2004-03-25 00:12:45
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8491/stdlib/nice/lang Modified Files: array.nice Log Message: The slice method on arrays overrides the slice method on Lists. Index: array.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/array.nice,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** array.nice 20 Mar 2004 11:26:13 -0000 1.34 --- array.nice 25 Mar 2004 00:02:03 -0000 1.35 *************** *** 84,88 **** } ! <T> T[] slice(T[] array, int from = 0, int to = array.length - 1) = fill(new T[to - from + 1], int i => array[i + from]); --- 84,88 ---- } ! override <T> T[] slice(T[] array, int from = 0, int to = array.length - 1) = fill(new T[to - from + 1], int i => array[i + from]); |
From: Daniel B. <bo...@us...> - 2004-03-24 23:55:07
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2614/src/bossa/syntax Modified Files: typecheck.nice Log Message: When checking polytype <: monotype, do not rigidify, since there are no need type variables introduced before. This should be slightly faster, and most importantly it allows existential type variables to be further constrained. This also means that we should _not_ discard changes after the test. Index: typecheck.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typecheck.nice,v retrieving revision 1.99 retrieving revision 1.100 diff -C2 -d -r1.99 -r1.100 *** typecheck.nice 24 Mar 2004 18:19:50 -0000 1.99 --- typecheck.nice 24 Mar 2004 23:44:25 -0000 1.100 *************** *** 923,928 **** void checkAssignment(mlsub.typing.Polytype left, Expression right) { ! typecheck(right); ! Typing.leq(right.getType(), left); } --- 923,933 ---- void checkAssignment(mlsub.typing.Polytype left, Expression right) { ! if (left.isMonomorphic) ! checkAssignment(left.getMonotype(), right); ! else ! { ! typecheck(right); ! Typing.leq(right.getType(), left); ! } } |
From: Daniel B. <bo...@us...> - 2004-03-24 23:55:06
|
Update of /cvsroot/nice/Nice/src/mlsub/typing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2614/src/mlsub/typing Modified Files: Typing.java Log Message: When checking polytype <: monotype, do not rigidify, since there are no need type variables introduced before. This should be slightly faster, and most importantly it allows existential type variables to be further constrained. This also means that we should _not_ discard changes after the test. Index: Typing.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/Typing.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** Typing.java 24 Mar 2004 14:02:11 -0000 1.38 --- Typing.java 24 Mar 2004 23:44:24 -0000 1.39 *************** *** 301,307 **** try{ ! Constraint.enter(t2.getConstraint()); ! implies(); Constraint.enter(t1.getConstraint()); --- 301,310 ---- try{ ! if (! t2.isMonomorphic()) ! { ! Constraint.enter(t2.getConstraint()); ! implies(); ! } Constraint.enter(t1.getConstraint()); *************** *** 327,342 **** Debug.println("Polytype leq: "+t1+" <: "+m2); ! // The additions we are going to make should be discarded at the end, ! // so as not to influence existential type variables in the context. ! int l = enter(true); try{ - implies(); - Constraint.enter(t1.getConstraint()); leq(t1.getMonotype(), m2); } finally{ ! if(leave(true, false) != l) throw new InternalError("Unmatched enters and leaves"); } --- 330,341 ---- Debug.println("Polytype leq: "+t1+" <: "+m2); ! int l = enter(); try{ Constraint.enter(t1.getConstraint()); leq(t1.getMonotype(), m2); } finally{ ! if(leave() != l) throw new InternalError("Unmatched enters and leaves"); } |
From: Daniel B. <bo...@us...> - 2004-03-24 23:55:05
|
Update of /cvsroot/nice/Nice/testsuite/compiler/typing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2614/testsuite/compiler/typing Modified Files: inference.testsuite Log Message: When checking polytype <: monotype, do not rigidify, since there are no need type variables introduced before. This should be slightly faster, and most importantly it allows existential type variables to be further constrained. This also means that we should _not_ discard changes after the test. Index: inference.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/typing/inference.testsuite,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** inference.testsuite 24 Mar 2004 14:02:10 -0000 1.5 --- inference.testsuite 24 Mar 2004 23:44:24 -0000 1.6 *************** *** 108,112 **** } ! /// PASS bug let L1 = new LinkedList(); for (var j = 1; j <= 10; j++) L1.add(j); --- 108,112 ---- } ! /// PASS let L1 = new LinkedList(); for (var j = 1; j <= 10; j++) L1.add(j); *************** *** 141,142 **** --- 141,168 ---- for(s : testmap.keySet()) println(s + " => " + testmap[s]); + + /// PASS + let testmap = new HashMap(); + for(s : ["1", "2", "3"]) + testmap[s] = Integer.parseInt(s); + for(String s : testmap.keySet()) + println(s + " => " + testmap[s]); + + /// PASS + let l = new ArrayList(); + (List<String> l0, List<String> l1) = foo(l); + /// Toplevel + <T,U | U <: T> (List<T>,List<U>) foo(List<U> x) = (new ArrayList(x), x); + + /// FAIL + let l = new ArrayList(); + (List<String> l0, List<String> l1) = foo(l); + /*/// FAIL HERE */ (List<Number> l2, List<Number> l3) = foo(l); + + /* Without failure above, then we could do: + l1.add(""); + Number n = l3.get(0); // Bang! + */ + + /// Toplevel + <T,U | U <: T> (List<T>,List<U>) foo(List<U> x) = (new ArrayList(x), x); |
From: Arjan B. <ar...@us...> - 2004-03-24 20:30:47
|
Update of /cvsroot/nice/Nice/testsuite/compiler/functions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19007/F:/nice/testsuite/compiler/functions Modified Files: clotures.testsuite Log Message: Testcase for bug in code generation. Index: clotures.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/functions/clotures.testsuite,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** clotures.testsuite 19 Nov 2002 15:53:24 -0000 1.2 --- clotures.testsuite 24 Mar 2004 20:20:07 -0000 1.3 *************** *** 16,17 **** --- 16,27 ---- long l = 0; [1].foreach(int i => { println(l); }); + + + /// PASS bug + boolean b = false; + [].foreach(int x => { + [].foreach(int y => { + if (true || false) + b = true; + }); + }); |
From: Daniel B. <bo...@us...> - 2004-03-24 18:30:34
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23727/src/bossa/syntax Modified Files: typecheck.nice tools.nice Log Message: Use the known monomorphic type in assignments when possible. Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** tools.nice 17 Mar 2004 16:55:34 -0000 1.33 --- tools.nice 24 Mar 2004 18:19:50 -0000 1.34 *************** *** 162,165 **** --- 162,167 ---- mlsub.typing.Polytype boolPolytype() = native PrimitiveType.boolPolytype; mlsub.typing.Polytype longPolytype() = native PrimitiveType.longPolytype; + mlsub.typing.Monotype boolType() = native PrimitiveType.boolType; + mlsub.typing.Monotype longType() = native PrimitiveType.longType; // Local Variables: Index: typecheck.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typecheck.nice,v retrieving revision 1.98 retrieving revision 1.99 diff -C2 -d -r1.98 -r1.99 *** typecheck.nice 17 Mar 2004 16:55:34 -0000 1.98 --- typecheck.nice 24 Mar 2004 18:19:50 -0000 1.99 *************** *** 53,57 **** try { ! checkAssignment(new mlsub.typing.Polytype(originalType), notNull(e.value)); // It is OK to assign the variable, considering it has the original --- 53,57 ---- try { ! checkAssignment(originalType, notNull(e.value)); // It is OK to assign the variable, considering it has the original *************** *** 85,89 **** if (originalType != null) try { ! checkAssignment(new mlsub.typing.Polytype(originalType), notNull(e.value)); } catch (TypingEx t) { throw assignmentError(e, to.toString(), --- 85,89 ---- if (originalType != null) try { ! checkAssignment(originalType, notNull(e.value)); } catch (TypingEx t) { throw assignmentError(e, to.toString(), *************** *** 591,595 **** try{ e.variable = notNull(e.variable).resolveOverloading(PrimitiveType.longPolytype); ! checkAssignment(PrimitiveType.longPolytype, notNull(e.variable)); } catch(TypingEx t){ --- 591,595 ---- try{ e.variable = notNull(e.variable).resolveOverloading(PrimitiveType.longPolytype); ! checkAssignment(PrimitiveType.longType, notNull(e.variable)); } catch(TypingEx t){ *************** *** 679,683 **** mlsub.typing.Polytype polytype = new mlsub.typing.Polytype(type); e.initValue = decl.value = value = value.resolveOverloading(polytype); ! checkAssignment(polytype, value); } catch(TypingEx t){ --- 679,683 ---- mlsub.typing.Polytype polytype = new mlsub.typing.Polytype(type); e.initValue = decl.value = value = value.resolveOverloading(polytype); ! checkAssignment(type, value); } catch(TypingEx t){ *************** *** 748,752 **** mlsub.typing.Polytype polytype = new mlsub.typing.Polytype(type); decl.value = value = value.resolveOverloading(polytype); ! checkAssignment(polytype, value); } catch(TypingEx t){ --- 748,752 ---- mlsub.typing.Polytype polytype = new mlsub.typing.Polytype(type); decl.value = value = value.resolveOverloading(polytype); ! checkAssignment(type, value); } catch(TypingEx t){ *************** *** 927,930 **** --- 927,936 ---- } + void checkAssignment(mlsub.typing.Monotype left, Expression right) + { + typecheck(right); + Typing.leq(right.getType(), left); + } + boolean isNullError(TypingEx ex); isNullError(@TypingEx) = false; *************** *** 962,966 **** void checkBooleanCondition(Expression condition) { try { ! checkAssignment(PrimitiveType.boolPolytype, condition); } catch(TypingEx t){ --- 968,972 ---- void checkBooleanCondition(Expression condition) { try { ! checkAssignment(PrimitiveType.boolType, condition); } catch(TypingEx t){ |
From: Daniel B. <bo...@us...> - 2004-03-24 14:12:50
|
Update of /cvsroot/nice/Nice/src/mlsub/typing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv618/src/mlsub/typing Modified Files: Typing.java Log Message: Handle typing checks that need rigidification while in existential mode (by appropriate backtracking). Index: Typing.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/Typing.java,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** Typing.java 23 Mar 2004 20:28:43 -0000 1.37 --- Typing.java 24 Mar 2004 14:02:11 -0000 1.38 *************** *** 296,301 **** Debug.println("Polytype leq: "+t1+" <: "+t2); ! int l; ! if(dbg) l=enter("#"); else l=enter(); try{ --- 296,302 ---- Debug.println("Polytype leq: "+t1+" <: "+t2); ! // The additions we are going to make should be discarded at the end, ! // so as not to influence existential type variables in the context. ! int l = enter(true); try{ *************** *** 308,312 **** } finally{ ! if(leave() != l) throw new InternalError("Unmatched enters and leaves"); } --- 309,313 ---- } finally{ ! if(leave(true, false) != l) throw new InternalError("Unmatched enters and leaves"); } *************** *** 326,331 **** Debug.println("Polytype leq: "+t1+" <: "+m2); ! int l; ! if(dbg) l=enter("#"); else l=enter(); try{ --- 327,333 ---- Debug.println("Polytype leq: "+t1+" <: "+m2); ! // The additions we are going to make should be discarded at the end, ! // so as not to influence existential type variables in the context. ! int l = enter(true); try{ *************** *** 336,340 **** } finally{ ! if(leave() != l) throw new InternalError("Unmatched enters and leaves"); } --- 338,342 ---- } finally{ ! if(leave(true, false) != l) throw new InternalError("Unmatched enters and leaves"); } *************** *** 470,474 **** } ! enter(); try{ Constraint.enter(d1.getConstraint()); --- 472,478 ---- } ! // The additions we are going to make should be discarded at the end, ! // so as not to influence existential type variables in the context. ! enter(true); try{ Constraint.enter(d1.getConstraint()); *************** *** 480,484 **** } finally{ ! leave(); } } --- 484,488 ---- } finally{ ! leave(true, false); } } |
From: Daniel B. <bo...@us...> - 2004-03-24 14:12:50
|
Update of /cvsroot/nice/Nice/testsuite/compiler/typing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv618/testsuite/compiler/typing Modified Files: inference.testsuite Log Message: Handle typing checks that need rigidification while in existential mode (by appropriate backtracking). Index: inference.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/typing/inference.testsuite,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** inference.testsuite 23 Mar 2004 20:28:42 -0000 1.4 --- inference.testsuite 24 Mar 2004 14:02:10 -0000 1.5 *************** *** 97,101 **** String s = l.get(0); ! /// PASS bug var n = 5; let table1 = new HashMap(10); --- 97,101 ---- String s = l.get(0); ! /// PASS var n = 5; let table1 = new HashMap(10); *************** *** 114,118 **** LinkedList<int> L2 = new LinkedList(L1); ! /// PASS bug let L1 = new LinkedList(); for (var j = 1; j <= 10; j++) --- 114,118 ---- LinkedList<int> L2 = new LinkedList(L1); ! /// PASS let L1 = new LinkedList(); for (var j = 1; j <= 10; j++) |
From: Daniel B. <bo...@us...> - 2004-03-23 20:39:13
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24136/src/bossa/syntax Modified Files: CallExp.java Log Message: When doing overloading resolution in existential mode, backtrack when the symbol is not applicable. Index: CallExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/CallExp.java,v retrieving revision 1.92 retrieving revision 1.93 diff -C2 -d -r1.92 -r1.93 *** CallExp.java 26 Feb 2004 22:17:39 -0000 1.92 --- CallExp.java 23 Mar 2004 20:28:43 -0000 1.93 *************** *** 107,111 **** { try{ ! Polytype t = getType(funt, parameters); return t; } --- 107,111 ---- { try{ ! Polytype t = getType(funt, parameters, true); return t; } *************** *** 124,128 **** try{ ! return getType(function.getType(), paramTypes); } catch(BadSizeEx e){ --- 124,128 ---- try{ ! return getType(function.getType(), paramTypes, false); } catch(BadSizeEx e){ *************** *** 167,172 **** } ! private static Polytype getType(Polytype type, ! Polytype[] parameters) throws TypingEx, BadSizeEx, ReportErrorEx { --- 167,176 ---- } ! /** ! @param tentative whether we only want to check if the call is valid ! (as during overloading resolution). ! */ ! private static Polytype getType(Polytype type, Polytype[] parameters, ! boolean tentative) throws TypingEx, BadSizeEx, ReportErrorEx { *************** *** 205,210 **** final boolean doEnter = true; //Constraint.hasBinders(cst); ! if(doEnter) Typing.enter(); ! try { --- 209,215 ---- final boolean doEnter = true; //Constraint.hasBinders(cst); ! if(doEnter) Typing.enter(tentative); ! ! boolean ok = false; try { *************** *** 224,231 **** Typing.in(parameters, dom); } finally{ if(doEnter) ! Typing.leave(); } --- 229,240 ---- Typing.in(parameters, dom); + ok = true; } finally{ if(doEnter) ! // If we are in tentative mode and the call is valid, then ! // we make the effects last (that's only important when there are ! // existential type variables in the context). ! Typing.leave(tentative, tentative && ok); } |
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); } |
From: Daniel B. <bo...@us...> - 2004-03-23 20:39:12
|
Update of /cvsroot/nice/Nice/src/mlsub/typing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24136/src/mlsub/typing Modified Files: Typing.java Enumeration.java Log Message: When doing overloading resolution in existential mode, backtrack when the symbol is not applicable. Index: Enumeration.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/Enumeration.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Enumeration.java 24 Feb 2004 18:35:26 -0000 1.11 --- Enumeration.java 23 Mar 2004 20:28:43 -0000 1.12 *************** *** 212,216 **** TypeConstructor[] vars = new TypeConstructor[tags.length]; ! Engine.enter(); try{ --- 212,216 ---- TypeConstructor[] vars = new TypeConstructor[tags.length]; ! Engine.enter(false); try{ *************** *** 273,277 **** } finally{ ! Engine.backtrack(); } --- 273,277 ---- } finally{ ! Engine.backtrack(false, false); } Index: Typing.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/Typing.java,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** Typing.java 17 Mar 2004 00:36:46 -0000 1.36 --- Typing.java 23 Mar 2004 20:28:43 -0000 1.37 *************** *** 39,46 **** public static int enter() { if(dbg) Debug.println("ENTER "+level); ! Engine.enter(); return level++; } --- 39,55 ---- public static int enter() { + return enter(false); + } + + /** + @param tentative when true, we will decide upon leaving if we want to + commit the changes made to existential type variables or not. + */ + public static int enter(boolean tentative) + { if(dbg) Debug.println("ENTER "+level); ! Engine.enter(tentative); return level++; } *************** *** 99,102 **** --- 108,122 ---- throws TypingEx { + return leave(false, false); + } + + /** + @param tentative must match the parameter used when entering + @param commit if tentative is true, then commit selects whether we + want to commit the changes made to existential type variables or not. + */ + public static int leave(boolean tentative, boolean commit) + throws TypingEx + { if(dbg) Debug.println("LEAVE "+(level-1)); *************** *** 104,108 **** try{ level--; ! Engine.leave(); } catch(Unsatisfiable e){ --- 124,128 ---- try{ level--; ! Engine.leave(tentative, commit); } catch(Unsatisfiable e){ |
From: Daniel B. <bo...@us...> - 2004-03-23 20:39:12
|
Update of /cvsroot/nice/Nice/testsuite/compiler/typing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24136/testsuite/compiler/typing Modified Files: inference.testsuite Log Message: When doing overloading resolution in existential mode, backtrack when the symbol is not applicable. Index: inference.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/typing/inference.testsuite,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** inference.testsuite 23 Mar 2004 14:45:21 -0000 1.3 --- inference.testsuite 23 Mar 2004 20:28:42 -0000 1.4 *************** *** 123,132 **** L3.add( L1.removeFirst ); ! /// PASS bug let L1 = new LinkedList(); L1.add(999); println( L1[0] ); ! /// PASS bug let testmap = new HashMap(); for(s : testmap.keySet()) --- 123,132 ---- L3.add( L1.removeFirst ); ! /// PASS let L1 = new LinkedList(); L1.add(999); println( L1[0] ); ! /// PASS let testmap = new HashMap(); for(s : testmap.keySet()) *************** *** 134,135 **** --- 134,142 ---- String x = s + " => " + testmap[s]; } + + /// PASS + let testmap = new HashMap(); + for(s : ["1", "2", "3"]) + testmap[s] = Integer.parseInt(s); + for(s : testmap.keySet()) + println(s + " => " + testmap[s]); |
From: Daniel B. <bo...@us...> - 2004-03-23 14:55:48
|
Update of /cvsroot/nice/Nice/src/mlsub/typing/lowlevel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6638/src/mlsub/typing/lowlevel Modified Files: Engine.java Log Message: Make sure to mark all existential elements when needed. Index: Engine.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/lowlevel/Engine.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** Engine.java 17 Mar 2004 16:55:33 -0000 1.29 --- Engine.java 23 Mar 2004 14:45:21 -0000 1.30 *************** *** 566,587 **** soft.clear(); ! try { ! for(Iterator i = frozenLeqs.iterator(); i.hasNext();) ! { ! Leq leq = (Leq) i.next(); ! Element e1 = leq.e1; ! Element e2 = leq.e2; ! // If at least one of the two is existential, then we must ! // keep ! if (e1.isExistential()) ! ((mlsub.typing.MonotypeVar) e2).setExistential(); ! else if (e2.isExistential()) ! ((mlsub.typing.MonotypeVar) e1).setExistential(); ! } ! } ! finally{ ! frozenLeqs.endOfIteration(); } try { --- 566,602 ---- soft.clear(); ! boolean more; ! do { ! more = false; ! try { ! for(Iterator i = frozenLeqs.iterator(); i.hasNext();) ! { ! Leq leq = (Leq) i.next(); ! Element e1 = leq.e1; ! Element e2 = leq.e2; ! // If at least one of the two is existential, then we must ! // keep both frozen. ! if ((e1.isExistential() && ! e2.isExistential()) ! || ! (e2.isExistential() && ! e1.isExistential())) ! { ! // Since we are marking an element as existential, we should ! // do one more pass to make sure all related elements are ! // marked ! more = true; ! ! if (e1.isExistential()) ! ((mlsub.typing.MonotypeVar) e2).setExistential(); ! else if (e2.isExistential()) ! ((mlsub.typing.MonotypeVar) e1).setExistential(); ! } ! } ! } ! finally{ ! frozenLeqs.endOfIteration(); ! } } + while (more); try { |
From: Daniel B. <bo...@us...> - 2004-03-23 14:55:48
|
Update of /cvsroot/nice/Nice/testsuite/compiler/typing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6638/testsuite/compiler/typing Modified Files: inference.testsuite Log Message: Make sure to mark all existential elements when needed. Index: inference.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/typing/inference.testsuite,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** inference.testsuite 22 Mar 2004 12:36:37 -0000 1.2 --- inference.testsuite 23 Mar 2004 14:45:21 -0000 1.3 *************** *** 127,128 **** --- 127,135 ---- L1.add(999); println( L1[0] ); + + /// PASS bug + let testmap = new HashMap(); + for(s : testmap.keySet()) + { + String x = s + " => " + testmap[s]; + } |
From: Francis B. <fb...@us...> - 2004-03-22 15:27:46
|
Update of /cvsroot/nice/Nice/src/nice/tools/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9894/src/nice/tools/doc Modified Files: htmlwriter.nice Log Message: nicedoc now documents global variables as well. a couple of minor clean-ups also done. Index: htmlwriter.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/doc/htmlwriter.nice,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** htmlwriter.nice 21 Mar 2004 01:40:59 -0000 1.6 --- htmlwriter.nice 22 Mar 2004 15:17:22 -0000 1.7 *************** *** 96,99 **** --- 96,125 ---- } + write(gv@GlobalVarDeclaration, packageName) { + //Handle global variables + + //Initialise a FileWriter + File dir = new File(outdir, packageName.replace('.',java.io.File.separator)); + if(!dir.exists() && !dir.mkdirs()) { + System.err.println("Error creating directory structure"); + } + + BufferedWriter writer = new BufferedWriter + (new FileWriter(new File(dir, "gv_" gv.getName() ".html"))); + + writer.write(getHeader(gv.getName().toString())); + + writer.write("<h1>Global Variable " + gv.getName() + "</h1>"); + + writer.write(htmlSafe(gv.toString())); + + writer.write("<p>"); + writer.write("nicedoc comments would go here..."); + writer.write("</p>"); + + writer.write(getFooter()); + writer.close(); + } + write(m@MethodDeclaration, packageName) { //Handle methods *************** *** 105,115 **** } - /*String fileName = m.getName().toString(); - //we only want information after the last . - //that is, nice.lang.Maybe -> Maybe - //System.out.println("Raw filename: " + fileName); - fileName = fileName.replace('/', "@slash"); - fileName = fileName.replace('.', "@dot");*/ - BufferedWriter writer = new BufferedWriter (new FileWriter(new File(dir, calculateMethodFilename(m)))); --- 131,134 ---- *************** *** 143,149 **** writer.write(getHeader("Package " + p.getName())); ! //we need to separate class and methods ArrayList<ClassDefinition.Class> classes = new ArrayList(); ArrayList<MethodDeclaration> methods = new ArrayList(); for(Definition d : p.getDefinitions().definitions()) { if(d instanceof ClassDefinition.Class) { --- 162,169 ---- writer.write(getHeader("Package " + p.getName())); ! //we need to separate class, methods, and global variables ArrayList<ClassDefinition.Class> classes = new ArrayList(); ArrayList<MethodDeclaration> methods = new ArrayList(); + ArrayList<GlobalVarDeclaration> globalVars = new ArrayList(); for(Definition d : p.getDefinitions().definitions()) { if(d instanceof ClassDefinition.Class) { *************** *** 156,161 **** methods.add(d.getDeclaration()); } else { ! System.err.println("Ignoring " + d); } } --- 176,184 ---- methods.add(d.getDeclaration()); } + else if(d instanceof GlobalVarDeclaration) { + globalVars.add(d); + } else { ! System.err.println("Ignoring " d "\n (type " d.getClass() ")"); } } *************** *** 181,186 **** } writer.write("</ul>\n"); ! ! writer.write(getFooter()); writer.close(); --- 204,216 ---- } writer.write("</ul>\n"); ! ! //Write global vars ! writer.write("<b>Global Variables:</b>\n"); ! writer.write("<ul>\n"); ! for(GlobalVarDeclaration gv : globalVars) { ! writer.write("<li><a href='gv_" gv.getName() ".html'>" gv.getName() "</a></li>\n"); ! } ! writer.write("</ul>\n"); ! writer.write(getFooter()); writer.close(); *************** *** 213,217 **** /** Converts a String that may contain characters such as '<' to one that will display ! * properly in html. Submitted by S. Bayer to http://www.rgagnon.com/javadetails/java-0306.html. */ String htmlSafe(String s) { --- 243,248 ---- /** Converts a String that may contain characters such as '<' to one that will display ! * properly in html. Submitted by S. Bayer to http://www.rgagnon.com/javadetails/java-0306.html, ! * although I've made some changes. */ String htmlSafe(String s) { *************** *** 251,258 **** sb.append("<br/>"); else { ! //char and int or not related in nice, so we can't do a direct cast //hence, we use int(c) instead of (int)c ! int ci = 0xffff & int(c); ! if(ci < 160) // nothing special only 7 Bit sb.append(c); --- 282,292 ---- sb.append("<br/>"); else { ! //char and int are not related in nice, so we can't do a direct cast //hence, we use int(c) instead of (int)c ! int ci = int(c); ! /*This was originally 160 in S. Bayer version, but I couldn't see the sense of that ! *so I changed it to 128, as 127 is the maximum value of an ascii character ! */ ! if(ci < 128) // nothing special only 7 Bit sb.append(c); |
From: Arjan B. <ar...@us...> - 2004-03-22 12:46:58
|
Update of /cvsroot/nice/Nice/testsuite/compiler/typing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6211/F:/nice/testsuite/compiler/typing Modified Files: inference.testsuite Log Message: Testcases from bugreports of polymorpic type inference. Index: inference.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/typing/inference.testsuite,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** inference.testsuite 17 Mar 2004 17:07:01 -0000 1.1 --- inference.testsuite 22 Mar 2004 12:36:37 -0000 1.2 *************** *** 96,97 **** --- 96,128 ---- } String s = l.get(0); + + /// PASS bug + var n = 5; + let table1 = new HashMap(10); + for (int i = 0; i <= n; i++) + table1["foo_" + i] = i; + + String key; + for (each : table1.entrySet) { + key = each.getKey; + } + + /// PASS bug + let L1 = new LinkedList(); + for (var j = 1; j <= 10; j++) L1.add(j); + + LinkedList<int> L2 = new LinkedList(L1); + + /// PASS bug + let L1 = new LinkedList(); + for (var j = 1; j <= 10; j++) + L1.add(j); + + let L3 = new LinkedList(); + while (!L1.isEmpty) + L3.add( L1.removeFirst ); + + /// PASS bug + let L1 = new LinkedList(); + L1.add(999); + println( L1[0] ); |
From: Francis B. <fb...@us...> - 2004-03-21 01:51:02
|
Update of /cvsroot/nice/Nice/src/nice/tools/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10726/src/nice/tools/doc Modified Files: htmlwriter.nice Log Message: 1) When generating file names, File.separator is now used instead of '/' (clearly better for portability). 2) Previously, if two methods where called "foo" they would both be written to the file "foo.html", the second overwriting the first. Now I use the hash code of the arguments, so we get something like "foo4351314.html". However, there is still a chance that two different argument types will have the same hash code. Index: htmlwriter.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/doc/htmlwriter.nice,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** htmlwriter.nice 20 Mar 2004 05:02:38 -0000 1.5 --- htmlwriter.nice 21 Mar 2004 01:40:59 -0000 1.6 *************** *** 7,10 **** --- 7,27 ---- */ + /*TODO + * 1)Make it file system independent by using java.io.File.separator instead of '/' + * Nice seems to reject this - + * Ambiguity for symbol File. Possibilities are : + * java.io.File File(?String, String) + * java.io.File File(?File, String) + */ + + /*Below is various info that could be used in the + *construction of the method entry + */ + //The compiler doesn't like this: println("Syntactic return type: " + m.getSyntacticReturnType()); + //println("Return type: " + m.getReturnType()); + //println("Arity: " + m.getArity()); + //println("Type: " + m.getType()); + //println("Formal Parameters: " + m.formalParameters()); + import bossa.syntax.*; import java.util.*; *************** *** 23,35 **** //Initialise a FileWriter // Output directory for this class ! File dir = new File(outdir, packageName.replace('.','/')); ! if(!dir.exists()) { ! if(!dir.mkdirs()) { ! System.err.println("Error creating directory structure"); ! } } String fileName = c.getName().toString(); //we only want information after the last . //that is, nice.lang.Maybe -> Maybe fileName = fileName.substring(fileName.lastIndexOf(".") + 1); BufferedWriter writer = new BufferedWriter --- 40,52 ---- //Initialise a FileWriter // Output directory for this class ! File dir = new File(outdir, packageName.replace('.', java.io.File.separator)); ! if(!dir.exists() && !dir.mkdirs()) { ! System.err.println("Error creating directory structure"); } + String fileName = c.getName().toString(); //we only want information after the last . //that is, nice.lang.Maybe -> Maybe + //this should also work when "." is not found fileName = fileName.substring(fileName.lastIndexOf(".") + 1); BufferedWriter writer = new BufferedWriter *************** *** 42,46 **** //Print hierarchy ArrayList<ClassDefinition.Class> list = new ArrayList(); ! ClassDefinition.Class superClass = c.getSuperClassDefinition(); while(superClass != null) { list.add(superClass); --- 59,63 ---- //Print hierarchy ArrayList<ClassDefinition.Class> list = new ArrayList(); ! ?ClassDefinition.Class superClass = c.getSuperClassDefinition(); while(superClass != null) { list.add(superClass); *************** *** 67,71 **** //Implemented interfaces ClassDefinition.Interface[?] interfaces = c.getImplementedInterfaces(); ! if (interfaces != null) { writer.write("<b>Implemented interfaces:</b>"); writer.write("<ul>"); --- 84,88 ---- //Implemented interfaces ClassDefinition.Interface[?] interfaces = c.getImplementedInterfaces(); ! if(interfaces != null) { writer.write("<b>Implemented interfaces:</b>"); writer.write("<ul>"); *************** *** 83,99 **** //Initialise a FileWriter ! File dir = new File(outdir, packageName.replace('.','/')); if(!dir.exists() && !dir.mkdirs()) { System.err.println("Error creating directory structure"); } ! String fileName = m.getName().toString(); //we only want information after the last . //that is, nice.lang.Maybe -> Maybe //System.out.println("Raw filename: " + fileName); fileName = fileName.replace('/', "@slash"); ! fileName = fileName.replace('.', "@dot"); BufferedWriter writer = new BufferedWriter ! (new FileWriter(new File(dir, fileName + ".html"))); writer.write(getHeader(m.getName().toString())); --- 100,117 ---- //Initialise a FileWriter ! File dir = new File(outdir, packageName.replace('.',java.io.File.separator)); if(!dir.exists() && !dir.mkdirs()) { System.err.println("Error creating directory structure"); } ! ! /*String fileName = m.getName().toString(); //we only want information after the last . //that is, nice.lang.Maybe -> Maybe //System.out.println("Raw filename: " + fileName); fileName = fileName.replace('/', "@slash"); ! fileName = fileName.replace('.', "@dot");*/ BufferedWriter writer = new BufferedWriter ! (new FileWriter(new File(dir, calculateMethodFilename(m)))); writer.write(getHeader(m.getName().toString())); *************** *** 106,118 **** writer.write("nicedoc comments would go here..."); writer.write("</p>"); ! /*Below is various info that could be used in the ! *construction of the method entry ! */ ! //The compiler doesn't like this: println("Syntactic return type: " + m.getSyntacticReturnType()); ! //println("Return type: " + m.getReturnType()); ! //println("Arity: " + m.getArity()); ! //println("Type: " + m.getType()); ! //println("Formal Parameters: " + m.formalParameters()); ! writer.write(getFooter()); writer.close(); --- 124,128 ---- writer.write("nicedoc comments would go here..."); writer.write("</p>"); ! writer.write(getFooter()); writer.close(); *************** *** 125,129 **** void write(bossa.modules.Package p) { try { ! File dir = new File(outdir, p.getName().replace('.','/')); if(!dir.exists() && !dir.mkdirs()) { System.err.println("Error creating directory structure"); --- 135,139 ---- void write(bossa.modules.Package p) { try { ! File dir = new File(outdir, p.getName().replace('.',java.io.File.separator)); if(!dir.exists() && !dir.mkdirs()) { System.err.println("Error creating directory structure"); *************** *** 167,172 **** writer.write("<ul>\n"); for(MethodDeclaration m : methods) { ! writer.write("<li><a href='" + m.getName() + ".html'>" + m.getName() + "</a>" + ! ": " + m.getType() + "</li>\n"); } writer.write("</ul>\n"); --- 177,182 ---- writer.write("<ul>\n"); for(MethodDeclaration m : methods) { ! writer.write("<li><a href='" calculateMethodFilename(m) "'>" m.getName() "</a>" + ! ": " m.getType() "</li>\n"); } writer.write("</ul>\n"); *************** *** 270,274 **** "<html>\n" + "<head>\n" + ! "<!-- Generated by nicedoc on " + df.format(new Date()) + " -->\n" + "\t<title>" + title + "</title>\n" + "</head>\n" + --- 280,284 ---- "<html>\n" + "<head>\n" + ! "<!-- Generated by nicedoc on " df.format(new Date()) " -->\n" + "\t<title>" + title + "</title>\n" + "</head>\n" + *************** *** 283,285 **** --- 293,304 ---- "</body>\n" + "</html>\n"; + } + + /** Methods can be overloaded - we can't just use the method name as a file name. + * This method returns a file name based upon the method name and its arguments. + */ + String calculateMethodFilename(MethodDeclaration md) { + String filename = md.getName().toString() + md.getType().toString().hashCode(); + filename = filename.replace('/', "@slash").replace('.', "@dot"); + return filename + ".html"; } \ No newline at end of file |
From: Daniel B. <bo...@us...> - 2004-03-20 16:34:14
|
Update of /cvsroot/nice/Nice In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7841 Modified Files: NEWS Log Message: Compile dispatch methods as member methods whenever possible, to make integration with Java tools and code easier. Index: NEWS =================================================================== RCS file: /cvsroot/nice/Nice/NEWS,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** NEWS 8 Mar 2004 18:03:24 -0000 1.29 --- NEWS 20 Mar 2004 16:24:15 -0000 1.30 *************** *** 1,2 **** --- 1,10 ---- + nice (0.9.8) + + * Nice methods are now compiled inside classes whenever possible. This does + not make any difference for Nice programs, but simplifies integration with + Java tools and usage of Nice code from Java sources. + + -- + nice (0.9.7) |
From: Daniel B. <bo...@us...> - 2004-03-20 15:59:24
|
Update of /cvsroot/nice/Nice/src/bossa/link In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv403/src/bossa/link Modified Files: Compilation.java Log Message: Compile dispatch methods as member methods whenever possible, to make integration with Java tools and code easier. Index: Compilation.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/link/Compilation.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Compilation.java 28 Feb 2004 12:26:05 -0000 1.15 --- Compilation.java 20 Mar 2004 15:49:25 -0000 1.16 *************** *** 46,49 **** --- 46,51 ---- Expression[] params = new Expression[arity]; int rank = 0; + if (lexp.isClassMethod()) + params[rank++] = new ThisExp(lexp.outerClass()); for(Declaration param = lexp.firstDecl(); rank < arity; param = param.nextDecl()) |
From: Daniel B. <bo...@us...> - 2004-03-20 15:59:24
|
Update of /cvsroot/nice/Nice/src/gnu/expr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv403/src/gnu/expr Modified Files: ThisExp.java Compilation.java Log Message: Compile dispatch methods as member methods whenever possible, to make integration with Java tools and code easier. Index: ThisExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/gnu/expr/ThisExp.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ThisExp.java 27 Nov 2003 21:02:13 -0000 1.3 --- ThisExp.java 20 Mar 2004 15:49:24 -0000 1.4 *************** *** 39,42 **** --- 39,43 ---- else comp.getCode().emitPushThis(); + target.compileFromStack(comp, comp.getCode().topType()); } Index: Compilation.java =================================================================== RCS file: /cvsroot/nice/Nice/src/gnu/expr/Compilation.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Compilation.java 17 Jan 2004 17:13:36 -0000 1.21 --- Compilation.java 20 Mar 2004 15:49:24 -0000 1.22 *************** *** 987,990 **** --- 987,993 ---- { LambdaExp source = (LambdaExp) lexp.applyMethods.elementAt(j); + int min_args = source.min_args; + if (source.isClassMethod()) + min_args++; // Select the subset of source.primMethods[*] that are suitable // for the current apply method. *************** *** 993,1002 **** boolean varArgs = source.max_args < 0 || Compilation.usingTailCalls ! || source.max_args >= source.min_args + numMethods; int methodIndex; boolean skipThisProc = false; if (i < 5) // Handling apply0 .. apply4 { ! methodIndex = i - source.min_args; if (methodIndex < 0 || methodIndex >= numMethods || (methodIndex == numMethods - 1 && varArgs)) --- 996,1005 ---- boolean varArgs = source.max_args < 0 || Compilation.usingTailCalls ! || source.max_args >= min_args + numMethods; int methodIndex; boolean skipThisProc = false; if (i < 5) // Handling apply0 .. apply4 { ! methodIndex = i - min_args; if (methodIndex < 0 || methodIndex >= numMethods || (methodIndex == numMethods - 1 && varArgs)) *************** *** 1007,1011 **** else // Handling applyN { ! methodIndex = 5 - source.min_args; if (methodIndex > 0 && numMethods <= methodIndex && ! varArgs) skipThisProc = true; --- 1010,1014 ---- else // Handling applyN { ! methodIndex = 5 - min_args; if (methodIndex > 0 && numMethods <= methodIndex && ! varArgs) skipThisProc = true; *************** *** 1066,1072 **** code.emitLoad(code.getArg(2)); code.emitArrayLength(); ! if (source.min_args != 0) { ! code.emitPushInt(source.min_args); code.emitSub(Type.int_type); } --- 1069,1075 ---- code.emitLoad(code.getArg(2)); code.emitArrayLength(); ! if (min_args != 0) { ! code.emitPushInt(min_args); code.emitSub(Type.int_type); } *************** *** 1074,1089 **** } ! int needsThis = primMethod.getStaticFlag() ? 0 : 1; ! if (needsThis > 0) code.emitPushThis(); Declaration var = source.firstDecl(); for (int k = 0; k < singleArgs; k++) { ! if (counter != null && k >= source.min_args) { code.emitLoad(counter); code.emitIfIntLEqZero(); ! code.emitInvoke(primMethods[k - source.min_args]); code.emitElse(); pendingIfEnds++; --- 1077,1100 ---- } ! int argumentStart = 2; ! ! if (source.getImportsLexVars()) code.emitPushThis(); + if (source.isClassMethod()) + { + code.emitLoad(code.getArg(argumentStart++)); + Type ptype = primMethod.getDeclaringClass(); + ptype.emitCoerceFromObject(code); + } + Declaration var = source.firstDecl(); for (int k = 0; k < singleArgs; k++) { ! if (counter != null && k >= min_args) { code.emitLoad(counter); code.emitIfIntLEqZero(); ! code.emitInvoke(primMethods[k - min_args]); code.emitElse(); pendingIfEnds++; *************** *** 1099,1103 **** } else // apply'i method ! code.emitLoad(code.getArg(k + 2)); Type ptype = var.getType(); if (ptype != Type.pointer_type) --- 1110,1114 ---- } else // apply'i method ! code.emitLoad(code.getArg(k + argumentStart)); Type ptype = var.getType(); if (ptype != Type.pointer_type) |
From: Daniel B. <bo...@us...> - 2004-03-20 15:59:24
|
Update of /cvsroot/nice/Nice/src/bossa/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv403/src/bossa/modules Modified Files: Package.java Log Message: Compile dispatch methods as member methods whenever possible, to make integration with Java tools and code easier. Index: Package.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/Package.java,v retrieving revision 1.114 retrieving revision 1.115 diff -C2 -d -r1.114 -r1.115 *** Package.java 5 Mar 2004 14:07:14 -0000 1.114 --- Package.java 20 Mar 2004 15:49:24 -0000 1.115 *************** *** 812,817 **** retType = def.javaReturnType(); } res = nice.tools.code.Gen.createMethod ! (name, argTypes, retType, def.getSymbols()); res.parameterCopies = def.formalParameters().getParameterCopies(); --- 812,836 ---- retType = def.javaReturnType(); } + + // Try to compile the dispatch method as a member method if possible. + NiceClass receiver; + if (argTypes.length == 0) + receiver = null; + else + { + receiver = NiceClass.get(def.getArgTypes()[0]); + + // JVM interfaces cannot contain code. + if (receiver != null && receiver.isInterface()) + receiver = null; + + // Special treatment for serialization at the moment. + if (def.getArity() == 2 && + (name.equals("writeObject")||name.equals("readObject"))) + receiver = null; + } + res = nice.tools.code.Gen.createMethod ! (name, argTypes, retType, def.getSymbols(), true, receiver != null); res.parameterCopies = def.formalParameters().getParameterCopies(); *************** *** 820,824 **** (new MiscAttr("id", def.getFullName().getBytes())); ! return addMethod(res, false); } --- 839,846 ---- (new MiscAttr("id", def.getFullName().getBytes())); ! if (receiver != null) ! return receiver.addJavaMethod(res); ! else ! return addMethod(res, false); } |
From: Daniel B. <bo...@us...> - 2004-03-20 15:59:24
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv403/src/bossa/syntax Modified Files: TypeMaper.java NiceClass.java MethodImplementation.java Log Message: Compile dispatch methods as member methods whenever possible, to make integration with Java tools and code easier. Index: TypeMaper.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/TypeMaper.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TypeMaper.java 12 Sep 2003 21:35:25 -0000 1.6 --- TypeMaper.java 20 Mar 2004 15:49:24 -0000 1.7 *************** *** 44,48 **** public TypeSymbol lookup(String name, bossa.util.Location loc) { ! TypeSymbol res = (TypeSymbol) nice.tools.ast.dispatch.get(inner, name); if (res != null) return res; --- 44,48 ---- public TypeSymbol lookup(String name, bossa.util.Location loc) { ! TypeSymbol res = (TypeSymbol) inner.get(name); if (res != null) return res; Index: NiceClass.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/NiceClass.java,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** NiceClass.java 4 Mar 2004 15:48:21 -0000 1.80 --- NiceClass.java 20 Mar 2004 15:49:24 -0000 1.81 *************** *** 82,85 **** --- 82,90 ---- ClassDefinition definition; + public boolean isInterface() + { + return definition instanceof ClassDefinition.Interface; + } + private static NewField[] noFields = new NewField[0]; private static OverridenField[] noOverrides = new OverridenField[0]; *************** *** 94,97 **** --- 99,110 ---- } + public static NiceClass get(mlsub.typing.Monotype type) + { + if (! nice.tools.typing.Types.isSure(type)) + return null; + + return get(nice.tools.typing.Types.constructor(type)); + } + NiceClass getParent() { *************** *** 120,124 **** boolean isFinal, boolean isTransient, boolean isVolatile, String docString) { ! if (definition instanceof ClassDefinition.Interface) User.error(sym, "An interface cannot have a field."); --- 133,137 ---- boolean isFinal, boolean isTransient, boolean isVolatile, String docString) { ! if (isInterface()) User.error(sym, "An interface cannot have a field."); *************** *** 128,132 **** public Field makeOverride (MonoSymbol sym, Expression value) { ! if (definition instanceof ClassDefinition.Interface) User.error(sym, "An interface cannot have a field."); --- 141,145 ---- public Field makeOverride (MonoSymbol sym, Expression value) { ! if (isInterface()) User.error(sym, "An interface cannot have a field."); *************** *** 809,813 **** return; ! if (definition instanceof ClassDefinition.Interface) return; --- 822,826 ---- return; ! if (isInterface()) return; Index: MethodImplementation.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MethodImplementation.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MethodImplementation.java 28 Feb 2004 14:23:43 -0000 1.5 --- MethodImplementation.java 20 Mar 2004 15:49:24 -0000 1.6 *************** *** 222,232 **** final int arity = formals.length; String name = this.name.toString(); - boolean isPrivate; ! if ((arity == 2) && (name.equals("writeObject") || name.equals("readObject"))) ! isPrivate = true; ! else if ((arity == 1) && (name.equals("writeReplace") || name.equals("readResolve"))) ! isPrivate = false; ! else return; --- 222,227 ---- final int arity = formals.length; String name = this.name.toString(); ! if (arity != 2 || !(name.equals("writeObject")||name.equals("readObject"))) return; *************** *** 247,252 **** Gen.setMethodBody(method, new gnu.expr.ApplyExp(getRefExp(), params)); ! c.getClassExp().addMethod(method, isPrivate); ! } --- 242,246 ---- Gen.setMethodBody(method, new gnu.expr.ApplyExp(getRefExp(), params)); ! c.getClassExp().addMethod(method, true); } |
From: Daniel B. <bo...@us...> - 2004-03-20 15:59:22
|
Update of /cvsroot/nice/Nice/src/nice/tools/ant In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv403/src/nice/tools/ant Modified Files: NiceUnit.java Log Message: Compile dispatch methods as member methods whenever possible, to make integration with Java tools and code easier. Index: NiceUnit.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/ant/NiceUnit.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NiceUnit.java 18 Feb 2004 16:47:34 -0000 1.1 --- NiceUnit.java 20 Mar 2004 15:49:24 -0000 1.2 *************** *** 133,137 **** throw new BuildException("Package " + pack + " was not found"); ! dispatch.printSummary(listener); } finally { --- 133,137 ---- throw new BuildException("Package " + pack + " was not found"); ! listener.printSummary(); } finally { |
From: Daniel B. <bo...@us...> - 2004-03-20 15:59:22
|
Update of /cvsroot/nice/Nice/testsuite/compiler/methods In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv403/testsuite/compiler/methods Added Files: compilation.testsuite Log Message: Compile dispatch methods as member methods whenever possible, to make integration with Java tools and code easier. --- NEW FILE: compilation.testsuite --- /// PASS // Test that the method is compiled inside the class let m = A.class.getDeclaredMethod("foo", []); assert m.invoke(new A(), null).equals("ABC"); /// Toplevel class A { String foo() = "ABC"; } |
From: Daniel B. <bo...@us...> - 2004-03-20 15:35:29
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27935/stdlib/nice/lang Modified Files: java-io.nice Log Message: Renamed retyped constructors for File to avoid clash with static field access. Index: java-io.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/java-io.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** java-io.nice 25 Feb 2004 14:53:46 -0000 1.3 --- java-io.nice 20 Mar 2004 15:25:30 -0000 1.4 *************** *** 39,44 **** // Constructors ! File File(?File, String) = native new File(File, String); ! File File(?String, String) = native new File(String, String); // OutputStreams --- 39,44 ---- // Constructors ! File newFile(?File, String) = native new File(File, String); ! File newFile(?String, String) = native new File(String, String); // OutputStreams |