nice-commit Mailing List for The Nice Programming Language (Page 104)
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: <bo...@us...> - 2003-06-10 19:33:05
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv3807/src/bossa/syntax Modified Files: analyse.nice Log Message: Handle correctly 'break' and 'continue' with unknown labels. Index: analyse.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/analyse.nice,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** analyse.nice 5 Jun 2003 16:06:03 -0000 1.70 --- analyse.nice 10 Jun 2003 19:33:00 -0000 1.71 *************** *** 690,694 **** analyse(b@BreakLabelStmt, info) { ! b.statement = findLabel(notNull(b.label), info); info.setUnreachable(); } --- 690,694 ---- analyse(b@BreakLabelStmt, info) { ! b.statement = mustFindLabel(notNull(b.label), info); info.setUnreachable(); } *************** *** 702,706 **** else { ! LabeledStmt l = findLabel(notNull(c.label), info); c.loop = l.getLoop(); } --- 702,706 ---- else { ! LabeledStmt l = mustFindLabel(notNull(c.label), info); c.loop = l.getLoop(); } |
From: <bo...@us...> - 2003-06-10 19:33:05
|
Update of /cvsroot/nice/Nice/testsuite/compiler/statements/loops In directory sc8-pr-cvs1:/tmp/cvs-serv3807/testsuite/compiler/statements/loops Modified Files: break.testsuite Log Message: Handle correctly 'break' and 'continue' with unknown labels. Index: break.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/statements/loops/break.testsuite,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** break.testsuite 4 Mar 2003 17:02:53 -0000 1.2 --- break.testsuite 10 Jun 2003 19:32:57 -0000 1.3 *************** *** 35,36 **** --- 35,43 ---- for (int i = 0; i < 5; i++) continue; for (int i = 0; i < 5; i++) continue; + + /// FAIL + break /*/// FAIL HERE */ undefined_label; + + /// FAIL + for(;;) + continue /*/// FAIL HERE */ undefined_label; |
From: <bo...@us...> - 2003-06-10 16:03:54
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang In directory sc8-pr-cvs1:/tmp/cvs-serv10235/stdlib/nice/lang Modified Files: collections.nice Log Message: Renamed some methods to match JDK names. Differentiate 'find*' and 'search*' methods in their names too, not just in the signature. This makes it easier to choose the "style". Index: collections.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/collections.nice,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** collections.nice 4 May 2003 16:49:38 -0000 1.47 --- collections.nice 10 Jun 2003 16:03:46 -0000 1.48 *************** *** 40,45 **** /** Modifies c, only keeping the elements for which test returns true. */ ! <T> void keep (Collection<T> c, T->boolean test) { Iterator<T> i = c.iterator(); --- 40,48 ---- + /** @deprecated */ + <T> void keep (Collection<T> c, T->boolean test) = c.retain(test); + /** Modifies c, only keeping the elements for which test returns true. */ ! <T> void retain (Collection<T> c, T->boolean test) { Iterator<T> i = c.iterator(); *************** *** 53,57 **** /** Modifies c, removing the elements for which test returns true. */ ! <T> void remove(Collection<T> c, T->boolean test) { Iterator<T> i = c.iterator(); --- 56,60 ---- /** Modifies c, removing the elements for which test returns true. */ ! <T> void remove (Collection<T> c, T->boolean test) { Iterator<T> i = c.iterator(); *************** *** 168,175 **** ****************************************************************/ ! <Any T> boolean has (java.util.List<T> s, T->boolean test) { for (int i = 0; i < s.size(); i++) ! if (test(s.get(i))) return true; --- 171,181 ---- ****************************************************************/ ! /** @deprecated */ ! <Any T> boolean has (java.util.List<T> s, T->boolean test) = s.contains(test); ! ! <Any T> boolean contains (java.util.List<T> s, T->boolean test) { for (int i = 0; i < s.size(); i++) ! if (test(s[i])) return true; *************** *** 177,189 **** } <Any T> T find (java.util.List<T> s, T->boolean test) { for (int i = 0; i < s.size(); i++) ! if (test(s.get(i))) ! return s.get(i); throw new java.util.NoSuchElementException(); } <Any T> T findLast (java.util.List<T> s, T->boolean test) { --- 183,201 ---- } + /** Find the first element that passes the given test. + @throw java.util.NoSuchElementException if there is no such element. + */ <Any T> T find (java.util.List<T> s, T->boolean test) { for (int i = 0; i < s.size(); i++) ! if (test(s[i])) ! return s[i]; throw new java.util.NoSuchElementException(); } + /** Find the last element that passes the given test. + @throw java.util.NoSuchElementException if there is no such element. + */ <Any T> T findLast (java.util.List<T> s, T->boolean test) { *************** *** 195,211 **** } ! <Any T> ?T find (java.util.List<!T> s, !T->boolean test) { for (int i = 0; i < s.size(); i++) ! if (test(s.get(i))) ! return s.get(i); return null; } ! <Any T> int findIndex (List<T> s, T->boolean test) { for (int i = 0; i < s.size(); i++) ! if (test(s.get(i))) return i; --- 207,241 ---- } ! /** Find the first element that passes the given test. ! Returns <code>null</code> if there is no such element. ! */ ! <Any T> ?T search (java.util.List<!T> s, !T->boolean test) { for (int i = 0; i < s.size(); i++) ! if (test(s[i])) ! return s[i]; return null; } ! /** Find the last element that passes the given test. ! Returns <code>null</code> if there is no such element. ! */ ! <Any T> ?T searchLast (java.util.List<!T> s, !T->boolean test) ! { ! for (int i = s.size(); --i >= 0;) ! if (test(s[i])) ! return s[i]; ! ! return null; ! } ! ! /** @deprecated */ ! <Any T> int findIndex (List<T> s, T->boolean test) = s.findIndex(test); ! ! <Any T> int indexOf (List<T> s, T->boolean test) { for (int i = 0; i < s.size(); i++) ! if (test(s[i])) return i; *************** *** 216,220 **** { for (int i = 0; i < s.size(); i++) ! if (s.get(i)) return true; --- 246,250 ---- { for (int i = 0; i < s.size(); i++) ! if (s[i]) return true; *************** *** 227,232 **** for(int i = 0; i < s.size(); i++) ! if (s.get(i) > res) ! res = s.get(i); return res; --- 257,262 ---- for(int i = 0; i < s.size(); i++) ! if (s[i] > res) ! res = s[i]; return res; |
From: <bo...@us...> - 2003-06-10 15:51:56
|
Update of /cvsroot/nice/Nice/regtest/basic In directory sc8-pr-cvs1:/tmp/cvs-serv3806/regtest/basic Modified Files: native.nice Log Message: Typo. Index: native.nice =================================================================== RCS file: /cvsroot/nice/Nice/regtest/basic/native.nice,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** native.nice 9 Sep 2002 13:03:05 -0000 1.12 --- native.nice 10 Jun 2003 15:51:52 -0000 1.13 *************** *** 47,51 **** // Tests creation of an array with a native type component. ! // java.lang.Void is exotic anough so that it has not been loaded in a previous package // (nice.lang), so that we check that this specific situation works. Array<?java.lang.Void> noVoids() = new java.lang.Void[0]; --- 47,51 ---- // Tests creation of an array with a native type component. ! // java.lang.Void is exotic enough so that it has not been loaded in a previous package // (nice.lang), so that we check that this specific situation works. Array<?java.lang.Void> noVoids() = new java.lang.Void[0]; |
From: <bo...@us...> - 2003-06-10 09:35:44
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv18173/src/bossa/syntax Modified Files: SuperExp.java Log Message: Fix the type of super, when the super implementation is written in Nice, and does not dispatch on all positions. Index: SuperExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/SuperExp.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** SuperExp.java 9 Jun 2003 22:12:31 -0000 1.10 --- SuperExp.java 10 Jun 2003 09:35:40 -0000 1.11 *************** *** 14,18 **** import bossa.link.*; - import bossa.util.*; import gnu.expr.*; import gnu.bytecode.*; --- 14,17 ---- *************** *** 26,29 **** --- 25,31 ---- import mlsub.typing.AtomicConstraint; + import bossa.util.*; + import java.util.*; + /** A call to the next most specific implementation of a metohd. *************** *** 164,179 **** { AtomicConstraint[] oldAtoms = c.atoms(); ! AtomicConstraint[] newAtoms; ! if (oldAtoms != null) { ! newAtoms = new AtomicConstraint[oldAtoms.length + p.length]; ! System.arraycopy(oldAtoms, 0, newAtoms, 0, oldAtoms.length); ! } else ! newAtoms = new AtomicConstraint[p.length]; for (int i = 0; i < p.length; i++) ! newAtoms[newAtoms.length - 1 - i] = new TypeConstructorLeqMonotypeCst(p[i].tc, m[i]); ! return new Constraint(c.binders(), newAtoms); } --- 166,187 ---- { AtomicConstraint[] oldAtoms = c.atoms(); ! ! List newAtoms; ! if (oldAtoms == null) ! newAtoms = new ArrayList(p.length); else ! { ! newAtoms = new ArrayList(oldAtoms.length + p.length); ! newAtoms.addAll(Arrays.asList(oldAtoms)); ! } for (int i = 0; i < p.length; i++) ! if (p[i].tc != null) ! newAtoms.add(new TypeConstructorLeqMonotypeCst(p[i].tc, m[i])); ! AtomicConstraint[] atoms = (AtomicConstraint[]) ! newAtoms.toArray(new AtomicConstraint[newAtoms.size()]); ! ! return new Constraint(c.binders(), atoms); } |
From: <bo...@us...> - 2003-06-10 09:35:43
|
Update of /cvsroot/nice/Nice/testsuite/compiler/methods In directory sc8-pr-cvs1:/tmp/cvs-serv18173/testsuite/compiler/methods Modified Files: super.testsuite Log Message: Fix the type of super, when the super implementation is written in Nice, and does not dispatch on all positions. Index: super.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/methods/super.testsuite,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** super.testsuite 9 Jun 2003 22:12:29 -0000 1.6 --- super.testsuite 10 Jun 2003 09:35:39 -0000 1.7 *************** *** 206,207 **** --- 206,218 ---- add(a@A, b) = super; + + /// PASS + /// Toplevel + class B { + Vector<A<B>> v = new Vector( 1 ); + } + + abstract class A<T> extends AbstractSet<T> { T x; } + + add(a@A, b) = false; + add(a@A, b@B) = super; |
From: <bo...@us...> - 2003-06-09 22:23:00
|
Update of /cvsroot/nice/Nice/regtest/basic In directory sc8-pr-cvs1:/tmp/cvs-serv19566/regtest/basic Modified Files: exceptions.nice Log Message: notNull throws an assertion error when assertions are checked. Index: exceptions.nice =================================================================== RCS file: /cvsroot/nice/Nice/regtest/basic/exceptions.nice,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** exceptions.nice 21 Oct 2002 17:09:23 -0000 1.10 --- exceptions.nice 9 Jun 2003 22:22:57 -0000 1.11 *************** *** 23,26 **** --- 23,29 ---- println("NullPointerException"); } + catch(nice.lang.AssertionFailed e){ + println("NullPointerException"); + } try{ |
From: <bo...@us...> - 2003-06-09 22:12:34
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv14791/src/bossa/syntax Modified Files: SuperExp.java Log Message: Handle polymorphic methods where super was defined in a Java superclass (closes #750422). Index: SuperExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/SuperExp.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SuperExp.java 5 Jun 2003 16:06:03 -0000 1.9 --- SuperExp.java 9 Jun 2003 22:12:31 -0000 1.10 *************** *** 18,21 **** --- 18,22 ---- import gnu.bytecode.*; import mlsub.typing.*; + import nice.tools.code.Types; import mlsub.typing.Polytype; *************** *** 132,145 **** else { ! TypeConstructor superTC = findTCforClass ! (currentMethod.firstArgument(), ! superMethod.getDeclaringClass()); if (superTC == null) { - // This probably means that super comes from a special - // class that is not in the Nice hierarchy, like - // java.lang.Object (because of variances). - // Our safe bet is to assert that the argument is // above Object --- 133,144 ---- else { ! TypeConstructor superTC = null; ! try { ! superTC = Types.typeConstructor(superMethod.getDeclaringClass()); ! } ! catch(Types.NotIntroducedClassException ex ) {} if (superTC == null) { // Our safe bet is to assert that the argument is // above Object *************** *** 177,193 **** return new Constraint(c.binders(), newAtoms); - } - - private static TypeConstructor findTCforClass(TypeConstructor tc, - ClassType t) - { - if (nice.tools.code.Types.get(tc) == t) - return tc; - - TypeConstructor superClass = ClassDefinition.get(tc).getSuperClass(); - if (superClass != null) - return findTCforClass(superClass, t); - - return null; } --- 176,179 ---- |
From: <bo...@us...> - 2003-06-09 22:12:34
|
Update of /cvsroot/nice/Nice/testsuite/compiler/methods In directory sc8-pr-cvs1:/tmp/cvs-serv14791/testsuite/compiler/methods Modified Files: super.testsuite Log Message: Handle polymorphic methods where super was defined in a Java superclass (closes #750422). Index: super.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/methods/super.testsuite,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** super.testsuite 18 Apr 2003 14:50:17 -0000 1.5 --- super.testsuite 9 Jun 2003 22:12:29 -0000 1.6 *************** *** 200,201 **** --- 200,207 ---- foo() = super; } + + /// PASS + /// Toplevel + abstract class A<B> extends AbstractSet<B> { } + + add(a@A, b) = super; |
From: <bo...@us...> - 2003-06-06 22:46:25
|
Update of /cvsroot/nice/Nice/web In directory sc8-pr-cvs1:/tmp/cvs-serv22625/web Modified Files: roadmap.xml Log Message: Roadmap for 1.0 Index: roadmap.xml =================================================================== RCS file: /cvsroot/nice/Nice/web/roadmap.xml,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** roadmap.xml 30 May 2003 11:38:29 -0000 1.6 --- roadmap.xml 6 Jun 2003 22:46:22 -0000 1.7 *************** *** 16,32 **** requesting that some feature should be given a higher priority because you need them more and proposing new features. ! These discussions can take place on ! <ulink url="http://sourceforge.net/forum/?group_id=12788">the forums</ulink>, ! on <ulink url="http://sourceforge.net/mail/?group_id=12788">the mailing list ! </ulink> ! or <ulink url="mailto:bo...@us...">privately</ulink> ! (the first two are prefered). ! </para> ! ! <para> ! <!-- The current stable version is 0.6, released July 11th, 2002. --> ! The latest version is 0.7.9, released May 6th, 2003. ! It includes all the planned features for version 0.8, which should be ! released real soon now! </para> --- 16,21 ---- requesting that some feature should be given a higher priority because you need them more and proposing new features. ! Each feature should have a link, which leads to a Wiki page where ! it is possible to discuss its design and its implementation. </para> *************** *** 36,47 **** <listitem> <para> ! Implement <ulink ! url="http://nice.sourceforge.net/cgi-bin/twiki/view/Dev/VisibilityModifiers"> ! visibility modifiers</ulink> (private, default, public). Improve the <ulink url="http://nice.sourceforge.net/cgi-bin/twiki/view/Dev/NiceConstructors"> support for object creation</ulink>, besides automatic constructors. ! A plugin to write Nice programs in <ulink url="http://www.eclipse.org"> ! Eclipse</ulink> will likely be included. Finish a first version of the <ulink url="manual.html">User's manual</ulink>. </para> --- 25,51 ---- <listitem> <para> ! Improve the <ulink url="http://nice.sourceforge.net/cgi-bin/twiki/view/Dev/NiceConstructors"> support for object creation</ulink>, besides automatic constructors. ! ! Add <ulink ! url="http://nice.sourceforge.net/cgi-bin/twiki/view/Dev/EnumImplementation"> ! enumerations</ulink> to the language. ! ! Implement <ulink ! url="http://nice.sourceforge.net/cgi-bin/twiki/view/Dev/VisibilityModifiers"> ! visibility modifiers</ulink> (private, default, public). ! ! <ulink url="http://nice.sourceforge.net/cgi-bin/twiki/view/Dev/StandardLibrary"> ! Improve and document the standard library <literal>nice.lang</literal></ulink>. ! ! </para> ! <para> ! A <ulink ! url="http://nice.sourceforge.net/cgi-bin/twiki/view/Dev/EclipsePlugin"> ! plugin</ulink> to write Nice programs in <ulink url="http://www.eclipse.org"> ! Eclipse</ulink> will also be included. ! Finish a first version of the <ulink url="manual.html">User's manual</ulink>. </para> *************** *** 49,62 **** <para> This will be the first official stable release of the language. ! With the above features, the language is rich enough to compete with Java 1.4 ! in every aspect. ! This will be the time for more widespread publicity. ! <ulink url="mailto:bo...@us...">What are the best places ! to announce Nice ? Tell me !</ulink> </para> </listitem> </varlistentry> ! <varlistentry><term>0.8 (done)</term> <listitem> <para> --- 53,64 ---- <para> This will be the first official stable release of the language. ! This will be the time for ! <ulink url="http://nice.sourceforge.net/cgi-bin/twiki/view/Dev/AnnouncingNewReleases"> ! more widespread publicity</ulink>, to which everyone is welcome to contribute. </para> </listitem> </varlistentry> ! <varlistentry><term>0.8 (released on May 29th, 2003)</term> <listitem> <para> |
From: <bo...@us...> - 2003-06-06 15:18:54
|
Update of /cvsroot/nice/Nice/testsuite/compiler/typing In directory sc8-pr-cvs1:/tmp/cvs-serv4042/testsuite/compiler/typing Modified Files: typeParameters.testsuite Log Message: Mark as 'skip'. Index: typeParameters.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/typing/typeParameters.testsuite,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** typeParameters.testsuite 3 Jun 2003 13:24:05 -0000 1.2 --- typeParameters.testsuite 6 Jun 2003 15:18:51 -0000 1.3 *************** *** 4,8 **** void f(/* /// FAIL HERE */ A) {} ! /// FAIL bug /// Toplevel class X<T> {} --- 4,8 ---- void f(/* /// FAIL HERE */ A) {} ! /// FAIL bug skip /// Toplevel class X<T> {} |
From: <bo...@us...> - 2003-06-06 15:18:21
|
Update of /cvsroot/nice/Nice/src/nice/tools/testsuite In directory sc8-pr-cvs1:/tmp/cvs-serv3853/src/nice/tools/testsuite Modified Files: TestSuite.java TestCase.java Log Message: Allow testcases to be marked as 'skip', in which case they are not run, and counted as known bugs. This is useful for bugs that take a very long time to fail, so that they don't slow down the whole suite. Index: TestSuite.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/testsuite/TestSuite.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** TestSuite.java 16 Mar 2003 19:21:44 -0000 1.14 --- TestSuite.java 6 Jun 2003 15:18:17 -0000 1.15 *************** *** 167,172 **** String type = line.substring(TestNice.KEYWORD_SIGN.length()).trim(); boolean isKnownBug = false; ! if (type.endsWith("bug")) { isKnownBug = true; --- 167,179 ---- String type = line.substring(TestNice.KEYWORD_SIGN.length()).trim(); + boolean skip = false; + if (type.endsWith(" skip")) + { + skip = true; + type = type.substring(0, type.length() - "skip".length()).trim(); + } + boolean isKnownBug = false; ! if (type.endsWith(" bug")) { isKnownBug = true; *************** *** 182,185 **** --- 189,193 ---- throw new TestSuiteException("Unknown testcase type: " + type); + res.skip = skip; res.isKnownBug = isKnownBug; return res; *************** *** 198,202 **** TestNice.cleanupTempFolder(); TestCase testCase = (TestCase)iter.next(); ! testCase.writeFiles(); testCase.performTest(); } --- 206,216 ---- TestNice.cleanupTempFolder(); TestCase testCase = (TestCase)iter.next(); ! ! if (testCase.skip) { ! testCase.fail(); ! continue; ! } ! ! testCase.writeFiles(); testCase.performTest(); } Index: TestCase.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/testsuite/TestCase.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** TestCase.java 27 Apr 2003 18:48:45 -0000 1.23 --- TestCase.java 6 Jun 2003 15:18:17 -0000 1.24 *************** *** 101,104 **** --- 101,105 ---- boolean isKnownBug; + boolean skip; |
From: <bo...@us...> - 2003-06-06 13:08:04
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang In directory sc8-pr-cvs1:/tmp/cvs-serv17427/stdlib/nice/lang Modified Files: prelude.nice booleans.nice Log Message: Now Primitive.boolTC needs to be known before any code using true or false is parsed. Therefore, it has to be defined in nice.lang/prelude.nice together with other primitive types. This works because prelude.nice is always parsed before any other file (hence the name). Index: prelude.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/prelude.nice,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** prelude.nice 16 May 2003 00:18:10 -0000 1.29 --- prelude.nice 6 Jun 2003 13:08:01 -0000 1.30 *************** *** 55,58 **** --- 55,60 ---- final class void = native; + final class boolean implements BooleanAlgebra, Comparable = native; + class Number implements Comparable = native java.lang.Number; class double extends Number = native; Index: booleans.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/booleans.nice,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** booleans.nice 4 Jun 2003 21:37:43 -0000 1.10 --- booleans.nice 6 Jun 2003 13:08:01 -0000 1.11 *************** *** 5,12 **** */ - final class boolean - implements BooleanAlgebra, Comparable - = native; - boolean `==`(boolean, boolean) = inline nice.lang.inline.BoolOp("=="); //for booleans is '!=' equal to '^' --- 5,8 ---- |
From: <bo...@us...> - 2003-06-06 13:01:18
|
Update of /cvsroot/nice/Nice In directory sc8-pr-cvs1:/tmp/cvs-serv13546 Modified Files: Makefile Log Message: Make check run the whole testsuite in one go. This makes it easier to read the results, since they are all in the last few lines. 'check_lib' can still be used to run only the library part of the testsuite. Index: Makefile =================================================================== RCS file: /cvsroot/nice/Nice/Makefile,v retrieving revision 1.118 retrieving revision 1.119 diff -C2 -d -r1.118 -r1.119 *** Makefile 3 Jun 2003 20:09:01 -0000 1.118 --- Makefile 6 Jun 2003 13:01:15 -0000 1.119 *************** *** 71,86 **** setDate: ! cd src/nice/tools/compiler; ./setBuildDate ${VERSION} ${TAG} test: cd regtest; JAVA="${java}" /usr/bin/time ./regtest ! check: check_compiler check_lib ! ! check_compiler: if [ `${java} -h 2>&1 | grep -- -enableassertions | wc -l` = 0 ]; then\ ! /usr/bin/time ${java} -Dassertions=true -classpath "classes" nice.tools.testsuite.TestNice testsuite/compiler; \ else \ ! /usr/bin/time ${java} -enableassertions -classpath "classes" nice.tools.testsuite.TestNice testsuite/compiler; \ fi --- 71,84 ---- setDate: ! cd src/nice/tools/compiler; ./setBuildDate "${VERSION}" "${TAG}" test: cd regtest; JAVA="${java}" /usr/bin/time ./regtest ! check: if [ `${java} -h 2>&1 | grep -- -enableassertions | wc -l` = 0 ]; then\ ! /usr/bin/time ${java} -Dassertions=true -classpath "classes" nice.tools.testsuite.TestNice testsuite; \ else \ ! /usr/bin/time ${java} -enableassertions -classpath "classes" nice.tools.testsuite.TestNice testsuite; \ fi |
From: <bo...@us...> - 2003-06-06 11:26:35
|
Update of /cvsroot/nice/Nice/src/nice/tools/code In directory sc8-pr-cvs1:/tmp/cvs-serv31033/src/nice/tools/code Modified Files: Gen.java Removed Files: EqualsMethodProc.java Log Message: Use PrimProcedure instead of a custom procedure class. The procedure can be shared among all calls, since it has no state. Index: Gen.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/code/Gen.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Gen.java 5 Jun 2003 23:47:23 -0000 1.13 --- Gen.java 6 Jun 2003 11:26:30 -0000 1.14 *************** *** 68,74 **** public static Expression stringEquals(String value1, Expression value2) { ! return Inline.inline(new EqualsMethodProc(), ! new gnu.expr.QuoteExp(value1, gnu.bytecode.Type.string_type), value2); } /** --- 68,78 ---- public static Expression stringEquals(String value1, Expression value2) { ! return new ApplyExp ! (equals, ! new Expression[] { new QuoteExp(value1, Type.string_type), value2 }); } + + private static final Expression equals = new QuoteExp + (new PrimProcedure(Type.pointer_type.getDeclaredMethod("equals", 1))); /** --- EqualsMethodProc.java DELETED --- |
From: <bo...@us...> - 2003-06-06 10:16:07
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv2540/src/bossa/syntax Modified Files: Pattern.java Log Message: Make string litteral patterns robust to the case where a String class is defined in the current package. Index: Pattern.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Pattern.java,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** Pattern.java 5 Jun 2003 23:47:22 -0000 1.51 --- Pattern.java 6 Jun 2003 10:16:04 -0000 1.52 *************** *** 67,71 **** if (atValue instanceof StringConstantExp) this.typeConstructor = new TypeIdent( ! new LocatedString("String" ,atValue.location())); else this.tc = atValue.tc; --- 67,71 ---- if (atValue instanceof StringConstantExp) this.typeConstructor = new TypeIdent( ! new LocatedString("java.lang.String", atValue.location())); else this.tc = atValue.tc; |
From: <bo...@us...> - 2003-06-06 10:16:07
|
Update of /cvsroot/nice/Nice/testsuite/compiler/methods In directory sc8-pr-cvs1:/tmp/cvs-serv2540/testsuite/compiler/methods Modified Files: string.testsuite Log Message: Make string litteral patterns robust to the case where a String class is defined in the current package. Index: string.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/methods/string.testsuite,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** string.testsuite 5 Jun 2003 23:47:23 -0000 1.1 --- string.testsuite 6 Jun 2003 10:16:04 -0000 1.2 *************** *** 40,41 **** --- 40,49 ---- foo("abc", "xyz") {} foo(null ,null) {} + + /// PASS + /// Toplevel + class String {} + + void foos(java.lang.String); + foos(x) {} + foos("abc") {} |
From: <bo...@us...> - 2003-06-06 10:09:08
|
Update of /cvsroot/nice/Nice/src/nice/tools/testsuite In directory sc8-pr-cvs1:/tmp/cvs-serv433/src/nice/tools/testsuite Modified Files: NiceSourceFile.java Log Message: Make the main method robust to the case where a String class is defined in the current package. Index: NiceSourceFile.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/testsuite/NiceSourceFile.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** NiceSourceFile.java 21 Feb 2003 15:17:53 -0000 1.16 --- NiceSourceFile.java 6 Jun 2003 10:09:04 -0000 1.17 *************** *** 335,339 **** writer.write("// main method");writer.newLine(); ! writer.write("void main(String[] args) {\n"); writer.write(_mainMethodContent.toString()); writer.write("}\n"); --- 335,339 ---- writer.write("// main method");writer.newLine(); ! writer.write("void main(java.lang.String[] args) {\n"); writer.write(_mainMethodContent.toString()); writer.write("}\n"); |
From: <ar...@us...> - 2003-06-05 23:47:26
|
Update of /cvsroot/nice/Nice/src/nice/tools/code In directory sc8-pr-cvs1:/tmp/cvs-serv17009/F:/nice/src/nice/tools/code Modified Files: Gen.java Added Files: EqualsMethodProc.java Log Message: Implemented dispatch on String literals. --- NEW FILE: EqualsMethodProc.java --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2000 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package nice.tools.code; import gnu.expr.*; import gnu.bytecode.*; public class EqualsMethodProc extends gnu.mapping.Procedure2 implements Inlineable { public EqualsMethodProc () {} public void compile (ApplyExp exp, Compilation comp, Target target) { Expression[] args = exp.getArgs(); CodeAttr code = comp.getCode(); args[0].compile(comp, Target.pushObject); args[1].compile(comp, Target.pushObject); code.emitInvokeVirtual(equalsMethod); target.compileFromStack(comp, Type.boolean_type); } private static final Method equalsMethod = Type.pointer_type.getDeclaredMethod("equals", 1); public gnu.bytecode.Type getReturnType (Expression[] args) { return Type.boolean_type; } public Object apply2 (Object arg1, Object arg2) { throw new Error("Not implemented"); } } Index: Gen.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/code/Gen.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Gen.java 1 May 2003 22:42:18 -0000 1.12 --- Gen.java 5 Jun 2003 23:47:23 -0000 1.13 *************** *** 66,69 **** --- 66,74 ---- } + public static Expression stringEquals(String value1, Expression value2) + { + return Inline.inline(new EqualsMethodProc(), + new gnu.expr.QuoteExp(value1, gnu.bytecode.Type.string_type), value2); + } /** |
From: <ar...@us...> - 2003-06-05 23:47:26
|
Update of /cvsroot/nice/Nice/testsuite/compiler/methods In directory sc8-pr-cvs1:/tmp/cvs-serv17009/F:/nice/testsuite/compiler/methods Added Files: string.testsuite Log Message: Implemented dispatch on String literals. --- NEW FILE: string.testsuite --- /// PASS assert(foo("abc")); /// Toplevel boolean foo(String); foo(s) = false; foo("abc") = true; foo("xyz") = false; /// PASS /// package a /// Toplevel void foo(String); foo(s) {} foo("X") {} /// package b import a ; /// FAIL /// Toplevel void foo(String); foo(s) {} foo("abc") {} foo("abc") {} /// FAIL /// Toplevel void foo(String, String); foo(s1 ,s2) {} foo("abc", s2) {} foo(s1, "xyz") {} /// PASS foo(null, null); /// Toplevel void foo(?String, ?String); foo(s1 ,s2) {} foo("abc", s2) {} foo(s1, "xyz") {} foo("abc", "xyz") {} foo(null ,null) {} |
From: <ar...@us...> - 2003-06-05 23:47:26
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1:/tmp/cvs-serv17009/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Implemented dispatch on String literals. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.180 retrieving revision 1.181 diff -C2 -d -r1.180 -r1.181 *** Parser.jj 5 Jun 2003 16:06:06 -0000 1.180 --- Parser.jj 5 Jun 2003 23:47:23 -0000 1.181 *************** *** 2225,2228 **** --- 2225,2229 ---- | res=charConstantExp() | res=booleanConstantExp() + | res=stringConstantExp() ) { return res; } |
From: <ar...@us...> - 2003-06-05 23:47:26
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv17009/F:/nice/src/bossa/syntax Modified Files: Pattern.java Log Message: Implemented dispatch on String literals. Index: Pattern.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Pattern.java,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** Pattern.java 5 Jun 2003 16:06:03 -0000 1.50 --- Pattern.java 5 Jun 2003 23:47:22 -0000 1.51 *************** *** 63,68 **** this.location = location; ! if (atValue != null) ! this.tc = atValue.tc; } --- 63,74 ---- this.location = location; ! if (atValue != null) ! { ! if (atValue instanceof StringConstantExp) ! this.typeConstructor = new TypeIdent( ! new LocatedString("String" ,atValue.location())); ! else ! this.tc = atValue.tc; ! } } *************** *** 407,410 **** --- 413,420 ---- return new Pattern(ConstantExp.makeNumber(new LocatedString( name.substring(1), Location.nowhere()))); + + if (name.charAt(0) == '\"') + return new Pattern(ConstantExp.makeString(new LocatedString( + name.substring(1,name.length()-1), Location.nowhere()))); } *************** *** 454,457 **** --- 464,470 ---- return Gen.integerComparison("Eq", parameter, atValue.longValue()); + if (atString()) + return Gen.stringEquals((String)atValue.value, parameter); + gnu.bytecode.Type ct = Types.javaType(tc); if (exactlyAt) *************** *** 495,498 **** public boolean atTrue() { return atValue != null && atValue.isTrue(); } public boolean atFalse() { return atValue != null && atValue.isFalse(); } ! } --- 508,511 ---- public boolean atTrue() { return atValue != null && atValue.isTrue(); } public boolean atFalse() { return atValue != null && atValue.isFalse(); } ! public boolean atString() { return atValue instanceof StringConstantExp; } } |
From: <ar...@us...> - 2003-06-05 16:15:15
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1:/tmp/cvs-serv15246/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Cleanup of Pattern.java and some related classes. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.179 retrieving revision 1.180 diff -C2 -d -r1.179 -r1.180 *** Parser.jj 4 Jun 2003 22:53:03 -0000 1.179 --- Parser.jj 5 Jun 2003 16:06:06 -0000 1.180 *************** *** 1200,1204 **** TypeIdent tc=null, additional = null; TypeConstructor runtimeTC = null; ! Expression val = null; boolean exactlyAt = false; Location loc = null; --- 1200,1204 ---- TypeIdent tc=null, additional = null; TypeConstructor runtimeTC = null; ! ConstantExp val = null; boolean exactlyAt = false; Location loc = null; *************** *** 1527,1531 **** /***********************************************************************/ ! Expression booleanConstantExp(): { Token t; --- 1527,1531 ---- /***********************************************************************/ ! ConstantExp booleanConstantExp(): { Token t; *************** *** 1536,1540 **** } ! Expression intConstantExp(): { LocatedString representation; --- 1536,1540 ---- } ! ConstantExp intConstantExp(): { LocatedString representation; *************** *** 1545,1549 **** } ! Expression floatConstantExp(): { LocatedString representation; --- 1545,1549 ---- } ! ConstantExp floatConstantExp(): { LocatedString representation; *************** *** 1554,1558 **** } ! Expression charConstantExp(): { Token t; --- 1554,1558 ---- } ! ConstantExp charConstantExp(): { Token t; *************** *** 2209,2216 **** } ! Expression patternLiteral() : //restricted literal for use in dispatch patterns { ! Expression res; Token t; } --- 2209,2216 ---- } ! ConstantExp patternLiteral() : //restricted literal for use in dispatch patterns { ! ConstantExp res; Token t; } |
From: <ar...@us...> - 2003-06-05 16:06:38
|
Update of /cvsroot/nice/Nice/src/bossa/link In directory sc8-pr-cvs1:/tmp/cvs-serv15246/F:/nice/src/bossa/link Modified Files: Alternative.java Dispatch.java Log Message: Cleanup of Pattern.java and some related classes. Index: Alternative.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/link/Alternative.java,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** Alternative.java 18 Apr 2003 14:50:29 -0000 1.41 --- Alternative.java 5 Jun 2003 16:06:04 -0000 1.42 *************** *** 21,24 **** --- 21,25 ---- import bossa.syntax.LocatedString; import bossa.syntax.Node; + import bossa.syntax.ConstantExp; import gnu.bytecode.*; *************** *** 116,120 **** } ! boolean matchesValuePart(long[] values, boolean[] isValue) { for(int i = 0, n = 0; i < patterns.length; i++) --- 117,121 ---- } ! boolean matchesValuePart(ConstantExp[] values, boolean[] isValue) { for(int i = 0, n = 0; i < patterns.length; i++) Index: Dispatch.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/link/Dispatch.java,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** Dispatch.java 18 Apr 2003 14:50:27 -0000 1.53 --- Dispatch.java 5 Jun 2003 16:06:05 -0000 1.54 *************** *** 289,293 **** { Alternative first = null; ! long[] values = (long[]) valit.next(); for (Iterator i = sortedTypeMatches.iterator(); i.hasNext();) { --- 289,293 ---- { Alternative first = null; ! ConstantExp[] values = (ConstantExp[]) valit.next(); for (Iterator i = sortedTypeMatches.iterator(); i.hasNext();) { *************** *** 333,337 **** } ! private static String toString(TypeConstructor[] tags, long[] values, boolean[] isValue) { StringBuffer res = new StringBuffer(); --- 333,337 ---- } ! private static String toString(TypeConstructor[] tags, ConstantExp[] values, boolean[] isValue) { StringBuffer res = new StringBuffer(); *************** *** 506,510 **** } ! /** Generate all combinations of integer values from the alternatives */ private static List generateValues(List alternatives, boolean[] isValue) --- 506,511 ---- } ! /** Generate all combinations of non boolean values from the alternatives ! * @return List<ConstantExp> */ private static List generateValues(List alternatives, boolean[] isValue) *************** *** 515,526 **** for (int pos = 0; pos < len; pos++) { ! long[] valuesAtPos = new long[alternatives.size()]; int valueCount = 0; for (Iterator i = alternatives.iterator(); i.hasNext(); ) { Pattern pat = ((Alternative)i.next()).getPatterns()[pos]; ! if (pat.atIntValue) { isValue[pos] = true; ! valuesAtPos[valueCount++] = pat.value; } } --- 516,527 ---- for (int pos = 0; pos < len; pos++) { ! ConstantExp[] valuesAtPos = new ConstantExp[alternatives.size()]; int valueCount = 0; for (Iterator i = alternatives.iterator(); i.hasNext(); ) { Pattern pat = ((Alternative)i.next()).getPatterns()[pos]; ! if (pat.atNonBoolValue()) { isValue[pos] = true; ! valuesAtPos[valueCount++] = pat.atValue; } } *************** *** 531,535 **** for (int i = 0; i < valueCount; i++) for (int j = i+1; j < valueCount; j++) ! if (valuesAtPos[i] == valuesAtPos[j]) valuesAtPos[i] = valuesAtPos[--valueCount]; --- 532,536 ---- for (int i = 0; i < valueCount; i++) for (int j = i+1; j < valueCount; j++) ! if (valuesAtPos[i].equals(valuesAtPos[j])) valuesAtPos[i] = valuesAtPos[--valueCount]; *************** *** 537,541 **** for (int i = 0; i < valueCount; i++) { ! long[] arr2 = new long[len]; arr2[pos] = valuesAtPos[i]; res.add(arr2); --- 538,542 ---- for (int i = 0; i < valueCount; i++) { ! ConstantExp[] arr2 = new ConstantExp[len]; arr2[pos] = valuesAtPos[i]; res.add(arr2); *************** *** 545,552 **** for (Iterator it = values.iterator(); it.hasNext(); ) { ! long[] arr = (long[])it.next(); for (int i = 0; i < valueCount; i++) { ! long[] arr2 = new long[len]; System.arraycopy(arr,0,arr2,0,len); arr2[pos] = valuesAtPos[i]; --- 546,553 ---- for (Iterator it = values.iterator(); it.hasNext(); ) { ! ConstantExp[] arr = (ConstantExp[])it.next(); for (int i = 0; i < valueCount; i++) { ! ConstantExp[] arr2 = new ConstantExp[len]; System.arraycopy(arr,0,arr2,0,len); arr2[pos] = valuesAtPos[i]; |
From: <ar...@us...> - 2003-06-05 16:06:38
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv15246/F:/nice/src/bossa/syntax Modified Files: ConstantExp.java NullExp.java Pattern.java SuperExp.java analyse.nice Log Message: Cleanup of Pattern.java and some related classes. Index: ConstantExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/ConstantExp.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** ConstantExp.java 4 Jun 2003 21:37:43 -0000 1.40 --- ConstantExp.java 5 Jun 2003 16:06:01 -0000 1.41 *************** *** 31,38 **** } ! ConstantExp(Polytype type, Object value, String representation, Location location) { this.type = type; this.value = value; this.representation = representation; --- 31,39 ---- } ! ConstantExp(Polytype type, TypeConstructor tc, Object value, String representation, Location location) { this.type = type; + this.tc = tc; this.value = value; this.representation = representation; *************** *** 44,48 **** { this(new Polytype(Monotype.sure(new MonotypeConstructor(tc,null))), ! value, representation, location); } --- 45,49 ---- { this(new Polytype(Monotype.sure(new MonotypeConstructor(tc,null))), ! tc, value, representation, location); } *************** *** 61,65 **** ****************************************************************/ ! public gnu.expr.Expression compile() { if(value == null) --- 62,66 ---- ****************************************************************/ ! protected gnu.expr.Expression compile() { if(value == null) *************** *** 73,77 **** protected Object value; private String representation; ! public String toString() { --- 74,79 ---- protected Object value; private String representation; ! public TypeConstructor tc; ! public String toString() { *************** *** 83,87 **** ****************************************************************/ ! public static Expression makeChar(LocatedString value) { String s = value.toString(); --- 85,89 ---- ****************************************************************/ ! public static ConstantExp makeChar(LocatedString value) { String s = value.toString(); *************** *** 130,137 **** } ! private static Expression makeInt(long value, boolean isLong, Location location) { Polytype type; Number object; --- 132,140 ---- } ! private static ConstantExp makeInt(long value, boolean isLong, Location location) { Polytype type; + TypeConstructor tc; Number object; *************** *** 139,142 **** --- 142,146 ---- { type = PrimitiveType.bytePolytype; + tc = PrimitiveType.byteTC; object = new Byte((byte) value); } *************** *** 144,147 **** --- 148,152 ---- { type = PrimitiveType.shortPolytype; + tc = PrimitiveType.shortTC; object = new Short((short) value); } *************** *** 149,152 **** --- 154,158 ---- { type = PrimitiveType.intPolytype; + tc = PrimitiveType.intTC; object = new Integer((int) value); } *************** *** 154,164 **** { type = PrimitiveType.longPolytype; object = new Long(value); } ! return new ConstantExp(type, object, value+"", location); } ! public static Expression makeNumber(LocatedString representation) { String rep = representation.toString(); --- 160,171 ---- { type = PrimitiveType.longPolytype; + tc = PrimitiveType.longTC; object = new Long(value); } ! return new ConstantExp(type, tc, object, value+"", location); } ! public static ConstantExp makeNumber(LocatedString representation) { String rep = representation.toString(); *************** *** 229,233 **** } ! public static Expression makeDouble(double value, Location location) { return new ConstantExp(PrimitiveType.floatTC, new Double(value), value+"", --- 236,240 ---- } ! public static ConstantExp makeDouble(double value, Location location) { return new ConstantExp(PrimitiveType.floatTC, new Double(value), value+"", *************** *** 235,244 **** } ! public static Expression makeFloating(LocatedString representation) { return makeDouble(Double.parseDouble(representation.toString()), representation.location()); } ! public static Expression makeString(LocatedString representation) { StringConstantExp res = new StringConstantExp(representation.toString()); --- 242,251 ---- } ! public static ConstantExp makeFloating(LocatedString representation) { return makeDouble(Double.parseDouble(representation.toString()), representation.location()); } ! public static ConstantExp makeString(LocatedString representation) { StringConstantExp res = new StringConstantExp(representation.toString()); *************** *** 275,277 **** --- 282,299 ---- return value == Boolean.TRUE; } + + long longValue() + { + if (value instanceof Character) + return ((Character)value).charValue(); + + return ((Number)value).longValue(); + } + + public boolean equals(Object other) + { + return other instanceof ConstantExp && + value.equals(((ConstantExp)other).value); + } + } Index: NullExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/NullExp.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** NullExp.java 24 Sep 2002 12:08:09 -0000 1.6 --- NullExp.java 5 Jun 2003 16:06:03 -0000 1.7 *************** *** 27,31 **** */ ! public class NullExp extends Expression { /** There is only one instance of NullExp, --- 27,31 ---- */ ! public class NullExp extends ConstantExp { /** There is only one instance of NullExp, Index: Pattern.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Pattern.java,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** Pattern.java 4 Jun 2003 22:53:02 -0000 1.49 --- Pattern.java 5 Jun 2003 16:06:03 -0000 1.50 *************** *** 50,54 **** */ public Pattern(LocatedString name, ! TypeIdent tc, Expression atValue, boolean exactlyAt, TypeIdent additional, TypeConstructor runtimeTC, --- 50,54 ---- */ public Pattern(LocatedString name, ! TypeIdent tc, ConstantExp atValue, boolean exactlyAt, TypeIdent additional, TypeConstructor runtimeTC, *************** *** 63,106 **** this.location = location; ! if (atValue != null && atValue instanceof ConstantExp && ! ((ConstantExp)atValue).value instanceof Boolean ) ! { ! this.tc = PrimitiveType.boolTC; ! } ! else if (atValue != null && atValue instanceof ConstantExp) ! { ! this.atIntValue = true; ! String typeName = ""; ! Object val = ((ConstantExp)atValue).value; ! ! if (val instanceof Byte) { ! this.value = ((Byte)val).byteValue(); ! typeName = "byte"; ! } ! else if (val instanceof Short) { ! this.value = ((Short)val).shortValue(); ! typeName = "short"; ! } ! else if (val instanceof Character) { ! this.value = ((Character)val).charValue(); ! typeName = "char"; ! } ! else if (val instanceof Integer) { ! this.value = ((Integer)val).intValue(); ! typeName = "int"; ! } ! else if (val instanceof Long) { ! this.value = ((Long)val).longValue(); ! typeName = "long"; ! } ! this.typeConstructor = ! new TypeIdent(new LocatedString(typeName,location)); ! } ! ! } ! ! public Pattern(LocatedString name) ! { ! this(name, null, null, false, null, null, name.location()); } --- 63,68 ---- this.location = location; ! if (atValue != null) ! this.tc = atValue.tc; } *************** *** 110,126 **** } ! Pattern(TypeConstructor tc, Expression atValue, boolean exactlyAt) { this.tc = tc; - this.atValue = atValue; this.exactlyAt = exactlyAt; } ! Pattern(TypeConstructor tc, Expression atValue, long value) { ! this.tc = tc; ! this.atValue = atValue; ! this.value = value; ! this.atIntValue = true; } --- 72,85 ---- } ! Pattern(TypeConstructor tc, boolean exactlyAt) { this.tc = tc; this.exactlyAt = exactlyAt; } ! Pattern(ConstantExp atValue) { ! this(null, null, atValue, false, null, null, ! atValue!=null ? atValue.location() : Location.nowhere() ); } *************** *** 179,186 **** { for (int i = 0; i < monotypes.length; i++) ! { ! Pattern p = patterns[i]; ! p.leq(monotypes[i]); ! } } --- 138,142 ---- { for (int i = 0; i < monotypes.length; i++) ! patterns[i].leq(monotypes[i]); } *************** *** 198,208 **** if (atNull()) ! { ! Typing.leq(PrimitiveType.maybeTC, mc.getTC()); ! } if (tc == null) return; ! // the argument is not null Typing.leq(mc.getTC(), PrimitiveType.sureTC); --- 154,162 ---- if (atNull()) ! Typing.leq(PrimitiveType.maybeTC, mc.getTC()); if (tc == null) return; ! // the argument is not null Typing.leq(mc.getTC(), PrimitiveType.sureTC); *************** *** 239,243 **** { TypeConstructor[] res = new TypeConstructor[patterns.length]; - for (int i = 0; i < patterns.length; i++) res[i] = patterns[i].tc; --- 193,196 ---- *************** *** 249,253 **** { TypeConstructor[] res = new TypeConstructor[patterns.length]; - for (int i = 0; i < patterns.length; i++) res[i] = patterns[i].tc2; --- 202,205 ---- *************** *** 292,297 **** return that.tc == PrimitiveType.boolTC; ! if (that.atIntValue) ! return this.atIntValue && (this.value == that.value); if (this.tc == that.tc) --- 244,249 ---- return that.tc == PrimitiveType.boolTC; ! if (that.atNonBoolValue()) ! return this.atNonBoolValue() && this.atValue.equals(that.atValue); if (this.tc == that.tc) *************** *** 313,317 **** return false; ! if (atIntValue) return false; --- 265,269 ---- return false; ! if (atNonBoolValue()) return false; *************** *** 338,347 **** } ! public boolean matchesValue(long val) { if (atAny()) return true; ! return atIntValue && this.value == val; } --- 290,299 ---- } ! public boolean matchesValue(ConstantExp val) { if (atAny()) return true; ! return atNonBoolValue() && atValue.equals(val); } *************** *** 349,364 **** { // only set it to atAny if it's a @type pattern ! if (equal && atValue == null && !exactlyAt && !atIntValue) tc = null; ! // don't allow primitive types(except boolean) in @type and #type patterns ! if (!equal && !atBool() && !atIntValue && ( ! tc == PrimitiveType.longTC || ! tc == PrimitiveType.intTC || ! tc == PrimitiveType.shortTC || ! tc == PrimitiveType.charTC || ! tc == PrimitiveType.byteTC) ) User.error(location, "A pattern cannot have a primitive type that is different from the declaration."); - } --- 301,310 ---- { // only set it to atAny if it's a @type pattern ! if (equal && atValue == null && !exactlyAt) tc = null; ! // don't allow integer primitive types in @type and #type patterns ! if (!equal && atValue == null && Typing.testRigidLeq(tc, PrimitiveType.longTC)) User.error(location, "A pattern cannot have a primitive type that is different from the declaration."); } *************** *** 369,398 **** public String toString() { ! if (atNull()) ! return "null"; if (atAny()) return "@_"; ! if (atBool()) ! return atValue.toString(); ! if (atIntValue) ! return "@" + atValue.toString(); StringBuffer res = new StringBuffer(); if (name != null) ! res.append(name.toString()); res.append(exactlyAt ? '#' : '@'); if (typeConstructor != null) ! res.append(typeConstructor.toString()); else if (tc != null) ! res.append(tc.toString()); return res.toString(); } ! public Location location() ! { ! return location; ! } /**************************************************************** --- 315,339 ---- public String toString() { ! if (atValue != null) ! return atValue.toString(); ! if (atAny()) return "@_"; ! StringBuffer res = new StringBuffer(); if (name != null) ! res.append(name); res.append(exactlyAt ? '#' : '@'); if (typeConstructor != null) ! res.append(typeConstructor); else if (tc != null) ! res.append(tc); return res.toString(); } ! public Location location() { return location; } /**************************************************************** *************** *** 410,426 **** return "@_"; ! if (atBool()) ! return "@" + atValue.toString(); ! if (atIntValue) ! if (tc == PrimitiveType.charTC) ! return "@" + atValue.toString(); ! else ! return "@" + (value >= 0 ? "+" : "") + Long.toString(value); ! return ! (exactlyAt ? "#" : "@") ! + ! (atNull() ? "NULL" : tc.toString().replace('$','.')); } --- 351,366 ---- return "@_"; ! if (atNull()) ! return "@NULL"; ! if (atValue != null) ! { ! if (atValue.value instanceof Number) ! return "@" + (atValue.longValue() >= 0 ? "+" : "") + atValue; ! return "@" + atValue; ! } ! ! return (exactlyAt ? "#" : "@") + tc.toString().replace('$','.'); } *************** *** 430,433 **** --- 370,374 ---- for(int i = 0; i < patterns.length; i++) res.append(patterns[i].bytecodeRepresentation()); + return res.toString(); } *************** *** 453,502 **** String name = rep.substring(start, pos[0]); - TypeConstructor tc = null; - Expression atValue = null; - if (name.length() > 1) { if (name.charAt(0) == '\'') ! { ! atValue = ConstantExp.makeChar(new LocatedString(name.substring(1,name.length()-1),Location.nowhere())); ! return new Pattern(PrimitiveType.charTC, atValue, ((Character)((ConstantExp)atValue).value).charValue()); ! } ! if (name.charAt(0) == '+' || name.charAt(0) == '-') ! { ! if (name.charAt(0) == '+') ! name = name.substring(1); ! Object val = ((ConstantExp)ConstantExp.makeNumber(new LocatedString(name,Location.nowhere()))).value; ! if (val instanceof Byte) ! return new Pattern(PrimitiveType.byteTC, null, ((Byte)val).byteValue()); ! if (val instanceof Short) ! return new Pattern(PrimitiveType.shortTC, null, ((Short)val).shortValue()); ! if (val instanceof Integer) ! return new Pattern(PrimitiveType.intTC, null, ((Integer)val).intValue()); ! return new Pattern(PrimitiveType.longTC, null, ((Long)val).longValue()); ! } } if (name.equals("_")) ! tc = null; ! else if (name.equals("NULL")) ! atValue = NullExp.instance; ! else if (name.equals("true") || name.equals("false") ) ! { ! atValue = ConstantExp.makeBoolean(name.equals("true"), Location.nowhere()); ! tc = PrimitiveType.boolTC; ! } ! else ! { ! mlsub.typing.TypeSymbol sym = Node.getGlobalTypeScope().lookup(name); ! if (sym == null) ! User.error("Pattern " + name + ! " of method " + methodName + ! " is not known"); ! tc = (TypeConstructor) sym; ! } ! return new Pattern(tc, atValue, exact); } --- 394,429 ---- String name = rep.substring(start, pos[0]); if (name.length() > 1) { if (name.charAt(0) == '\'') ! return new Pattern(ConstantExp.makeChar(new LocatedString( ! name.substring(1,name.length()-1), Location.nowhere()))); ! ! if (name.charAt(0) == '-') ! return new Pattern(ConstantExp.makeNumber(new LocatedString(name, ! Location.nowhere()))); ! ! if (name.charAt(0) == '+') ! return new Pattern(ConstantExp.makeNumber(new LocatedString( ! name.substring(1), Location.nowhere()))); } if (name.equals("_")) ! return new Pattern(null); ! if (name.equals("NULL")) ! return new Pattern(NullExp.instance); ! if (name.equals("true") || name.equals("false") ) ! return new Pattern(ConstantExp.makeBoolean(name.equals("true"), ! Location.nowhere())); ! ! mlsub.typing.TypeSymbol sym = Node.getGlobalTypeScope().lookup(name); ! ! if (sym == null) ! User.error("Pattern " + name + " of method " + methodName + ! " is not known"); ! ! return new Pattern((TypeConstructor) sym, exact); } *************** *** 524,544 **** } ! if (atIntValue) ! return Gen.integerComparison("Eq", parameter, value); ! ! gnu.bytecode.Type ct = nice.tools.code.Types.javaType(tc); if (exactlyAt) return Gen.isOfClass(parameter, ct); - else - /* - This is not correct if the parameter is null: - we don't want @C to match a null value - OPTIM: produce a '!is_null' in this case - */ - //if (parameter.getType().isSubtype(ct)) - //return QuoteExp.trueExp; ! return Gen.instanceOfExp(parameter, ct); } --- 451,462 ---- } ! if (atIntValue()) ! return Gen.integerComparison("Eq", parameter, atValue.longValue()); + gnu.bytecode.Type ct = Types.javaType(tc); if (exactlyAt) return Gen.isOfClass(parameter, ct); ! return Gen.instanceOfExp(parameter, ct); } *************** *** 559,569 **** private boolean exactlyAt; ! public Expression atValue; private Location location; ! public long value; ! public boolean atIntValue = false; ! public boolean atNull() { return atValue == NullExp.instance; } public boolean atAny() { return atValue == null && tc == null; } --- 477,491 ---- private boolean exactlyAt; ! public ConstantExp atValue; private Location location; ! public boolean atIntValue() { ! return atValue != null && (atValue.value instanceof Number || ! atValue.value instanceof Character); ! } ! public boolean atNonBoolValue() { ! return atValue != null && !atBool() && !atNull(); ! } public boolean atNull() { return atValue == NullExp.instance; } public boolean atAny() { return atValue == null && tc == null; } *************** *** 571,580 **** return atValue != null && tc == PrimitiveType.boolTC; } ! public boolean atTrue() { ! return atBool() && ((ConstantExp)atValue).isTrue(); ! } ! public boolean atFalse() { ! return atBool() && ((ConstantExp)atValue).isFalse(); ! } } --- 493,498 ---- return atValue != null && tc == PrimitiveType.boolTC; } ! public boolean atTrue() { return atValue != null && atValue.isTrue(); } ! public boolean atFalse() { return atValue != null && atValue.isFalse(); } } Index: SuperExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/SuperExp.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SuperExp.java 29 May 2003 14:17:19 -0000 1.8 --- SuperExp.java 5 Jun 2003 16:06:03 -0000 1.9 *************** *** 150,154 **** constraint = addLeq (type.getConstraint(), ! new Pattern[]{new Pattern(superTC, null, false)}, monotype.domain()); } --- 150,154 ---- constraint = addLeq (type.getConstraint(), ! new Pattern[]{new Pattern(superTC, false)}, monotype.domain()); } Index: analyse.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/analyse.nice,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** analyse.nice 21 May 2003 15:32:13 -0000 1.69 --- analyse.nice 5 Jun 2003 16:06:03 -0000 1.70 *************** *** 502,505 **** --- 502,507 ---- } + analyse(e@NullExp, i) = e; + analyse(c@ConstantExp, info) { |