nice-commit Mailing List for The Nice Programming Language (Page 124)
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-03-04 16:50:52
|
Update of /cvsroot/nice/Nice/src/mlsub/compilation In directory sc8-pr-cvs1:/tmp/cvs-serv26840/src/mlsub/compilation Modified Files: make.nice Module.java Log Message: Fixed compilation of packages cyclically importing each other (exhibited by some code written by Alex). Index: make.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/compilation/make.nice,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** make.nice 18 Feb 2003 23:33:09 -0000 1.19 --- make.nice 4 Mar 2003 16:50:17 -0000 1.20 *************** *** 34,37 **** --- 34,48 ---- try { + modules.foreach(Module m => m.typedResolve()); + } + finally { + notNull(compilation.root).unfreezeGlobalContext(); + } + + modules.foreach(Module m => m.localResolve()); + + notNull(compilation.root).freezeGlobalContext(); + + try { modules.foreach(Module m => m.compile()); Index: Module.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/compilation/Module.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Module.java 28 Aug 2002 09:27:40 -0000 1.4 --- Module.java 4 Mar 2003 16:50:17 -0000 1.5 *************** *** 36,39 **** --- 36,45 ---- void load(); + /** Resolve scoping for entities that need the global context. */ + void typedResolve(); + + /** Resolve local entities, that might increase the global context. */ + void localResolve(); + /** Compile the module. |
From: <bo...@us...> - 2003-03-04 16:50:51
|
Update of /cvsroot/nice/Nice/testsuite/compiler/classes/constructors In directory sc8-pr-cvs1:/tmp/cvs-serv26840/testsuite/compiler/classes/constructors Modified Files: compilation.testsuite Log Message: Fixed compilation of packages cyclically importing each other (exhibited by some code written by Alex). Index: compilation.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/classes/constructors/compilation.testsuite,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** compilation.testsuite 2 Sep 2002 16:11:34 -0000 1.1 --- compilation.testsuite 4 Mar 2003 16:50:17 -0000 1.2 *************** *** 4,5 **** --- 4,21 ---- /// Toplevel class A {} + + /// PASS + /// package a import b + /// Toplevel + class A { String name = ""; } + + /// package b import a + new A(); + + /// PASS + /// package b import a + new A(); + + /// package a import b + /// Toplevel + class A { String name = ""; } |
From: <bo...@us...> - 2003-03-04 16:50:51
|
Update of /cvsroot/nice/Nice/testsuite/compiler/methods In directory sc8-pr-cvs1:/tmp/cvs-serv26840/testsuite/compiler/methods Modified Files: super.testsuite Log Message: Fixed compilation of packages cyclically importing each other (exhibited by some code written by Alex). Index: super.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/methods/super.testsuite,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** super.testsuite 17 Sep 2002 16:30:56 -0000 1.3 --- super.testsuite 4 Mar 2003 16:50:11 -0000 1.4 *************** *** 129,132 **** --- 129,154 ---- /// PASS + /// COMMENT super defined in an imported package, with mutual import. + /// package a import b + /// Toplevel + void m(A); + m(@A) { if (false) m(new A()); } + + /// package b import a + /// Toplevel + m(@B) { super; } + + /// PASS + /// COMMENT super defined in an imported package, with mutual import. + /// package a import b + /// Toplevel + m(@B) { super; } + + /// package b import a + /// Toplevel + void m(A); + m(@A) { if (false) m(new A()); } + + /// PASS assert (new C().foo() == 1); /// Toplevel |
From: <bo...@us...> - 2003-03-04 16:50:28
|
Update of /cvsroot/nice/Nice/src/bossa/modules In directory sc8-pr-cvs1:/tmp/cvs-serv26840/src/bossa/modules Modified Files: Package.java Log Message: Fixed compilation of packages cyclically importing each other (exhibited by some code written by Alex). Index: Package.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/Package.java,v retrieving revision 1.84 retrieving revision 1.85 diff -C2 -d -r1.84 -r1.85 *** Package.java 12 Feb 2003 12:48:34 -0000 1.84 --- Package.java 4 Mar 2003 16:50:20 -0000 1.85 *************** *** 220,223 **** --- 220,233 ---- } + public void typedResolve() + { + ast.typedResolve(); + } + + public void localResolve() + { + ast.localResolve(); + } + public void compile() { |
From: <bo...@us...> - 2003-03-04 16:50:28
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv26840/src/bossa/syntax Modified Files: MethodBodyDefinition.java AST.java Log Message: Fixed compilation of packages cyclically importing each other (exhibited by some code written by Alex). Index: MethodBodyDefinition.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MethodBodyDefinition.java,v retrieving revision 1.112 retrieving revision 1.113 diff -C2 -d -r1.112 -r1.113 *** MethodBodyDefinition.java 16 Jan 2003 01:52:32 -0000 1.112 --- MethodBodyDefinition.java 4 Mar 2003 16:50:18 -0000 1.113 *************** *** 465,468 **** --- 465,469 ---- gnu.expr.ReferenceExp ref; + gnu.expr.LambdaExp compiledMethod; public gnu.expr.ReferenceExp getRefExp() *************** *** 481,498 **** public void compile() { ! if(Debug.codeGeneration) Debug.println("Compiling method body " + this); getRefExp(); } private gnu.expr.ReferenceExp compile (NiceMethod definition) { ! gnu.expr.LambdaExp lexp = createMethod(name.toString(), false); ! gnu.expr.ReferenceExp ref = module.addMethod(lexp, true); ! lexp.addBytecodeAttribute (new MiscAttr("definition", definition.getFullName().getBytes())); ! lexp.addBytecodeAttribute (new MiscAttr("patterns", Pattern.bytecodeRepresentation(formals).getBytes())); --- 482,500 ---- public void compile() { ! if (Debug.codeGeneration) Debug.println("Compiling method body " + this); getRefExp(); + Gen.setMethodBody(compiledMethod, body.generateCode()); } private gnu.expr.ReferenceExp compile (NiceMethod definition) { ! createMethod(name.toString(), false); ! gnu.expr.ReferenceExp ref = module.addMethod(compiledMethod, true); ! compiledMethod.addBytecodeAttribute (new MiscAttr("definition", definition.getFullName().getBytes())); ! compiledMethod.addBytecodeAttribute (new MiscAttr("patterns", Pattern.bytecodeRepresentation(formals).getBytes())); *************** *** 520,532 **** private void compile (JavaMethod declaration) { ! gnu.expr.LambdaExp lexp = createMethod(declaration.getName().toString(), true); // Compile as a method in the class of the first argument ! declaringClass().addJavaMethod(lexp); } ! private gnu.expr.LambdaExp createMethod (String bytecodeName, boolean member) { ! gnu.expr.LambdaExp lexp = Gen.createMethod(bytecodeName, javaArgTypes(), --- 522,534 ---- private void compile (JavaMethod declaration) { ! createMethod(declaration.getName().toString(), true); // Compile as a method in the class of the first argument ! declaringClass().addJavaMethod(compiledMethod); } ! private void createMethod (String bytecodeName, boolean member) { ! compiledMethod = Gen.createMethod(bytecodeName, javaArgTypes(), *************** *** 534,539 **** parameters, true, member); - Gen.setMethodBody(lexp, body.generateCode()); - return lexp; } --- 536,539 ---- Index: AST.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/AST.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** AST.java 12 Feb 2003 12:48:34 -0000 1.39 --- AST.java 4 Mar 2003 16:50:19 -0000 1.40 *************** *** 83,90 **** nice.tools.compiler.OutputMessages.exitIfErrors(); } ! ! public void typechecking() { Node.setModule(module); for(Iterator i = children.iterator(); i.hasNext();) { --- 83,91 ---- nice.tools.compiler.OutputMessages.exitIfErrors(); } ! ! public void typedResolve() { Node.setModule(module); + for(Iterator i = children.iterator(); i.hasNext();) { *************** *** 99,120 **** } nice.tools.compiler.OutputMessages.exitIfErrors(); ! module.unfreezeGlobalContext(); ! try{ ! for(Iterator i = children.iterator(); i.hasNext();) ! { ! Definition d = (Definition) i.next(); ! try{ ! d.resolveBody(); ! } ! catch(UserError ex){ ! nice.tools.compiler.OutputMessages.error(ex.getMessage()); ! } } ! } finally { ! module.freezeGlobalContext(); ! } nice.tools.compiler.OutputMessages.exitIfErrors(); // Classes are typechecked first, since code can depend on them. for(int i = 0; i < classes.length; i++) --- 100,130 ---- } nice.tools.compiler.OutputMessages.exitIfErrors(); + } ! public void localResolve() ! { ! Node.setModule(module); ! ! for (Iterator i = children.iterator(); i.hasNext();) ! { ! Definition d = (Definition) i.next(); ! try{ ! d.resolveBody(); } ! catch(UserError ex){ ! nice.tools.compiler.OutputMessages.error(ex.getMessage()); ! } ! } ! nice.tools.compiler.OutputMessages.exitIfErrors(); + for (int i = 0; i < classes.length; i++) + classes[i].precompile(); + } + + public void typechecking() + { + Node.setModule(module); + // Classes are typechecked first, since code can depend on them. for(int i = 0; i < classes.length; i++) *************** *** 136,142 **** public void compile(boolean generateCode) { - for(int i = 0; i < classes.length; i++) - classes[i].precompile(); - if (! generateCode) return; --- 146,149 ---- |
From: <bo...@us...> - 2003-03-03 16:42:51
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang In directory sc8-pr-cvs1:/tmp/cvs-serv20382/stdlib/nice/lang Modified Files: collections.nice Log Message: Sorting collections using an anonymous comparator. Index: collections.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/collections.nice,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** collections.nice 26 Feb 2003 19:19:37 -0000 1.45 --- collections.nice 3 Mar 2003 16:42:45 -0000 1.46 *************** *** 161,164 **** --- 161,184 ---- /**************************************************************** + * Sort + ****************************************************************/ + + /** + comparator must return a negative integer, zero, or a positive integer + as the first argument is less than, equal to, or greater than the second. + */ + <T> void sort(List<T> list, (T,T) -> int comparator) + { + Collections.sort(list, new NiceComparator(comparator: comparator)); + } + + class NiceComparator<T> implements java.util.Comparator + { + final (T,T) -> int comparator; + + compare(x, y) = (this.comparator)(x,y); + } + + /**************************************************************** * Standard operations ****************************************************************/ |
From: <bo...@us...> - 2003-03-03 16:42:48
|
Update of /cvsroot/nice/Nice/testsuite/lib/java/util In directory sc8-pr-cvs1:/tmp/cvs-serv20382/testsuite/lib/java/util Modified Files: collections.testsuite Log Message: Sorting collections using an anonymous comparator. Index: collections.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/lib/java/util/collections.testsuite,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** collections.testsuite 5 Dec 2002 16:05:39 -0000 1.4 --- collections.testsuite 3 Mar 2003 16:42:43 -0000 1.5 *************** *** 23,24 **** --- 23,33 ---- alist.add(10); alist.remove(10); + + /// PASS + int[] a = [ 1, 10, 3 ]; + a.sort((int i, int j) => j - i); + assert a[0] == 10; + + String[] s = [ "a", "aa", "aaa" ]; + s.sort((String s1, String s2) => s2.length - s1.length); + assert s[0] == "aaa"; |
From: <bo...@us...> - 2003-03-01 01:07:57
|
Update of /cvsroot/nice/Nice/src/mlsub/typing In directory sc8-pr-cvs1:/tmp/cvs-serv21265/src/mlsub/typing Modified Files: MonotypeVar.java Log Message: Added debuging info. Index: MonotypeVar.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/MonotypeVar.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** MonotypeVar.java 1 Aug 2002 00:25:32 -0000 1.13 --- MonotypeVar.java 1 Mar 2003 01:07:53 -0000 1.14 *************** *** 124,127 **** --- 124,129 ---- // Do the appropriate cast equivalent = value.freshMonotype(); + if (Typing.dbg) + Debug.println("Equivalence: " + this + " == " + equivalent); // equivalent is null if the kind is that of unconstrained variables |
From: <bo...@us...> - 2003-03-01 00:58:31
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv18080/src/bossa/syntax Modified Files: OverloadedSymbolExp.java CallExp.java Log Message: Computed expected bytecode type for actual arguments of polymorphic methods. Index: OverloadedSymbolExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/OverloadedSymbolExp.java,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** OverloadedSymbolExp.java 25 Sep 2002 16:40:26 -0000 1.48 --- OverloadedSymbolExp.java 1 Mar 2003 00:58:28 -0000 1.49 *************** *** 174,177 **** --- 174,179 ---- { VarSymbol res = (VarSymbol) symbols.get(0); + // store the formal argument types for later use together with the type + callExp.argTypes = nice.tools.code.Types.domain(res.getClonedType()); res.releaseClonedType(); Index: CallExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/CallExp.java,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** CallExp.java 24 Jan 2003 19:09:25 -0000 1.72 --- CallExp.java 1 Mar 2003 00:58:28 -0000 1.73 *************** *** 257,271 **** } ! /* ! If type is not monomorphic, simplification can result in ! a more precise result for the java type used in compilation. ! However, it is probably not perfect. setByteCodetype should be usefull. ! FIXME and test me with regtest case. ! */ if (! type.trySimplify()) User.warning(this, "This call might have a type error, or this might be a bug in the compiler. \nPlease contact bo...@us..."); - //Types.setBytecodeType(type); } boolean isAssignable() { --- 257,289 ---- } ! if (! type.isMonomorphic() && argTypes != null) ! { ! /* ! We construct the instantiated version of the function type: ! the type of the function, constrained by the actual arguments. ! Then we simplify it. ! It is useful to constrain the arguments to have the expected ! bytecode types. ! */ ! instanciatedType = new Polytype ! (type.getConstraint(), new FunType(argTypes, type.getMonotype())); ! instanciatedType = instanciatedType.cloneType(); ! // By default, a polytype is suppose to be simplified. ! instanciatedType.setNotSimplified(); ! instanciatedType.simplify(); ! } ! if (! type.trySimplify()) User.warning(this, "This call might have a type error, or this might be a bug in the compiler. \nPlease contact bo...@us..."); } + /** The types of the formal arguments of the function, in the same + polymorphic instance as the computed type. + */ + Monotype[] argTypes; + + /** The type of the function, constrained by the actual arguments. */ + private Polytype instanciatedType; + boolean isAssignable() { *************** *** 286,299 **** res = new gnu.expr.ApplyExp(function.generateCode(), compileParams()); ! gnu.bytecode.Type expectedType; ! if ("notNull".equals(function.toString())) ! { ! expectedType = Types.javaType(getType()); ! //System.out.println(this + ", " + res.getType() + "; " + expectedType + "^" + getType()); ! expectedType = Types.javaType(getType()); ! //System.out.println(this + ", " + res.getType() + "; " + expectedType + "^" + getType()); ! } ! expectedType = Types.javaType(getType()); ! return EnsureTypeProc.ensure(res, expectedType); } --- 304,308 ---- res = new gnu.expr.ApplyExp(function.generateCode(), compileParams()); ! return EnsureTypeProc.ensure(res, Types.javaType(type)); } *************** *** 313,316 **** --- 322,335 ---- } } + + // Make sure the arguments have the expected bytecode type, + // matching the instantiated type of the (polymorphic) function. + Monotype[] domain = null; + if (instanciatedType != null) + domain = Types.domain(instanciatedType); + if (domain != null) + for (int i = 0; i < params.length; i++) + params[i] = EnsureTypeProc.ensure + (params[i], Types.javaType(domain[i])); return params; |
From: <bo...@us...> - 2003-03-01 00:58:31
|
Update of /cvsroot/nice/Nice/src/mlsub/typing In directory sc8-pr-cvs1:/tmp/cvs-serv18080/src/mlsub/typing Modified Files: Polytype.java Monotype.java Log Message: Computed expected bytecode type for actual arguments of polymorphic methods. Index: Polytype.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/Polytype.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Polytype.java 5 Dec 2002 12:53:37 -0000 1.15 --- Polytype.java 1 Mar 2003 00:58:28 -0000 1.16 *************** *** 250,253 **** --- 250,258 ---- private boolean simplified = true; + public void setNotSimplified() + { + simplified = false; + } + public void simplify() { Index: Monotype.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/Monotype.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Monotype.java 7 Oct 2002 12:34:46 -0000 1.8 --- Monotype.java 1 Mar 2003 00:58:28 -0000 1.9 *************** *** 105,108 **** --- 105,117 ---- } + /** + If this monotype is functional, return its domain. + Otherwise return null. + */ + public Monotype[] domain() + { + return null; + } + /**************************************************************** * Simplification |
From: <bo...@us...> - 2003-03-01 00:58:31
|
Update of /cvsroot/nice/Nice/testsuite/compiler/expressions/tuples In directory sc8-pr-cvs1:/tmp/cvs-serv18080/testsuite/compiler/expressions/tuples Modified Files: compilation.testsuite Log Message: Computed expected bytecode type for actual arguments of polymorphic methods. Index: compilation.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/expressions/tuples/compilation.testsuite,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** compilation.testsuite 19 Nov 2002 16:27:07 -0000 1.3 --- compilation.testsuite 1 Mar 2003 00:58:27 -0000 1.4 *************** *** 18,19 **** --- 18,25 ---- assert d1 == 1; assert d2 == 2; + + /// PASS + Map<String,(int,int)> mapTest = new HashMap(); + + mapTest.put("test", (1,2)); + ?(int,int) res = mapTest.get("test"); |
From: <bo...@us...> - 2003-03-01 00:58:31
|
Update of /cvsroot/nice/Nice/src/nice/tools/code In directory sc8-pr-cvs1:/tmp/cvs-serv18080/src/nice/tools/code Modified Files: Types.java Log Message: Computed expected bytecode type for actual arguments of polymorphic methods. Index: Types.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/code/Types.java,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** Types.java 24 Jan 2003 13:18:16 -0000 1.45 --- Types.java 1 Mar 2003 00:58:28 -0000 1.46 *************** *** 641,644 **** --- 641,650 ---- } + /** @return the domain of a functional polytype with nullness marker */ + public static Monotype[] domain(Polytype type) + { + return rawType(type.getMonotype()).domain(); + } + /** @return the codomain of a functional polytype with nullness marker */ public static Monotype codomain(Polytype type) |
From: <bo...@us...> - 2003-02-28 20:52:19
|
Update of /cvsroot/nice/Nice/src/mlsub/typing In directory sc8-pr-cvs1:/tmp/cvs-serv11335/src/mlsub/typing Modified Files: TupleType.java FunType.java Log Message: Fix type simplification for arrows and tuples. Index: TupleType.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/TupleType.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TupleType.java 26 Jul 2002 16:10:46 -0000 1.5 --- TupleType.java 28 Feb 2003 20:52:12 -0000 1.6 *************** *** 91,95 **** Monotype canonify() { ! Monotype.canonify(types); return this; } --- 91,95 ---- Monotype canonify() { ! types = Monotype.canonify(types); return this; } Index: FunType.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/FunType.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** FunType.java 7 Oct 2002 12:34:46 -0000 1.8 --- FunType.java 28 Feb 2003 20:52:13 -0000 1.9 *************** *** 127,131 **** { out = out.canonify(); ! Monotype.canonify(in); return this; } --- 127,131 ---- { out = out.canonify(); ! in = Monotype.canonify(in); return this; } |
From: <bo...@us...> - 2003-02-26 19:19:42
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang In directory sc8-pr-cvs1:/tmp/cvs-serv16819/stdlib/nice/lang Modified Files: collections.nice Log Message: Added similarEmptyCollection, to factorize the creation of a collection of the same class as a given one. Used to implement map and filter. Also added filter that allows to keep a certain subtype of the collection element type. Index: collections.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/collections.nice,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** collections.nice 24 Jan 2003 12:36:47 -0000 1.44 --- collections.nice 26 Feb 2003 19:19:37 -0000 1.45 *************** *** 12,18 **** --- 12,44 ---- <Any T> void iter(java.util.Collection<T> c, T->void f) = c.foreach(f); + <java.util.Collection C, T, U> C<U> similarEmptyCollection(C<T>); + <java.util.Collection C, Any T, Any U> C<U> map(C<T>, T->U); + + // A more precise type for filter would be: + // <Collection C, T, U | T <: U> C<U> filter(C<T>, T -> boolean); + // This would allow List<A> lA = lB.filter(...) where B is a subclass of A. + <java.util.Collection C, Any T> C<T> filter(C<T>, T->boolean); + /** Return a collection containing all elements for which converter + returns a non-null value. + It is possible to retain only elemnts with a subtype of the original + element type, in which case the returned collection has that + element type. + */ + <Collection C, T, U> C<!U> filter(C<T> source, T->?U converter) + { + C<!U> res = source.similarEmptyCollection(); + source.foreach(T elem => { + ?U converted = converter(elem); + if (converted != null) + res.add(converted); + }); + return res; + } + + + /** Modifies c, only keeping the elements for which test returns true. */ <T> void keep (Collection<T> c, T->boolean test) { *************** *** 26,29 **** --- 52,56 ---- } + /** Modifies c, removing the elements for which test returns true. */ <T> void remove(Collection<T> c, T->boolean test) { *************** *** 37,43 **** } - // A more precise type for filter would be: - // <Collection C, T, U | T <: U> C<U> filter(C<T>, T -> boolean); - // This would allow List<A> lA = lB.filter(...) where B is a subclass of A. <Any T, Any U> U foldLeft(java.util.List<T> l, (U, T)->U f, U init) --- 64,67 ---- *************** *** 93,145 **** } ! map(c, f) ! { ! throw new Error("Map not implemented for " + c.getClass()); ! } ! ! map<C,T,U>(c#ArrayList, f) { ! ArrayList<U> res = new ArrayList(c.size()); c.foreach(T elem => { res.add(f(elem)); }); return res; } ! map<C,T,U>(c#java.util.Vector, f) { ! java.util.Vector<U> res = new java.util.Vector(c.size()); ! c.foreach(T elem => { res.add(f(elem)); }); return res; } ! map<C,T,U>(c#java.util.Stack, f) { ! java.util.Stack<U> res = new java.util.Stack(); ! c.foreach(T elem => { res.add(f(elem)); }); ! return res; } ! filter(c, f) { ! throw new Error("Filter not implemented for " + c.getClass()); } ! filter<C,T>(c#ArrayList, test) { ! ArrayList<T> res = new ArrayList(c.size()); ! c.foreach(T elem => { if(test(elem)) res.add(elem); }); return res; } ! filter<C,T>(c#java.util.Vector, test) { ! java.util.Vector<T> res = new java.util.Vector(c.size()); ! c.foreach(T elem => { if(test(elem)) res.add(elem); }); return res; } ! filter<C,T>(c#java.util.Stack, test) { ! java.util.Stack<T> res = new java.util.Stack(); ! c.foreach(T elem => { if(test(elem)) res.add(elem); }); return res; } --- 117,160 ---- } ! map<C,T,U>(c, f) { ! C<U> res = c.similarEmptyCollection(); c.foreach(T elem => { res.add(f(elem)); }); return res; } ! filter<C,T>(c, test) { ! C<T> res = c.similarEmptyCollection(); ! c.foreach(T elem => { if(test(elem)) res.add(elem); }); return res; } ! similarEmptyCollection(c) { ! throw new Error("The method similarEmptyCollection is not yet implemented for " + c.getClass()); } ! similarEmptyCollection<C,T,U>(c#ArrayList) { ! ArrayList<U> res = new ArrayList(c.size()); ! return res; } ! similarEmptyCollection<C,T,U>(c#LinkedList) { ! LinkedList<U> res = new LinkedList(); return res; } ! similarEmptyCollection<C,T,U>(c#java.util.Vector) { ! java.util.Vector<U> res = new java.util.Vector(c.size()); return res; } ! similarEmptyCollection<C,T,U>(c#java.util.Stack) { ! java.util.Stack<U> res = new java.util.Stack(); return res; } *************** *** 249,251 **** c.foreach(T elem => res[i++] = elem); return res; ! } \ No newline at end of file --- 264,266 ---- c.foreach(T elem => res[i++] = elem); return res; ! } |
From: <bo...@us...> - 2003-02-26 17:09:58
|
Update of /cvsroot/nice/Nice/testsuite/compiler/functions In directory sc8-pr-cvs1:/tmp/cvs-serv1298/testsuite/compiler/functions Modified Files: anonymous.testsuite Log Message: Check that the different returns in an anonymous function form build a well-formed type (fixes #693184). Index: anonymous.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/functions/anonymous.testsuite,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** anonymous.testsuite 17 Feb 2003 14:15:08 -0000 1.4 --- anonymous.testsuite 26 Feb 2003 17:09:23 -0000 1.5 *************** *** 57,58 **** --- 57,66 ---- /// package b import a ; + + /// FAIL + () -> int f = () => { + if (true) + return 1; + else + /* /// FAIL HERE */ return ""; + }; |
From: <bo...@us...> - 2003-02-26 17:09:33
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv1298/src/bossa/syntax Modified Files: typecheck.nice Function.java FunExp.java Log Message: Check that the different returns in an anonymous function form build a well-formed type (fixes #693184). Index: typecheck.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typecheck.nice,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** typecheck.nice 18 Feb 2003 23:39:44 -0000 1.50 --- typecheck.nice 26 Feb 2003 17:09:24 -0000 1.51 *************** *** 547,550 **** --- 547,553 ---- valueOf(e.expectedReturnType), notNull(e.typingException)); } + catch(Function.IncompatibleReturnType e){ + throw bossa.util.User.error(r, "The returned value is incompatible with the return type: " + e.previouslyInferredType); + } } Index: Function.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Function.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Function.java 18 Sep 2002 19:30:42 -0000 1.5 --- Function.java 26 Feb 2003 17:09:25 -0000 1.6 *************** *** 2,6 **** /* 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 */ --- 2,6 ---- /* N I C E */ /* A high-level object-oriented research language */ ! /* (c) Daniel Bonniot 2003 */ /* */ /* This program is free software; you can redistribute it and/or modify */ *************** *** 17,28 **** @version $Date$ ! @author Daniel Bonniot (d.b...@ma...) */ interface Function { /** The expected return type of this function. ! Can be null if it is not know (e.g. the type is inferred). */ mlsub.typing.Monotype getExpectedType(); --- 17,30 ---- @version $Date$ ! @author Daniel Bonniot (bo...@us...) */ + import mlsub.typing.Polytype; + interface Function { /** The expected return type of this function. ! Can be null if it is not known (e.g. the type is inferred). */ mlsub.typing.Monotype getExpectedType(); *************** *** 33,39 **** */ void checkReturnedType(mlsub.typing.Polytype returned) ! throws WrongReturnType; ! class WrongReturnType extends Exception { WrongReturnType(mlsub.typing.TypingEx typingException, --- 35,43 ---- */ void checkReturnedType(mlsub.typing.Polytype returned) ! throws ReturnTypeError; ! abstract class ReturnTypeError extends Exception {} ! ! class WrongReturnType extends ReturnTypeError { WrongReturnType(mlsub.typing.TypingEx typingException, *************** *** 46,49 **** --- 50,63 ---- mlsub.typing.TypingEx typingException; mlsub.typing.Monotype expectedReturnType; + } + + static class IncompatibleReturnType extends ReturnTypeError + { + IncompatibleReturnType(Polytype previouslyInferredType) + { + this.previouslyInferredType = previouslyInferredType; + } + + Polytype previouslyInferredType; } } Index: FunExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/FunExp.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** FunExp.java 17 Feb 2003 14:15:40 -0000 1.38 --- FunExp.java 26 Feb 2003 17:09:25 -0000 1.39 *************** *** 55,64 **** public void checkReturnedType(mlsub.typing.Polytype returned) ! throws Function.WrongReturnType { if (inferredReturnType == null) inferredReturnType = returned; else ! inferredReturnType = Polytype.union(inferredReturnType, returned); /* This is disabled, since currently default values of class fields are --- 55,70 ---- public void checkReturnedType(mlsub.typing.Polytype returned) ! throws Function.ReturnTypeError { if (inferredReturnType == null) inferredReturnType = returned; else ! { ! Polytype old = inferredReturnType; ! inferredReturnType = Polytype.union(inferredReturnType, returned); ! ! if (! inferredReturnType.trySimplify()) ! throw new FunExp.IncompatibleReturnType(old); ! } /* This is disabled, since currently default values of class fields are *************** *** 81,86 **** ! nice.tools.code.Types.isVoid(inferredReturnType)) throw User.error(this, "Missing return statement"); - - inferredReturnType.simplify(); Monotype t = new FunType(MonoSymbol.getMonotype(formals), --- 87,90 ---- |
From: <bo...@us...> - 2003-02-26 16:15:42
|
Update of /cvsroot/nice/Nice/debian In directory sc8-pr-cvs1:/tmp/cvs-serv32146/debian Modified Files: changelog Log Message: Made the order more logical, when reading from top to bottom. Index: changelog =================================================================== RCS file: /cvsroot/nice/Nice/debian/changelog,v retrieving revision 1.133 retrieving revision 1.134 diff -C2 -d -r1.133 -r1.134 *** changelog 25 Feb 2003 20:36:52 -0000 1.133 --- changelog 26 Feb 2003 16:15:37 -0000 1.134 *************** *** 1,5 **** nice (0.7.7) unstable; urgency=low ! * The '@' in '@null' patterns is deprecated, '@' should be omitted. * Method can also dispatch on integer and character literals, but there is always a default case required. An example: --- 1,9 ---- nice (0.7.7) unstable; urgency=low ! * Methods taking a boolean parameter can now dispatch on the cases ! 'true' and 'false': ! boolean not(boolean); ! not(true) = false; ! not(false) = true; * Method can also dispatch on integer and character literals, but there is always a default case required. An example: *************** *** 12,20 **** fib(2) = 1; fib(n) = fib(n-2) + fib(n-1); ! * Methods taking a boolean parameter can now dispatch on the cases ! 'true' and 'false': ! boolean not(boolean); ! not(true) = false; ! not(false) = true; * The 'fun' keyword is deprecated now, you can leave it away. * New policy for typing calls to Java methods. By default, the typing --- 16,20 ---- fib(2) = 1; fib(n) = fib(n-2) + fib(n-1); ! * The '@' in '@null' patterns is deprecated, '@' should be omitted. * The 'fun' keyword is deprecated now, you can leave it away. * New policy for typing calls to Java methods. By default, the typing |
From: <bo...@us...> - 2003-02-26 16:08:02
|
Update of /cvsroot/nice/Nice/regtest/basic In directory sc8-pr-cvs1:/tmp/cvs-serv27721/regtest/basic Modified Files: main.nice Log Message: Anonymous functions consisting of a single assignment now return void. Index: main.nice =================================================================== RCS file: /cvsroot/nice/Nice/regtest/basic/main.nice,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** main.nice 20 Feb 2003 11:16:14 -0000 1.30 --- main.nice 26 Feb 2003 16:07:58 -0000 1.31 *************** *** 78,82 **** println(""+(()=>--j)()); println(""+(()=>j++)()); ! println(""+(()=>j=2*j)()); } --- 78,82 ---- println(""+(()=>--j)()); println(""+(()=>j++)()); ! println(""+(()=>{ return j=2*j; })()); } |
From: <bo...@us...> - 2003-02-26 14:40:14
|
Update of /cvsroot/nice/Nice In directory sc8-pr-cvs1:/tmp/cvs-serv15446 Modified Files: Makefile Log Message: Use the /bin/sh shell. Index: Makefile =================================================================== RCS file: /cvsroot/nice/Nice/Makefile,v retrieving revision 1.109 retrieving revision 1.110 diff -C2 -d -r1.109 -r1.110 *** Makefile 27 Dec 2002 19:29:35 -0000 1.109 --- Makefile 26 Feb 2003 14:40:07 -0000 1.110 *************** *** 10,14 **** VERSION = ${shell expr "`head -1 debian/changelog`" : '.*(\(.*\))'} ! SHELL = /bin/zsh TOP=${PWD} --- 10,14 ---- VERSION = ${shell expr "`head -1 debian/changelog`" : '.*(\(.*\))'} ! SHELL = /bin/sh TOP=${PWD} |
From: <ar...@us...> - 2003-02-25 20:36:59
|
Update of /cvsroot/nice/Nice/debian In directory sc8-pr-cvs1:/tmp/cvs-serv20675/F:/nice/debian Modified Files: changelog Log Message: Rewrite of the pattern part of the parser there are 5 different types of patterns now: name value //value can be false, true, null, integer literal or character literal name@value @type name@type And @null patterns are still allowed but will give a warning. Index: changelog =================================================================== RCS file: /cvsroot/nice/Nice/debian/changelog,v retrieving revision 1.132 retrieving revision 1.133 diff -C2 -d -r1.132 -r1.133 *** changelog 25 Feb 2003 12:54:46 -0000 1.132 --- changelog 25 Feb 2003 20:36:52 -0000 1.133 *************** *** 1,10 **** nice (0.7.7) unstable; urgency=low * Method can also dispatch on integer and character literals, but there is always a default case required. An example: long fac(long n); ! fac(@0) = 1; ! fac(n) = n*fac(n-1); ! The '@' before a literal is optional, so the following is allowed: int fib(int n); fib(1) = 1; --- 1,11 ---- nice (0.7.7) unstable; urgency=low + * The '@' in '@null' patterns is deprecated, '@' should be omitted. * Method can also dispatch on integer and character literals, but there is always a default case required. An example: long fac(long n); ! fac(n@0) = 1; ! fac(n@long) = n*fac(n-1); ! Another example using the shorter syntax: int fib(int n); fib(1) = 1; *************** *** 14,19 **** 'true' and 'false': boolean not(boolean); ! not(@true) = false; ! not(@false) = true; * New policy for typing calls to Java methods. By default, the typing is more convenient, considering arguments as possibly null, and --- 15,21 ---- 'true' and 'false': boolean not(boolean); ! not(true) = false; ! not(false) = true; ! * The 'fun' keyword is deprecated now, you can leave it away. * New policy for typing calls to Java methods. By default, the typing is more convenient, considering arguments as possibly null, and |
From: <ar...@us...> - 2003-02-25 20:08:06
|
Update of /cvsroot/nice/Nice/testsuite/compiler/methods In directory sc8-pr-cvs1:/tmp/cvs-serv4942/F:/nice/testsuite/compiler/methods Modified Files: integer.testsuite Log Message: Rewrite of the pattern part of the parser there are 5 different types of patterns now: name value //value can be false, true, null, integer literal or character literal name@value @type name@type And @null patterns are still allowed but will give a warning. Index: integer.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/methods/integer.testsuite,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** integer.testsuite 25 Feb 2003 12:27:03 -0000 1.1 --- integer.testsuite 25 Feb 2003 20:08:02 -0000 1.2 *************** *** 3,7 **** long fac(long n); fac(n@long) = n*fac(n-1); ! fac(@1) = 1; /// PASS --- 3,7 ---- long fac(long n); fac(n@long) = n*fac(n-1); ! fac(1) = 1; /// PASS *************** *** 9,14 **** int fib(int n); fib(n@int) = fib(n-2) + fib(n-1); ! fib(@1) = 1; ! fib(@2) = 1; /// FAIL --- 9,14 ---- int fib(int n); fib(n@int) = fib(n-2) + fib(n-1); ! fib(1) = 1; ! fib(2) = 1; /// FAIL *************** *** 16,21 **** int ack(int x, int y); // missing (0,0) case ! ack(@0, y@int) = y+1; ! ack(x@int, @0) = ack(x-1, 1); ack(x@int, y@int) = ack(x-1, ack(x, y-1)); --- 16,21 ---- int ack(int x, int y); // missing (0,0) case ! ack(0, y@int) = y+1; ! ack(x@int, 0) = ack(x-1, 1); ack(x@int, y@int) = ack(x-1, ack(x, y-1)); *************** *** 25,31 **** String toStr(char); toStr(@char) = ""; ! toStr(@'a') = "a"; ! toStr(@'b') = "b"; ! toStr(@'a') = "a"; /// PASS --- 25,31 ---- String toStr(char); toStr(@char) = ""; ! toStr('a') = "a"; ! toStr('b') = "b"; ! toStr('a') = "a"; /// PASS *************** *** 35,41 **** int bar(int); bar(n@int) = n; ! bar(@-1) = 1; ! bar(@-12389) = 12389; ! bar(@3920) = -3920; /// package b import a --- 35,41 ---- int bar(int); bar(n@int) = n; ! bar(-1) = 1; ! bar(-12389) = 12389; ! bar(3920) = -3920; /// package b import a *************** *** 47,51 **** void foo(char); foo(@char) {} ! foo(@'a') {} /// package b import a --- 47,51 ---- void foo(char); foo(@char) {} ! foo('a') {} /// package b import a *************** *** 56,75 **** // The default case is missing void foo(short); ! foo(@0) {} ! foo(@1) {} /// PASS /// Toplevel - // literals without @ int fib(int n); fib(n) = fib(n-2) + fib(n-1); ! fib(1) = 1; ! fib(2) = 1; /// PASS /// Toplevel - // literals without @ String toStr(char); ! toStr(@char) = ""; ! toStr('a') = "a"; ! toStr('b') = "b"; --- 56,73 ---- // The default case is missing void foo(short); ! foo(0) {} ! foo(1) {} /// PASS /// Toplevel int fib(int n); fib(n) = fib(n-2) + fib(n-1); ! fib(n@1) = 1; ! fib(n@2) = 1; /// PASS /// Toplevel String toStr(char); ! toStr(c@char) = ""; ! toStr(c@'a') = "a"; ! toStr(c@'b') = "b"; |
From: <ar...@us...> - 2003-02-25 20:08:06
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1:/tmp/cvs-serv4942/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Rewrite of the pattern part of the parser there are 5 different types of patterns now: name value //value can be false, true, null, integer literal or character literal name@value @type name@type And @null patterns are still allowed but will give a warning. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.144 retrieving revision 1.145 diff -C2 -d -r1.144 -r1.145 *** Parser.jj 25 Feb 2003 12:19:34 -0000 1.144 --- Parser.jj 25 Feb 2003 20:08:00 -0000 1.145 *************** *** 1190,1226 **** Pattern pattern(): { ! Pattern res = null; ! Expression val = null; ! LocatedString i; ! } ! { ! ( res = anonymousPattern(null) ! | val = patternLiteral() { res = new Pattern(null,null,val,false,null,null,val.location()); } ! | i = ident() ! ( res = anonymousPattern(i) | { res = new Pattern(i); } ) ! ) ! { return res; } ! } ! ! Pattern anonymousPattern(LocatedString name): ! { TypeIdent tc=null, additional = null; Monotype type=null; Expression val = null; boolean exactlyAt = false; ! Token t; } { ! ( ! t="@" ( val=patternLiteral() | tc=typeIdent() ) ! | ! t="#" tc=typeIdent() { exactlyAt = true; } ) ! [ "(" additional = typeIdent() ")" ] [ ":" type=monotype() ] ! { ! Location loc = name != null ? name.location() ! : tc != null ? tc.location() : new Location(t); ! return new Pattern(name, tc, val, exactlyAt, additional, type, loc); } } --- 1190,1240 ---- Pattern pattern(): { ! LocatedString name = null; ! Token t; TypeIdent tc=null, additional = null; Monotype type=null; Expression val = null; boolean exactlyAt = false; ! Location loc = null; } { ! ( ! val=patternLiteral() { loc = val.location(); } ! | ! ( ! t="@" ! | ! t="#" { exactlyAt = true;} ! ) ! ( ! tc=typeIdent() { loc = tc.location(); } ! | ! //temporarily added to warn the user about the deprecated '@null' syntax. ! t="null" ! { val = NullExp.instance; ! loc = new Location(t); ! User.warning(loc,"The '@null' syntax is deprecated, leave the '@' away."); ! } ! ) ! | ! name = ident() ! ( ! t ="@" ! ( ! val=patternLiteral() ! | ! tc=typeIdent() ! ) ! | ! t ="#" tc=typeIdent() { exactlyAt = true; } ! | ! {} //name only ! ) ! { loc = name.location(); } ) ! [ "(" additional=typeIdent() ")" ] [ ":" type=monotype() ] ! { ! return new Pattern(name, tc, val, exactlyAt, additional, type, loc); } } |
From: <ar...@us...> - 2003-02-25 19:52:44
|
Update of /cvsroot/nice/Nice/testsuite/compiler/methods In directory sc8-pr-cvs1:/tmp/cvs-serv30208/F:/nice/testsuite/compiler/methods Modified Files: boolean.testsuite Log Message: Make it possible to dispatch on @true and @false without the '@'. Index: boolean.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/methods/boolean.testsuite,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** boolean.testsuite 18 Feb 2003 14:21:19 -0000 1.1 --- boolean.testsuite 25 Feb 2003 19:52:37 -0000 1.2 *************** *** 16,28 **** boolean and(boolean, boolean); and(@boolean, @boolean) = false; ! and(@true, @true) = true; /// PASS /// Toplevel boolean xor(boolean, boolean); ! xor(@true, @true) = false; ! xor(@true, @false) = true; ! xor(@false, @true) = true; ! xor(@false, @false) = false; /// FAIL --- 16,28 ---- boolean and(boolean, boolean); and(@boolean, @boolean) = false; ! and(true, true) = true; /// PASS /// Toplevel boolean xor(boolean, boolean); ! xor(true, true) = false; ! xor(true, false) = true; ! xor(false, true) = true; ! xor(false, false) = false; /// FAIL *************** *** 31,42 **** // Ambiguity for the case (@true, @true) or(@true, @boolean) = true; ! or(@boolean, @true) = true; ! or(@false, @false) = false; /// FAIL /// Toplevel boolean nor(boolean, boolean); ! nor(@true, @true) = false; ! nor(@true, @false) = false; ! //nor(@false, @true) = false; // This case is missing. ! nor(@false, @false) = true; --- 31,42 ---- // Ambiguity for the case (@true, @true) or(@true, @boolean) = true; ! or(boolean, true) = true; ! or(false, false) = false; /// FAIL /// Toplevel boolean nor(boolean, boolean); ! nor(true, true) = false; ! nor(true, false) = false; ! //nor(false, true) = false; // This case is missing. ! nor(false, false) = true; |
From: <ar...@us...> - 2003-02-25 19:52:44
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv30208/F:/nice/src/bossa/syntax Modified Files: Pattern.java Log Message: Make it possible to dispatch on @true and @false without the '@'. Index: Pattern.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Pattern.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** Pattern.java 25 Feb 2003 12:30:56 -0000 1.40 --- Pattern.java 25 Feb 2003 19:52:35 -0000 1.41 *************** *** 68,88 **** this.location = location; ! if (tc != null) { ! String ident = tc.getName().toString(); ! if (ident.equals("true")) { ! this.atValue = new IdentExp(tc.getName()); this.typeConstructor = new TypeIdent(new LocatedString("boolean",location)); } ! else if (ident.equals("false")) { this.atValue = new IdentExp(tc.getName()); this.typeConstructor = new TypeIdent(new LocatedString("boolean",location)); ! } } ! else if (atValue != null && atValue instanceof ConstantExp) { this.atIntValue = true; --- 68,94 ---- this.location = location; ! if(tc == null && atValue == null && name != null) { ! String ident = name.toString(); ! if (ident.equals("true") || ident.equals("false")) { ! this.atValue = new IdentExp(name); ! this.name = null; this.typeConstructor = new TypeIdent(new LocatedString("boolean",location)); } ! } ! else if (tc != null) ! { ! String ident = tc.getName().toString(); ! if (ident.equals("true") || ident.equals("false")) { this.atValue = new IdentExp(tc.getName()); this.typeConstructor = new TypeIdent(new LocatedString("boolean",location)); ! } } ! ! if (atValue != null && atValue instanceof ConstantExp) { this.atIntValue = true; |
From: <ar...@us...> - 2003-02-25 12:54:50
|
Update of /cvsroot/nice/Nice/debian In directory sc8-pr-cvs1:/tmp/cvs-serv18136/F:/nice/debian Modified Files: changelog Log Message: Added dispatch on integer and character literals. Index: changelog =================================================================== RCS file: /cvsroot/nice/Nice/debian/changelog,v retrieving revision 1.131 retrieving revision 1.132 diff -C2 -d -r1.131 -r1.132 *** changelog 18 Feb 2003 14:21:21 -0000 1.131 --- changelog 25 Feb 2003 12:54:46 -0000 1.132 *************** *** 1,4 **** --- 1,14 ---- nice (0.7.7) unstable; urgency=low + * Method can also dispatch on integer and character literals, but there is + always a default case required. An example: + long fac(long n); + fac(@0) = 1; + fac(n) = n*fac(n-1); + The '@' before a literal is optional, so the following is allowed: + int fib(int n); + fib(1) = 1; + fib(2) = 1; + fib(n) = fib(n-2) + fib(n-1); * Methods taking a boolean parameter can now dispatch on the cases 'true' and 'false': *************** *** 24,28 **** * Faster compilation for large projects with many classes. * Bugfixes (anonymous functions inside functionals with constracts, ! typechecking loop tests, ...). -- --- 34,39 ---- * Faster compilation for large projects with many classes. * Bugfixes (anonymous functions inside functionals with constracts, ! typechecking loop tests, other fixes to reduce the difference between ! what the parser accepts and the compiler can handle, ...). -- |