nice-commit Mailing List for The Nice Programming Language (Page 64)
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...> - 2004-01-15 12:09:59
|
Update of /cvsroot/nice/Nice/testsuite/compiler/methods In directory sc8-pr-cvs1:/tmp/cvs-serv28747/testsuite/compiler/methods Modified Files: implementations.testsuite Log Message: Allow specialization on parameters of type Object. Index: implementations.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/methods/implementations.testsuite,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** implementations.testsuite 23 Dec 2003 11:30:57 -0000 1.14 --- implementations.testsuite 15 Jan 2004 12:09:53 -0000 1.15 *************** *** 122,127 **** /// PASS ! foo(new Object()); /// Toplevel ! void foo(Object o); ! foo(Object o) { } --- 122,129 ---- /// PASS ! assert foo(new Object()); ! assert !foo(""); /// Toplevel ! boolean foo(Object o); ! foo(Object o) = true; ! foo(String s) = false; |
From: <bo...@us...> - 2004-01-15 12:09:56
|
Update of /cvsroot/nice/Nice/src/mlsub/typing In directory sc8-pr-cvs1:/tmp/cvs-serv28747/src/mlsub/typing Modified Files: Typing.java Log Message: Allow specialization on parameters of type Object. Index: Typing.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/Typing.java,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** Typing.java 8 Oct 2003 22:30:11 -0000 1.32 --- Typing.java 15 Jan 2004 12:09:53 -0000 1.33 *************** *** 194,197 **** --- 194,201 ---- return; + if (isTop(m)) + // Trivially true. + return; + AtomicKind v = t.variance; if(v == null) *************** *** 585,588 **** --- 589,601 ---- } + /**************************************************************** + * Tools + ****************************************************************/ + + static boolean isTop(Monotype m) + { + return m.getKind() == TopMonotype.TopKind.instance; + } + public static boolean dbg; } |
From: <ar...@us...> - 2003-12-31 22:37:02
|
Update of /cvsroot/nice/Nice/src/nice/tools/compiler/console In directory sc8-pr-cvs1:/tmp/cvs-serv12865/F:/nice/src/nice/tools/compiler/console Modified Files: main.nice Log Message: Maked the --native-compiler option visible. Index: main.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/compiler/console/main.nice,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** main.nice 10 Dec 2003 19:29:05 -0000 1.6 --- main.nice 31 Dec 2003 22:36:59 -0000 1.7 *************** *** 119,123 **** "file", String file => { compilation.runtimeFile = file; }), ! option("native-compiler", visible: false, "Location of the native compiler binary (gcj)", "file", --- 119,124 ---- "file", String file => { compilation.runtimeFile = file; }), ! ! option("native-compiler", "Location of the native compiler binary (gcj)", "file", |
From: <bo...@us...> - 2003-12-23 11:47:05
|
Update of /cvsroot/nice/Nice In directory sc8-pr-cvs1:/tmp/cvs-serv17811 Modified Files: NEWS Log Message: Dispatch on Object. Index: NEWS =================================================================== RCS file: /cvsroot/nice/Nice/NEWS,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** NEWS 17 Dec 2003 16:08:18 -0000 1.10 --- NEWS 23 Dec 2003 11:47:02 -0000 1.11 *************** *** 7,11 **** 'loop(5, () => { doSomeThing(); });' * Bug fixes (checking of local variables in a call position, make it possible ! to use new Object() again, ... ) -- --- 7,12 ---- 'loop(5, () => { doSomeThing(); });' * Bug fixes (checking of local variables in a call position, make it possible ! to use new Object() and dispatch on Object again, ... ) ! -- |
From: <bo...@us...> - 2003-12-23 11:31:49
|
Update of /cvsroot/nice/Nice/web In directory sc8-pr-cvs1:/tmp/cvs-serv15755/web Modified Files: language.html Log Message: Use the new syntax for method dispatch. Index: language.html =================================================================== RCS file: /cvsroot/nice/Nice/web/language.html,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** language.html 30 May 2003 12:06:07 -0000 1.20 --- language.html 23 Dec 2003 11:31:46 -0000 1.21 *************** *** 61,70 **** <b>implementations</b> for method <tt>display</tt>: <PRE> ! <FONT COLOR="#cd0000">display</FONT>(p<FONT COLOR="#0000ee">@</FONT><FONT COLOR="#b7860b">Person</FONT>) { <FONT COLOR="#0000ee">return</FONT> p.name + <FONT COLOR="#a020f0">" (age="</FONT> + p.age + <FONT COLOR="#a020f0">")"</FONT>; } ! <FONT COLOR="#cd0000">display</FONT>(p<FONT COLOR="#0000ee">@</FONT><FONT COLOR="#b7860b">Worker</FONT>) { <FONT COLOR="#0000ee">return</FONT> p.name + <FONT COLOR="#a020f0">" (age+"</FONT> + p.age + <FONT COLOR="#a020f0">", salary="</FONT> + p.salary + <FONT COLOR="#a020f0">")"</FONT>; --- 61,70 ---- <b>implementations</b> for method <tt>display</tt>: <PRE> ! <FONT COLOR="#cd0000">display</FONT>(<FONT COLOR="#b7860b">Person</FONT> p) { <FONT COLOR="#0000ee">return</FONT> p.name + <FONT COLOR="#a020f0">" (age="</FONT> + p.age + <FONT COLOR="#a020f0">")"</FONT>; } ! <FONT COLOR="#cd0000">display</FONT>(<FONT COLOR="#b7860b">Worker</FONT> p) { <FONT COLOR="#0000ee">return</FONT> p.name + <FONT COLOR="#a020f0">" (age+"</FONT> + p.age + <FONT COLOR="#a020f0">", salary="</FONT> + p.salary + <FONT COLOR="#a020f0">")"</FONT>; *************** *** 124,128 **** } ! <font color="#CD0000">equals</font>(p1<font color="#0000EE">@</font><font color="#B7860B">Person</font>, p2<font color="#0000EE">@</font><font color="#B7860B">Person</font>) = p1.name.equals(p2.name) && p1.age==p2.age;</pre> --- 124,128 ---- } ! <font color="#CD0000">equals</font>(<font color="#B7860B">Person</font> p1, <font color="#B7860B">Person</font> p2) = p1.name.equals(p2.name) && p1.age==p2.age;</pre> *************** *** 386,391 **** <li> ! <b>Functional-like syntax for method implementations</b>. One can write <tt>f(x@P) ! = e; </tt>as an equivalent form for <tt>f(x@p) { return e; }</tt>. This is very handy when defining methods that return simple values, depending on the type of the argument -- that is doing <i>pattern-matching</i>.</li> --- 386,391 ---- <li> ! <b>Functional-like syntax for method implementations</b>. One can write <tt>f(P x) ! = e; </tt>as an equivalent form for <tt>f(P x) { return e; }</tt>. This is very handy when defining methods that return simple values, depending on the type of the argument -- that is doing <i>pattern-matching</i>.</li> |
From: <bo...@us...> - 2003-12-23 11:31:01
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv15643/src/bossa/syntax Modified Files: Pattern.java Log Message: Restore the ability to dispatch on Object. Index: Pattern.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Pattern.java,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** Pattern.java 23 Dec 2003 10:20:40 -0000 1.76 --- Pattern.java 23 Dec 2003 11:30:58 -0000 1.77 *************** *** 124,131 **** if (typeConstructor != null) { ! mlsub.typing.TypeSymbol sym = ! typeConstructor.resolveToTypeSymbol(scope); ! if (sym instanceof TypeConstructor) tc = (TypeConstructor) sym; else --- 124,134 ---- if (typeConstructor != null) { ! TypeSymbol sym = typeConstructor.resolveToTypeSymbol(scope); ! if (sym == TopMonotype.instance) ! { ! // This is @Object, which is always true, nothing to test. ! } ! else if (sym instanceof TypeConstructor) tc = (TypeConstructor) sym; else |
From: <bo...@us...> - 2003-12-23 11:31:01
|
Update of /cvsroot/nice/Nice/testsuite/compiler/methods In directory sc8-pr-cvs1:/tmp/cvs-serv15643/testsuite/compiler/methods Modified Files: implementations.testsuite Log Message: Restore the ability to dispatch on Object. Index: implementations.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/methods/implementations.testsuite,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** implementations.testsuite 8 Oct 2003 22:37:05 -0000 1.13 --- implementations.testsuite 23 Dec 2003 11:30:57 -0000 1.14 *************** *** 120,121 **** --- 120,127 ---- f(x@A) = x.i; f(null) = 0; + + /// PASS + foo(new Object()); + /// Toplevel + void foo(Object o); + foo(Object o) { } |
From: <bo...@us...> - 2003-12-23 11:30:11
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv15523/src/bossa/syntax Modified Files: JavaClasses.java Log Message: Do not cache the object constructor across restarts of the compiler, since that would make its type invalid. Index: JavaClasses.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/JavaClasses.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** JavaClasses.java 16 Dec 2003 12:34:33 -0000 1.43 --- JavaClasses.java 23 Dec 2003 11:30:07 -0000 1.44 *************** *** 212,215 **** --- 212,216 ---- retyped = new HashMap(); knownMethods = new HashMap(); + objectConstructor = null; } |
From: <bo...@us...> - 2003-12-23 10:20:43
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv4805/src/bossa/syntax Modified Files: TypeIdent.java Pattern.java Log Message: Better localize specific error reporting where it belongs. Index: TypeIdent.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/TypeIdent.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** TypeIdent.java 22 Dec 2003 20:28:10 -0000 1.27 --- TypeIdent.java 23 Dec 2003 10:20:40 -0000 1.28 *************** *** 112,125 **** } - public mlsub.typing.TypeConstructor resolveToTCForPattern(TypeMap scope) - { - TypeSymbol res = scope.lookup(name); - - if (res instanceof TypeConstructor) - return (TypeConstructor) res; - - throw User.error(this, this + " is not a declared class or interface"); - } - public TypeSymbol resolvePreferablyToItf(TypeMap scope) { --- 112,115 ---- Index: Pattern.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Pattern.java,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -d -r1.75 -r1.76 *** Pattern.java 23 Oct 2003 18:43:37 -0000 1.75 --- Pattern.java 23 Dec 2003 10:20:40 -0000 1.76 *************** *** 15,18 **** --- 15,19 ---- import java.util.*; import bossa.util.*; + import mlsub.typing.*; import mlsub.typing.TypeConstructor; import mlsub.typing.Monotype; *************** *** 123,127 **** if (typeConstructor != null) { ! tc = typeConstructor.resolveToTCForPattern(scope); if (exactlyAt && !TypeConstructors.instantiable(tc)) User.error --- 124,136 ---- if (typeConstructor != null) { ! mlsub.typing.TypeSymbol sym = ! typeConstructor.resolveToTypeSymbol(scope); ! ! if (sym instanceof TypeConstructor) ! tc = (TypeConstructor) sym; ! else ! throw User.error(this, typeConstructor + ! " is not a declared class or interface"); ! if (exactlyAt && !TypeConstructors.instantiable(tc)) User.error *************** *** 742,746 **** Location.nowhere())); ! mlsub.typing.TypeSymbol sym = Node.getGlobalTypeScope().lookup(name); if (sym == null) --- 751,755 ---- Location.nowhere())); ! TypeSymbol sym = Node.getGlobalTypeScope().lookup(name); if (sym == null) |
From: <bo...@us...> - 2003-12-22 20:28:14
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1:/tmp/cvs-serv1721/src/bossa/parser Modified Files: Parser.jj Log Message: Handle custom constructors for classes with type parameters. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.229 retrieving revision 1.230 diff -C2 -d -r1.229 -r1.230 *** Parser.jj 17 Dec 2003 14:33:39 -0000 1.229 --- Parser.jj 22 Dec 2003 20:28:10 -0000 1.230 *************** *** 1068,1072 **** } ! CustomConstructor customConstructor(): { LocatedString name; --- 1068,1072 ---- } ! CustomConstructor customConstructor(Constraint cst): { LocatedString name; *************** *** 1086,1090 **** ) { ! return CustomConstructor.make(name, params, new Block(statements)); } } --- 1086,1090 ---- ) { ! return CustomConstructor.make(name, cst, params, new Block(statements)); } } *************** *** 1527,1536 **** | [ "public" | "private" ] ! ( res=customConstructor() ! | res=globalVariable() | res=enumDefinition(definitions) | { Constraint cst; } cst = constraint() ( ! LOOKAHEAD ( "abstract" "interface" ) res=interfaceDefinition(cst) | res=classDefinition(cst, definitions, storeDocString) --- 1527,1537 ---- | [ "public" | "private" ] ! ( ! res=globalVariable() | res=enumDefinition(definitions) | { Constraint cst; } cst = constraint() ( ! res=customConstructor(cst) ! | LOOKAHEAD ( "abstract" "interface" ) res=interfaceDefinition(cst) | res=classDefinition(cst, definitions, storeDocString) |
From: <bo...@us...> - 2003-12-22 20:28:13
|
Update of /cvsroot/nice/Nice/testsuite/compiler/classes/constructors In directory sc8-pr-cvs1:/tmp/cvs-serv1721/testsuite/compiler/classes/constructors Modified Files: custom.testsuite Log Message: Handle custom constructors for classes with type parameters. Index: custom.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/classes/constructors/custom.testsuite,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** custom.testsuite 22 Dec 2003 15:39:51 -0000 1.9 --- custom.testsuite 22 Dec 2003 20:28:10 -0000 1.10 *************** *** 82,86 **** new /*/// FAIL HERE */ FooBar(int x) = this("xyz"); ! /// PASS bug A<String> a = new A(x: 5, z: "abc"); assert a.t.equals("abc"); --- 82,87 ---- new /*/// FAIL HERE */ FooBar(int x) = this("xyz"); ! /// PASS ! /// package a A<String> a = new A(x: 5, z: "abc"); assert a.t.equals("abc"); *************** *** 91,93 **** T t; } ! new A(int x, T z) = this(str: x.toString(), t: z); --- 92,99 ---- T t; } ! // Locally rename the type parameter ! <U> new A(int x, U z) = this(str: x.toString(), t: z); ! ! /// package b import a ! A<String> a = new A(x: 5, z: "abc"); ! A<String> b = new A(str: "5", t: "abc"); |
From: <bo...@us...> - 2003-12-22 20:28:13
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv1721/src/bossa/syntax Modified Files: TypeIdent.java CustomConstructor.java Constraint.java Log Message: Handle custom constructors for classes with type parameters. Index: TypeIdent.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/TypeIdent.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** TypeIdent.java 9 Dec 2003 15:21:05 -0000 1.26 --- TypeIdent.java 22 Dec 2003 20:28:10 -0000 1.27 *************** *** 58,62 **** Monotype substitute(Map map) { ! Monotype res = (Monotype) map.get(this); if(res!=null) return res; --- 58,62 ---- Monotype substitute(Map map) { ! Monotype res = (Monotype) map.get(name.toString()); if(res!=null) return res; Index: CustomConstructor.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/CustomConstructor.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** CustomConstructor.java 22 Dec 2003 01:30:59 -0000 1.10 --- CustomConstructor.java 22 Dec 2003 20:28:10 -0000 1.11 *************** *** 30,42 **** { public static CustomConstructor make ! (LocatedString className, FormalParameters params, Block body) { ! return new SourceCustomConstructor(className, params, body); } ! CustomConstructor(LocatedString className, FormalParameters params) { ! super(new LocatedString("<init>", className.location()), Constraint.True, ! returnType(className), params, Contract.noContract); } --- 30,44 ---- { public static CustomConstructor make ! (LocatedString className, Constraint cst, FormalParameters params, ! Block body) { ! return new SourceCustomConstructor(className, cst, params, body); } ! CustomConstructor(LocatedString className, Constraint cst, ! FormalParameters params) { ! super(new LocatedString("<init>", className.location()), cst, ! returnType(className, cst), params, Contract.noContract); } *************** *** 44,48 **** { super(new LocatedString("<init>", def.definition.location()), ! def.definition.classConstraint, returnType(def.definition), parameters, Contract.noContract); --- 46,51 ---- { super(new LocatedString("<init>", def.definition.location()), ! def.definition.classConstraint == null ? ! null : def.definition.classConstraint.shallowClone(), returnType(def.definition), parameters, Contract.noContract); *************** *** 64,70 **** } ! private static Monotype returnType(LocatedString className) { ! Monotype res = new TypeIdent(className); res.nullness = Monotype.sure; return res; --- 67,90 ---- } ! private static Monotype returnType(LocatedString className, Constraint cst) { ! TypeIdent classe = new TypeIdent(className); ! classe.nullness = Monotype.sure; ! ! if (cst == Constraint.True) ! return classe; ! ! TypeSymbol[] syms = cst.getBinderArray(); ! Monotype[] params = new Monotype[syms.length]; ! ! for (int i = 0; i < syms.length; i++) ! { ! if (! (syms[i] instanceof mlsub.typing.MonotypeVar)) ! User.error(classe, syms[i] + " is not a type"); ! params[i] = Monotype.create((MonotypeVar) syms[i]); ! } ! ! Monotype res = new MonotypeConstructor ! (classe, new TypeParameters(params), classe.location()); res.nullness = Monotype.sure; return res; *************** *** 99,106 **** static class SourceCustomConstructor extends CustomConstructor { ! SourceCustomConstructor(LocatedString className, FormalParameters params, ! Block body) { ! super(className, params); this.className = className; --- 119,126 ---- static class SourceCustomConstructor extends CustomConstructor { ! SourceCustomConstructor(LocatedString className, Constraint cst, ! FormalParameters params, Block body) { ! super(className, cst, params); this.className = className; *************** *** 169,172 **** --- 189,202 ---- } + private Map map(TypeSymbol[] source, mlsub.typing.Monotype[] destination) + { + Map res = new HashMap(source.length); + + for (int i = 0; i < source.length; i++) + res.put(source[i].toString(), Monotype.create(destination[i])); + + return res; + } + protected gnu.expr.Expression computeCode() { *************** *** 176,179 **** --- 206,218 ---- Gen.setMethodBody(lambda, body.generateCode()); classe.getClassExp().addMethod(lambda); + + // In the bytecode, we want to use the same type parameter names + // as the class definition, even if the source of this custom constructor + // renamed them locally. + mlsub.typing.Constraint cst = getType().getConstraint(); + if (mlsub.typing.Constraint.hasBinders(cst)) + parameters.substitute + (map(cst.binders(), classe.definition.getTypeParameters())); + lambda.addBytecodeAttribute(parameters.asBytecodeAttribute()); initializationCode = Index: Constraint.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Constraint.java,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** Constraint.java 15 Nov 2003 17:25:47 -0000 1.37 --- Constraint.java 22 Dec 2003 20:28:10 -0000 1.38 *************** *** 93,97 **** * The lists are new, but the list elements are the same. */ ! private Constraint shallowClone() { return new Constraint(cloneList(binders), --- 93,97 ---- * The lists are new, but the list elements are the same. */ ! Constraint shallowClone() { return new Constraint(cloneList(binders), |
From: <ar...@us...> - 2003-12-22 15:39:58
|
Update of /cvsroot/nice/Nice/testsuite/compiler/classes/constructors In directory sc8-pr-cvs1:/tmp/cvs-serv4712/F:/nice/testsuite/compiler/classes/constructors Modified Files: custom.testsuite Log Message: Testcase for custom constructor of a parametric class. Index: custom.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/classes/constructors/custom.testsuite,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** custom.testsuite 22 Dec 2003 01:30:59 -0000 1.8 --- custom.testsuite 22 Dec 2003 15:39:51 -0000 1.9 *************** *** 81,82 **** --- 81,93 ---- /// Toplevel new /*/// FAIL HERE */ FooBar(int x) = this("xyz"); + + /// PASS bug + A<String> a = new A(x: 5, z: "abc"); + assert a.t.equals("abc"); + /// Toplevel + class A<T> + { + String str; + T t; + } + new A(int x, T z) = this(str: x.toString(), t: z); |
From: <bo...@us...> - 2003-12-22 01:31:04
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv26684/src/bossa/syntax Modified Files: RetypedJavaMethod.java NiceClass.java MethodDeclaration.java JavaMethod.java JavaConstructor.java FormalParameters.java CustomConstructor.java Constructor.java AST.java Log Message: Classes now have default constructors build upon their parent's custom constructors. Index: RetypedJavaMethod.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/RetypedJavaMethod.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** RetypedJavaMethod.java 26 Nov 2003 08:50:23 -0000 1.12 --- RetypedJavaMethod.java 22 Dec 2003 01:30:59 -0000 1.13 *************** *** 19,22 **** --- 19,24 ---- import nice.tools.code.Types; import nice.tools.code.TypeImport; + import gnu.expr.QuoteExp; + import gnu.expr.InitializeProc; import java.util.*; *************** *** 238,241 **** --- 240,248 ---- } + gnu.expr.Expression getConstructorInvocation(boolean omitDefaults) + { + return new QuoteExp(new InitializeProc(reflectMethod)); + } + /**************************************************************** * Module interface Index: NiceClass.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/NiceClass.java,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** NiceClass.java 14 Dec 2003 16:52:32 -0000 1.76 --- NiceClass.java 22 Dec 2003 01:30:59 -0000 1.77 *************** *** 165,171 **** } ! FormalParameters.Parameter asParameter(TypeMap map) { ! Monotype type = Monotype.create(sym.syntacticType.resolve(map)); if (value == null) return new FormalParameters.NamedParameter(type, sym.getName(), true); --- 165,171 ---- } ! FormalParameters.Parameter asParameter() { ! Monotype type = sym.syntacticType; if (value == null) return new FormalParameters.NamedParameter(type, sym.getName(), true); *************** *** 312,331 **** to this overriding. */ ! void updateConstructorParameter ! (FormalParameters.Parameter[] inherited, int nb, TypeScope scope) { String name = sym.getName().toString(); ! Monotype type = Monotype.create(sym.syntacticType.resolve(scope)); ! for (int i = 0; i < nb; i++) ! if (inherited[i].match(name)) { if (value != null) ! inherited[i] = new FormalParameters.OptionalParameter ! (type, sym.getName(), true, value, ! inherited[i].value() == null || inherited[i].isOverriden()); else ! inherited[i].resetType(type); } } --- 312,333 ---- to this overriding. */ ! void updateConstructorParameter(List inherited) { String name = sym.getName().toString(); ! Monotype type = sym.syntacticType; ! for (int i = 1; i < inherited.size(); i++) { ! FormalParameters.Parameter param = (FormalParameters.Parameter) ! inherited.get(i); ! if (param.match(name)) { if (value != null) ! inherited.set(i, new FormalParameters.OptionalParameter ! (type, sym.getName(), true, value, ! param.value() == null || param.isOverriden())); else ! param.resetType(type); } + } } *************** *** 402,406 **** resolveFields(); resolveIntitializers(); ! createConstructor(); addPublicCloneMethod(); } --- 404,408 ---- resolveFields(); resolveIntitializers(); ! createDefaultConstructors(); addPublicCloneMethod(); } *************** *** 634,669 **** /** - Collect in 'constraints' the constraints set by each class - on the type parameters. - */ - private static FormalParameters.Parameter[][] getFieldsAsParameters - (TypeConstructor tc, int nbFields, List constraints, - TypeSymbol[] binders) - { - ClassDefinition sup = ClassDefinition.get(tc); - if (sup != null && sup.implementation instanceof NiceClass) - return ((NiceClass) sup.implementation). - getFieldsAsParameters(nbFields, constraints, binders); - - List constructors = TypeConstructors.getConstructors(tc); - if (constructors == null) - return new FormalParameters.Parameter[][] - { new FormalParameters.Parameter[nbFields] }; - - FormalParameters.Parameter[][] res = - new FormalParameters.Parameter[constructors.size()][]; - int n = 0; - for (Iterator i = constructors.iterator(); i.hasNext(); n++) - { - MethodDeclaration.Symbol m = (MethodDeclaration.Symbol) i.next(); - res[n] = new FormalParameters.Parameter[nbFields + m.arity]; - mlsub.typing.Monotype[] args = m.getMethodDeclaration().getArgTypes(); - for (int j = 0; j < args.length; j++) - res[n][j] = new FormalParameters.Parameter(Monotype.create(args[j])); - } - return res; - } - - /** @return the scope that maps the type parameters of the other class to the corresponding symbol in the constructor of this class. --- 636,639 ---- *************** *** 686,708 **** } ! private FormalParameters.Parameter[][] getFieldsAsParameters ! (int nbFields, List constraints, TypeSymbol[] binders) { ! nbFields += this.fields.length; ! FormalParameters.Parameter[][] res = getFieldsAsParameters ! (definition.getSuperClass(), nbFields, constraints, binders); ! if (fields.length == 0 && overrides.length == 0 && ! definition.classConstraint == null) ! return res; TypeScope scope = Node.getGlobalTypeScope(); Map map = null; if (binders != null) { ! // Constructs a type scope that maps the type parameters of this ! // class to the corresponding symbol in the constructor. scope = new TypeScope(scope); ! map = new HashMap(); TypeSymbol[] ourBinders = definition.getBinders(); for (int i = 0; i < binders.length; i++) --- 656,703 ---- } ! /** ! Collect in 'constraints' the constraints set by each class ! on the type parameters. ! */ ! private static List getNativeConstructorParameters ! (TypeConstructor tc, List constraints, TypeSymbol[] binders) { ! List constructors = TypeConstructors.getConstructors(tc); ! if (constructors == null) ! { ! List res = new ArrayList(10); ! List params = new ArrayList(10); ! // null stands for the Object() constructor ! params.add(null); ! res.add(params); ! return res; ! } ! List res = new ArrayList(constructors.size()); ! int n = 0; ! for (Iterator i = constructors.iterator(); i.hasNext(); n++) ! { ! MethodDeclaration.Symbol m = (MethodDeclaration.Symbol) i.next(); ! List params = new ArrayList(10); ! params.add(m.getMethodDeclaration()); ! res.add(params); ! mlsub.typing.Monotype[] args = m.getMethodDeclaration().getArgTypes(); ! for (int j = 0; j < args.length; j++) ! params.add(new FormalParameters.Parameter(Monotype.create(args[j]))); ! } ! return res; ! } + private List getParentConstructorParameters + (List constraints, TypeSymbol[] binders) + { TypeScope scope = Node.getGlobalTypeScope(); Map map = null; if (binders != null) { ! // Constructs a type scope that maps the type parameters of this ! // class to the corresponding symbol in the constructor. scope = new TypeScope(scope); ! map = new HashMap(); TypeSymbol[] ourBinders = definition.getBinders(); for (int i = 0; i < binders.length; i++) *************** *** 713,721 **** } ! updateConstructorParameters(res[0], res[0].length - nbFields, scope); ! for (int j = 0; j < res.length; j++) ! for (int i = fields.length, n = res[j].length - nbFields + i; --i >= 0;) ! res[j][--n] = fields[i].asParameter(scope); if (definition.classConstraint != null) --- 708,723 ---- } ! ArrayList res = new ArrayList(constructors.size()); ! for (Iterator i = constructors.iterator(); i.hasNext();) ! { ! MethodDeclaration decl = ((MethodDeclaration.Symbol) i.next()). ! getMethodDeclaration(); ! List params = new ArrayList(1 + decl.arity); ! params.add(decl); ! if (decl.arity > 0) ! params.addAll(decl.formalParameters().getParameters(scope)); ! res.add(params); ! } if (definition.classConstraint != null) *************** *** 732,744 **** } /** This must be done in a given class for every subclass, since they have different type parameters. */ ! private void updateConstructorParameters ! (FormalParameters.Parameter[] inherited, int nb, TypeScope scope) { for (int f = 0; f < overrides.length; f++) ! overrides[f].updateConstructorParameter(inherited, nb, scope); } --- 734,774 ---- } + private List getConstructorParameters(List constraints, TypeSymbol[] binders) + { + TypeConstructor supTC = definition.getSuperClass(); + + NiceClass sup = get(supTC); + List res; + if (sup == null) + res = getNativeConstructorParameters(supTC, constraints, binders); + else + res = sup.getParentConstructorParameters(constraints, binders); + + if (overrides.length > 0) + for (Iterator i = res.iterator(); i.hasNext();) + updateConstructorParameters((List) i.next()); + + if (fields.length > 0) + for (int j = 0; j < res.size(); j++) + { + List params = (List) res.get(j); + for (int i = 0; i < fields.length; i++) + params.add(fields[i].asParameter()); + } + + if (definition.resolvedConstraints != null) + constraints.addAll(Arrays.asList(definition.resolvedConstraints)); + + return res; + } + /** This must be done in a given class for every subclass, since they have different type parameters. */ ! private void updateConstructorParameters(List inherited) { for (int f = 0; f < overrides.length; f++) ! overrides[f].updateConstructorParameter(inherited); } *************** *** 761,766 **** private Constructor[] constructorMethod; ! private void createConstructor() { if (definition instanceof ClassDefinition.Interface) return; --- 791,800 ---- private Constructor[] constructorMethod; ! private void createDefaultConstructors() { + if (definition.inInterfaceFile()) + // The constructors are loaded from the compiled package. + return; + if (definition instanceof ClassDefinition.Interface) return; *************** *** 773,780 **** constraints = new LinkedList(); ! FormalParameters.Parameter[][] params = ! getFieldsAsParameters(0, constraints, binders); ! ! checkFields(params[0]); Constraint cst; --- 807,811 ---- constraints = new LinkedList(); ! List allConstructorParams = getConstructorParameters(constraints, binders); Constraint cst; *************** *** 786,826 **** cst = Constraint.True; ! constructorMethod = new Constructor[params.length]; ! for (int i = 0; i < params.length; i++) { ! FormalParameters values = new FormalParameters(params[i]); constructorMethod[i] = new Constructor ! (this, fields, i, definition.location(), values, cst, ! Monotype.resolve(definition.typeScope, values.types()), Monotype.sure(new MonotypeConstructor(definition.tc, definition.getTypeParameters()))); TypeConstructors.addConstructor(definition.tc, constructorMethod[i]); } - } - - private static gnu.expr.Expression objectConstructor = - new gnu.expr.QuoteExp - (new gnu.expr.InitializeProc - (gnu.bytecode.Type.pointer_type.getDeclaredMethod("<init>", 0))); - - gnu.expr.Expression getSuper(int index, boolean omitDefaults) - { - TypeConstructor tc = definition.getSuperClass(); - - if (tc == null) - return objectConstructor; - - ClassDefinition sup = ClassDefinition.get(tc); - if (sup != null && sup.implementation instanceof NiceClass) - return ((NiceClass) sup.implementation). - constructorMethod[index].getConstructorInvocation(omitDefaults); - - List constructors = TypeConstructors.getConstructors(tc); - JavaMethod m = (JavaMethod) - ((MethodDeclaration.Symbol) constructors.get(index)).getDefinition(); - return m.getConstructorInvocation(); } --- 817,844 ---- cst = Constraint.True; ! constructorMethod = new Constructor[allConstructorParams.size()]; ! for (int i = 0; i < allConstructorParams.size(); i++) { ! List argList = (List) allConstructorParams.get(i); ! MethodDeclaration parent = (MethodDeclaration) argList.get(0); ! argList = argList.subList(1, argList.size()); ! FormalParameters.Parameter[] args = (FormalParameters.Parameter[]) ! argList.toArray(new FormalParameters.Parameter[argList.size()]); ! ! // Check only once. ! if (i == 0) ! checkFields(args); ! ! FormalParameters values = new FormalParameters(args); constructorMethod[i] = new Constructor ! (this, fields, parent, definition.location(), values, cst, ! Monotype.resolve(definition.getLocalScope(), values.types()), Monotype.sure(new MonotypeConstructor(definition.tc, definition.getTypeParameters()))); TypeConstructors.addConstructor(definition.tc, constructorMethod[i]); } } Index: MethodDeclaration.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MethodDeclaration.java,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** MethodDeclaration.java 8 Dec 2003 18:39:21 -0000 1.52 --- MethodDeclaration.java 22 Dec 2003 01:30:59 -0000 1.53 *************** *** 58,61 **** --- 58,64 ---- addChild(parameters); + if (constraint == null) + constraint = bossa.syntax.Constraint.True; + // remember it to print the interface syntacticConstraint = constraint.toString(); *************** *** 399,402 **** --- 402,413 ---- // Default implementation. return getCodeInCallPosition(); + } + + /** Call to the constructor. This should be overriden by methods + that really give access to a constructor. + */ + gnu.expr.Expression getConstructorInvocation(boolean omitDefaults) + { + throw new Error("Constructor for " + this + " (" + this.getClass() + ")"); } Index: JavaMethod.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/JavaMethod.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** JavaMethod.java 30 Aug 2003 10:37:13 -0000 1.28 --- JavaMethod.java 22 Dec 2003 01:30:59 -0000 1.29 *************** *** 102,110 **** } - gnu.expr.Expression getConstructorInvocation() - { - return new QuoteExp(new InitializeProc(reflectMethod)); - } - /**************************************************************** * Module interface --- 102,105 ---- Index: JavaConstructor.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/JavaConstructor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** JavaConstructor.java 30 Aug 2003 10:37:13 -0000 1.3 --- JavaConstructor.java 22 Dec 2003 01:30:59 -0000 1.4 *************** *** 39,41 **** --- 39,46 ---- return new QuoteExp(new InstantiateProc(reflectMethod)); } + + gnu.expr.Expression getConstructorInvocation(boolean omitDefaults) + { + return new QuoteExp(new InitializeProc(reflectMethod)); + } } Index: FormalParameters.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/FormalParameters.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** FormalParameters.java 15 Dec 2003 02:40:17 -0000 1.34 --- FormalParameters.java 22 Dec 2003 01:30:59 -0000 1.35 *************** *** 38,41 **** --- 38,46 ---- Monotype type; + Parameter cloneParam() + { + return new Parameter(type); + } + boolean match(String id) { return false; } boolean requiresName() { return false; } *************** *** 159,162 **** --- 164,174 ---- boolean requiresName() { return nameRequired; } + Parameter cloneParam() + { + NamedParameter res = new NamedParameter(type, name); + res.nameRequired = this.nameRequired; + return res; + } + boolean match(String id) { return name.toString().equals(id); } *************** *** 209,212 **** --- 221,229 ---- boolean isOverriden() { return overriden; } + Parameter cloneParam() + { + return new OptionalParameter(type, name, nameRequired, defaultValue, overriden); + } + void resolve() { *************** *** 525,528 **** --- 542,557 ---- } + return res; + } + + List getParameters(TypeScope scope) + { + ArrayList res = new ArrayList(size); + for (int i = 0; i < size; i++) + { + Parameter p = parameters[i].cloneParam(); + p.type = Monotype.create(p.type.resolve(scope)); + res.add(p); + } return res; } Index: CustomConstructor.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/CustomConstructor.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** CustomConstructor.java 16 Dec 2003 12:59:50 -0000 1.9 --- CustomConstructor.java 22 Dec 2003 01:30:59 -0000 1.10 *************** *** 41,44 **** --- 41,53 ---- } + CustomConstructor(NiceClass def, FormalParameters parameters) + { + super(new LocatedString("<init>", def.definition.location()), + def.definition.classConstraint, + returnType(def.definition), parameters, + Contract.noContract); + classe = def; + } + void addConstructorCallSymbol() { *************** *** 50,64 **** gnu.expr.Expression compileInCallPosition() { ! return getInitializationCode(); } }); } - CustomConstructor(NiceClass def, FormalParameters parameters) - { - this(def.definition.getName(), parameters); - classe = def; - } - private static Monotype returnType(LocatedString className) { --- 59,67 ---- gnu.expr.Expression compileInCallPosition() { ! return getInitializationCode(true); } }); } private static Monotype returnType(LocatedString className) { *************** *** 68,71 **** --- 71,81 ---- } + private static Monotype returnType(ClassDefinition def) + { + mlsub.typing.Monotype res = Monotype.sure + (new mlsub.typing.MonotypeConstructor(def.tc, def.getTypeParameters())); + return Monotype.create(res); + } + public void printInterface(java.io.PrintWriter s) { *************** *** 79,83 **** } ! abstract gnu.expr.Expression getInitializationCode(); NiceClass classe; --- 89,93 ---- } ! abstract gnu.expr.Expression getInitializationCode(boolean implicitThis); NiceClass classe; *************** *** 167,176 **** classe.getClassExp().addMethod(lambda); lambda.addBytecodeAttribute(parameters.asBytecodeAttribute()); ! initializationCode = new QuoteExp(new InitializeProc(lambda, true)); return new QuoteExp(new InstantiateProc(lambda)); } ! gnu.expr.Expression getInitializationCode() { getCode(); --- 177,189 ---- classe.getClassExp().addMethod(lambda); lambda.addBytecodeAttribute(parameters.asBytecodeAttribute()); ! initializationCode = ! new QuoteExp(new InitializeProc(lambda)); ! initializationCodeImplicitThis = ! new QuoteExp(new InitializeProc(lambda, true)); return new QuoteExp(new InstantiateProc(lambda)); } ! gnu.expr.Expression getConstructorInvocation(boolean omitDefaults) { getCode(); *************** *** 178,184 **** --- 191,207 ---- } + gnu.expr.Expression getInitializationCode(boolean implicitThis) + { + getCode(); + if (implicitThis) + return initializationCodeImplicitThis; + else + return initializationCode; + } + LocatedString className; Statement body; gnu.expr.Expression initializationCode; + gnu.expr.Expression initializationCodeImplicitThis; } *************** *** 219,226 **** } ! gnu.expr.Expression getInitializationCode() { int dummyArgs = method.arg_types.length - arity; ! return new QuoteExp(new InitializeProc(method, true, dummyArgs)); } --- 242,255 ---- } ! gnu.expr.Expression getConstructorInvocation(boolean omitDefaults) { int dummyArgs = method.arg_types.length - arity; ! return new QuoteExp(new InitializeProc(method, false, dummyArgs)); ! } ! ! gnu.expr.Expression getInitializationCode(boolean implicitThis) ! { ! int dummyArgs = method.arg_types.length - arity; ! return new QuoteExp(new InitializeProc(method, implicitThis, dummyArgs)); } Index: Constructor.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Constructor.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Constructor.java 14 Dec 2003 16:52:32 -0000 1.10 --- Constructor.java 22 Dec 2003 01:30:59 -0000 1.11 *************** *** 35,39 **** class Constructor extends MethodDeclaration { ! Constructor(NiceClass classe, NiceClass.Field[] fields, int index, Location location, FormalParameters formals, --- 35,40 ---- class Constructor extends MethodDeclaration { ! Constructor(NiceClass classe, NiceClass.Field[] fields, ! MethodDeclaration parent, Location location, FormalParameters formals, *************** *** 47,51 **** this.classe = classe; this.fields = fields; ! this.index = index; mlsub.typing.Polytype type = new mlsub.typing.Polytype --- 48,52 ---- this.classe = classe; this.fields = fields; ! this.parent = parent; mlsub.typing.Polytype type = new mlsub.typing.Polytype *************** *** 64,68 **** private NiceClass classe; private NiceClass.Field[] fields; ! private int index; Expression getConstructorInvocation(boolean omitDefaults) --- 65,69 ---- private NiceClass classe; private NiceClass.Field[] fields; ! private MethodDeclaration parent; Expression getConstructorInvocation(boolean omitDefaults) *************** *** 129,148 **** if (classe.definition.inInterfaceFile()) ! { ! Method m = classe.getClassExp().getClassType().getDeclaredMethod ! ("<init>", argTypesArray); ! ! if (omitDefaults) ! { ! initializeOmitDefaults = new QuoteExp(new InitializeProc(m)); ! } ! else ! { ! initialize = new QuoteExp(new InitializeProc(m)); ! initializeFromConstructor = new QuoteExp(new InitializeProc(m, true)); ! instantiate = new QuoteExp(new InstantiateProc(m)); ! } ! return; ! } ConstructorExp lambda = Gen.createConstructor --- 130,134 ---- if (classe.definition.inInterfaceFile()) ! throw new Error("Constructors are loaded from the compiled package"); ConstructorExp lambda = Gen.createConstructor *************** *** 152,155 **** --- 138,143 ---- Gen.setMethodBody(lambda, body(thisExp, fullArgs, omitDefaults)); classe.getClassExp().addMethod(lambda); + if (! omitDefaults) + lambda.addBytecodeAttribute(parameters.asBytecodeAttribute()); if (omitDefaults) *************** *** 165,168 **** --- 153,161 ---- } + private static gnu.expr.Expression objectConstructor = + new gnu.expr.QuoteExp + (new gnu.expr.InitializeProc + (gnu.bytecode.Type.pointer_type.getDeclaredMethod("<init>", 0))); + private Expression callSuper(Expression thisExp, MonoSymbol[] args, boolean omitDefaults) *************** *** 177,181 **** } ! Expression superExp = classe.getSuper(index, omitDefaults); return new ApplyExp(superExp, (Expression[]) superArgs.toArray(new Expression[superArgs.size()])); --- 170,176 ---- } ! // A null parent means no parent class: call the Object constructor. ! Expression superExp = parent == null ? ! objectConstructor : parent.getConstructorInvocation(omitDefaults); return new ApplyExp(superExp, (Expression[]) superArgs.toArray(new Expression[superArgs.size()])); Index: AST.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/AST.java,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** AST.java 13 Dec 2003 16:53:04 -0000 1.55 --- AST.java 22 Dec 2003 01:30:59 -0000 1.56 *************** *** 108,119 **** Node.setModule(module); ! // Classes are resolved first, since code can depend on them ! for(int i = 0; i < classes.length; i++) ! resolve(classes[i]); ! ! // Custom constructors depend classes, and code can depend on them for(int i = 0; i < customConstructors.length; i++) resolve(customConstructors[i]); for(Iterator i = children.iterator();i.hasNext();) { --- 108,120 ---- Node.setModule(module); ! // Resolve custom constructors early, classes depend on them for(int i = 0; i < customConstructors.length; i++) resolve(customConstructors[i]); + // Classes are then resolved, since code can depend on them + for(int i = 0; i < classes.length; i++) + resolve(classes[i]); + + // Resolve all the rest for(Iterator i = children.iterator();i.hasNext();) { |
From: <bo...@us...> - 2003-12-22 01:31:02
|
Update of /cvsroot/nice/Nice/src/gnu/expr In directory sc8-pr-cvs1:/tmp/cvs-serv26684/src/gnu/expr Modified Files: InitializeProc.java ConstructorExp.java Log Message: Classes now have default constructors build upon their parent's custom constructors. Index: InitializeProc.java =================================================================== RCS file: /cvsroot/nice/Nice/src/gnu/expr/InitializeProc.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** InitializeProc.java 15 Dec 2003 16:19:47 -0000 1.3 --- InitializeProc.java 22 Dec 2003 01:30:59 -0000 1.4 *************** *** 90,98 **** // Add dummy arguments to match the bytecode constructor. - if (method !=null) - dummyArgs = method.dummyArgs; if (method != null) ! for (int i = 0; i < dummyArgs; i++) ! code.emitPushInt(0); code.emitInvokeSpecial(constructor); --- 90,97 ---- // Add dummy arguments to match the bytecode constructor. if (method != null) ! dummyArgs = method.dummyArgs; ! for (int i = 0; i < dummyArgs; i++) ! code.emitPushInt(0); code.emitInvokeSpecial(constructor); *************** *** 102,105 **** --- 101,116 ---- { return Type.void_type; + } + + public String toString() + { + String res; + if (constructor != null) + res = constructor.toString(); + else if (method != null) + res = method.toString(); + else + res = "?"; + return "Initialization: " + res; } Index: ConstructorExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/gnu/expr/ConstructorExp.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ConstructorExp.java 15 Dec 2003 02:40:16 -0000 1.6 --- ConstructorExp.java 22 Dec 2003 01:30:59 -0000 1.7 *************** *** 70,85 **** // Make sure the signature is unique ! if (! primary) { ! do ! { ! Type[] newArgs = new Type[args.length + 1]; ! System.arraycopy(args, 0, newArgs, 0, args.length); ! newArgs[args.length] = Type.int_type; ! args = newArgs; ! dummyArgs++; ! addDeclaration("dummy"); ! } ! while (ctype.getDeclaredMethod("<init>", args) != null); } --- 70,81 ---- // Make sure the signature is unique ! while (ctype.getDeclaredMethod("<init>", args) != null) { ! Type[] newArgs = new Type[args.length + 1]; ! System.arraycopy(args, 0, newArgs, 0, args.length); ! newArgs[args.length] = Type.int_type; ! args = newArgs; ! dummyArgs++; ! addDeclaration("dummy"); } |
From: <bo...@us...> - 2003-12-22 01:31:02
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang/inline In directory sc8-pr-cvs1:/tmp/cvs-serv26684/stdlib/nice/lang/inline Modified Files: Assert.java Log Message: Classes now have default constructors build upon their parent's custom constructors. Index: Assert.java =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/inline/Assert.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Assert.java 30 Nov 2003 14:50:04 -0000 1.6 --- Assert.java 22 Dec 2003 01:30:59 -0000 1.7 *************** *** 70,73 **** --- 70,74 ---- code.emitDup(); + prepare(); if (args.length == 1) { *************** *** 89,97 **** errorClass = ClassType.make("nice.lang.AssertionFailed"); ! private static final Method errorInit = errorClass.addMethod ! ("<init>", Access.PUBLIC, new Type[]{}, Type.void_type), errorInitString = errorClass.addMethod ("<init>", Access.PUBLIC, new Type[]{Type.string_type}, Type.void_type); public Type getReturnType (Expression[] args) --- 90,105 ---- errorClass = ClassType.make("nice.lang.AssertionFailed"); ! private static Method errorInit, errorInitString; ! ! private static void prepare() ! { ! if (errorInit != null) ! return; ! errorInit = errorClass.addMethod ! ("<init>", Access.PUBLIC, new Type[]{}, Type.void_type); errorInitString = errorClass.addMethod ("<init>", Access.PUBLIC, new Type[]{Type.string_type}, Type.void_type); + } public Type getReturnType (Expression[] args) |
From: <bo...@us...> - 2003-12-22 01:31:02
|
Update of /cvsroot/nice/Nice/testsuite/compiler/classes/constructors In directory sc8-pr-cvs1:/tmp/cvs-serv26684/testsuite/compiler/classes/constructors Modified Files: custom.testsuite Log Message: Classes now have default constructors build upon their parent's custom constructors. Index: custom.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/classes/constructors/custom.testsuite,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** custom.testsuite 16 Dec 2003 12:59:50 -0000 1.7 --- custom.testsuite 22 Dec 2003 01:30:59 -0000 1.8 *************** *** 35,39 **** } ! /// PASS bug var p = new Point(angle: 0, distance: 1); assert abs(p.x - 1) < 0.01 && abs(p.y) < 0.01; --- 35,39 ---- } ! /// PASS var p = new Point(angle: 0, distance: 1); assert abs(p.x - 1) < 0.01 && abs(p.y) < 0.01; |
From: <bo...@us...> - 2003-12-21 15:07:51
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv9947/src/bossa/syntax Modified Files: Contract.java Log Message: More robust toString method. Index: Contract.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Contract.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Contract.java 28 Nov 2003 13:52:08 -0000 1.6 --- Contract.java 21 Dec 2003 15:07:48 -0000 1.7 *************** *** 125,131 **** { StringBuffer res = new StringBuffer(); ! if (preExp.length > 0) res.append(requireRepr.toString()); ! if (postExp.length > 0) res.append(ensureRepr.toString()); return res.toString(); --- 125,131 ---- { StringBuffer res = new StringBuffer(); ! if (preExp != null && preExp.length > 0) res.append(requireRepr.toString()); ! if (postExp != null && postExp.length > 0) res.append(ensureRepr.toString()); return res.toString(); |
From: <bo...@us...> - 2003-12-21 02:50:58
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv6609/src/bossa/syntax Modified Files: NewExp.java Log Message: Clarified error message. Index: NewExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/NewExp.java,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** NewExp.java 16 Dec 2003 12:34:33 -0000 1.37 --- NewExp.java 21 Dec 2003 02:50:55 -0000 1.38 *************** *** 69,74 **** { if (tc.arity() > 0) ! User.error(this, "Class " + tc + " has no constructor with the correct number of " + ! tc.arity() + " type parameters.\nA retyping is needed to use this constructor."); else User.error(this, "Class " + tc + " has no constructor"); --- 69,75 ---- { if (tc.arity() > 0) ! User.error(this, "Class " + tc + " has no constructor with " + ! tc.arity() + " type parameters.\n" + ! "A retyping is needed to use this constructor."); else User.error(this, "Class " + tc + " has no constructor"); |
From: <ar...@us...> - 2003-12-19 18:52:48
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang In directory sc8-pr-cvs1:/tmp/cvs-serv14429/F:/nice/stdlib/nice/lang Modified Files: collections.nice java.nice Log Message: Simplified retypings and made Comparator contravariant. Index: collections.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/collections.nice,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** collections.nice 16 Dec 2003 14:55:28 -0000 1.58 --- collections.nice 19 Dec 2003 18:52:45 -0000 1.59 *************** *** 175,179 **** } ! class NiceComparator<T> implements java.util.Comparator { final (T,T) -> int comparator; --- 175,179 ---- } ! class NiceComparator<-T> implements java.util.Comparator<T> { final (T,T) -> int comparator; Index: java.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/java.nice,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** java.nice 19 Dec 2003 17:18:06 -0000 1.50 --- java.nice 19 Dec 2003 18:52:45 -0000 1.51 *************** *** 98,109 **** <T> T next(Iterator<T>) = native Object Iterator.next(); <T> void remove(Iterator<T>) = native void Iterator.remove(); ! <T,U | U <: T> void add(ListIterator<T>, U) = native void ListIterator.add(Object); <T> boolean hasPrevious(ListIterator<T>) = native boolean ListIterator.hasPrevious(); <T> int nextIndex(ListIterator<T>) = native int ListIterator.nextIndex(); <T> T previous(ListIterator<T>) = native Object ListIterator.previous(); <T> int previousIndex(ListIterator<T>) = native int ListIterator.previousIndex(); ! <T,U | U <: T> void set(ListIterator<T>, U) = native void ListIterator.set(Object); <T> int compare(Comparator<T>, T, T) = native int Comparator.compare(Object, Object); ! <T,U | U <: T> ?Comparator<U> comparator(SortedSet<T>) = native Comparator SortedSet.comparator(); <T> T first(SortedSet<T>) = native Object SortedSet.first(); <T> T last(SortedSet<T>) = native Object SortedSet.last(); --- 98,109 ---- <T> T next(Iterator<T>) = native Object Iterator.next(); <T> void remove(Iterator<T>) = native void Iterator.remove(); ! <T> void add(ListIterator<T>, T) = native void ListIterator.add(Object); <T> boolean hasPrevious(ListIterator<T>) = native boolean ListIterator.hasPrevious(); <T> int nextIndex(ListIterator<T>) = native int ListIterator.nextIndex(); <T> T previous(ListIterator<T>) = native Object ListIterator.previous(); <T> int previousIndex(ListIterator<T>) = native int ListIterator.previousIndex(); ! <T> void set(ListIterator<T>, T) = native void ListIterator.set(Object); <T> int compare(Comparator<T>, T, T) = native int Comparator.compare(Object, Object); ! <T> ?Comparator<T> comparator(SortedSet<T>) = native Comparator SortedSet.comparator(); <T> T first(SortedSet<T>) = native Object SortedSet.first(); <T> T last(SortedSet<T>) = native Object SortedSet.last(); *************** *** 115,119 **** <K,V> boolean isEmpty(Map<K,V>) = native boolean Map.isEmpty(); <K,V> int size(Map<K,V>) = native int Map.size(); ! <K,V,T | K <: T> ?Comparator<T> comparator(SortedMap<K,V>) = native Comparator SortedMap.comparator(); <K,V> K firstKey(SortedMap<K,V>) = native Object SortedMap.firstKey(); <K,V> K lastKey(SortedMap<K,V>) = native Object SortedMap.lastKey(); --- 115,119 ---- <K,V> boolean isEmpty(Map<K,V>) = native boolean Map.isEmpty(); <K,V> int size(Map<K,V>) = native int Map.size(); ! <K,V> ?Comparator<K> comparator(SortedMap<K,V>) = native Comparator SortedMap.comparator(); <K,V> K firstKey(SortedMap<K,V>) = native Object SortedMap.firstKey(); <K,V> K lastKey(SortedMap<K,V>) = native Object SortedMap.lastKey(); *************** *** 197,209 **** <T> TreeSet<T> TreeSet() = native new TreeSet(); <T,U | U <: T> TreeSet<T> TreeSet(Collection<U>) = native new TreeSet(Collection); ! <T,U | T <: U> TreeSet<T> TreeSet(Comparator<U>) = native new TreeSet(Comparator); <T> TreeSet<T> TreeSet(SortedSet<T>) = native new TreeSet(SortedSet); <K,V> TreeMap<K,V> TreeMap() = native new TreeMap(); ! <K,V,T | K <: T> TreeMap<K,V> TreeMap(Comparator<T>) = native new TreeMap(Comparator); <K,K0,V,V0 | K0 <: K, V0 <: V> TreeMap<K,V> TreeMap(Map<K0,V0>) = native new TreeMap(Map); <K,V> TreeMap<K,V> TreeMap(SortedMap<K,V>) = native new TreeMap(SortedMap); interface Collection<T> = native java.util.Collection; ! interface Comparator<T> = native java.util.Comparator; interface Enumeration<T> = native java.util.Enumeration; interface List<T> extends Collection<T> = native java.util.List; --- 197,209 ---- <T> TreeSet<T> TreeSet() = native new TreeSet(); <T,U | U <: T> TreeSet<T> TreeSet(Collection<U>) = native new TreeSet(Collection); ! <T> TreeSet<T> TreeSet(Comparator<T>) = native new TreeSet(Comparator); <T> TreeSet<T> TreeSet(SortedSet<T>) = native new TreeSet(SortedSet); <K,V> TreeMap<K,V> TreeMap() = native new TreeMap(); ! <K,V> TreeMap<K,V> TreeMap(Comparator<K>) = native new TreeMap(Comparator); <K,K0,V,V0 | K0 <: K, V0 <: V> TreeMap<K,V> TreeMap(Map<K0,V0>) = native new TreeMap(Map); <K,V> TreeMap<K,V> TreeMap(SortedMap<K,V>) = native new TreeMap(SortedMap); interface Collection<T> = native java.util.Collection; ! interface Comparator<-T> = native java.util.Comparator; interface Enumeration<T> = native java.util.Enumeration; interface List<T> extends Collection<T> = native java.util.List; *************** *** 320,328 **** <T> void shuffle(List<T>, Random) = native void Collections.shuffle(List, Random); ! <T,U | T <: U> T max(Collection<T>, Comparator<U>) = native Object Collections.max(Collection, Comparator); ! <T,U | T <: U> T min(Collection<T>, Comparator<U>) = native Object Collections.max(Collection, Comparator); ! <T, U | T <: U> void sort(List<T>, Comparator<U>) = native void Collections.sort(List, Comparator); <T> void swap(List<T>, int, int) = --- 320,328 ---- <T> void shuffle(List<T>, Random) = native void Collections.shuffle(List, Random); ! <T> T max(Collection<T>, Comparator<T>) = native Object Collections.max(Collection, Comparator); ! <T> T min(Collection<T>, Comparator<T>) = native Object Collections.max(Collection, Comparator); ! <T> void sort(List<T>, Comparator<T>) = native void Collections.sort(List, Comparator); <T> void swap(List<T>, int, int) = *************** *** 336,344 **** <T,U | T <: U> int lastIndexOfSubList(List<T>, List<U>) = native int Collections.lastIndexOfSubList(List, List); ! <T,U,V | T <: U, T <: V> int binarySearch(List<T>, U, Comparator<V>) = native int Collections.binarySearch(List, Object, Comparator); ! <T,U | T <: U> List<U> singletonList(T) = native List Collections.singletonList(Object); ! <K,K0,V,V0 | K <: K0, V <: V0> Map<K0,V0> singletonMap(K, V) = native Map Collections.singletonMap(Object, Object); <T> Collection<T> synchronizedCollection(Collection<T>) = --- 336,344 ---- <T,U | T <: U> int lastIndexOfSubList(List<T>, List<U>) = native int Collections.lastIndexOfSubList(List, List); ! <T,U | T <: U> int binarySearch(List<T>, U, Comparator<T>) = native int Collections.binarySearch(List, Object, Comparator); ! <T> List<T> singletonList(T) = native List Collections.singletonList(Object); ! <K,V> Map<K,V> singletonMap(K, V) = native Map Collections.singletonMap(Object, Object); <T> Collection<T> synchronizedCollection(Collection<T>) = |
From: <ar...@us...> - 2003-12-19 18:08:37
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv6452/F:/nice/src/bossa/syntax Modified Files: ClassDefinition.java Log Message: Don't ignore co\contra varariant typeparameters anymore. Index: ClassDefinition.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/ClassDefinition.java,v retrieving revision 1.101 retrieving revision 1.102 diff -C2 -d -r1.101 -r1.102 *** ClassDefinition.java 15 Dec 2003 14:04:13 -0000 1.101 --- ClassDefinition.java 19 Dec 2003 18:08:33 -0000 1.102 *************** *** 441,448 **** localScope = new TypeScope(localScope); mlsub.typing.TypeSymbol[] binders = getBinders(); - //add only nonvariant type parameter so no possibly unsafe co/contra-variant fields can exist. for (int i = 0; i < binders.length; i++) ! if (variance.getVariance(i) == mlsub.typing.Variance.INVARIANT) ! localScope.addSymbol(binders[i]); } catch(TypeScope.DuplicateName e){ --- 441,446 ---- localScope = new TypeScope(localScope); mlsub.typing.TypeSymbol[] binders = getBinders(); for (int i = 0; i < binders.length; i++) ! localScope.addSymbol(binders[i]); } catch(TypeScope.DuplicateName e){ |
From: <bo...@us...> - 2003-12-19 17:18:09
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang In directory sc8-pr-cvs1:/tmp/cvs-serv28030/stdlib/nice/lang Modified Files: java.nice Log Message: Document why contravariance is safe for unmodifiable views of collections and maps. Index: java.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/java.nice,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** java.nice 19 Dec 2003 16:16:56 -0000 1.49 --- java.nice 19 Dec 2003 17:18:06 -0000 1.50 *************** *** 354,357 **** --- 354,359 ---- <T> SortedSet<T> synchronizedSortedSet(SortedSet<T>) = native SortedSet Collections.synchronizedSortedSet(SortedSet); + // Return unmodifiable views of collections and maps. It is therefore safe + // to lose precision on the type parameter. <T,U | T <: U> Collection<U> unmodifiableCollection(Collection<T>) = native Collection Collections.unmodifiableCollection(Collection); |
From: <ar...@us...> - 2003-12-19 16:16:59
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang In directory sc8-pr-cvs1:/tmp/cvs-serv13172/F:/nice/stdlib/nice/lang Modified Files: java.nice Log Message: Make the Collection.synchronized... methods non-variant. Index: java.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/java.nice,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** java.nice 17 Dec 2003 18:55:06 -0000 1.48 --- java.nice 19 Dec 2003 16:16:56 -0000 1.49 *************** *** 342,356 **** <K,K0,V,V0 | K <: K0, V <: V0> Map<K0,V0> singletonMap(K, V) = native Map Collections.singletonMap(Object, Object); ! <T,U | T <: U> Collection<U> synchronizedCollection(Collection<T>) = native Collection Collections.synchronizedCollection(Collection); ! <T,U | T <: U> List<U> synchronizedList(List<T>) = native List Collections.synchronizedList(List); ! <K,K0,V,V0 | K <: K0, V <: V0> Map<K0,V0> synchronizedMap(Map<K,V>) = native Map Collections.synchronizedMap(Map); ! <T,U | T <: U> Set<U> synchronizedSet(Set<T>) = native Set Collections.synchronizedSet(Set); ! <K,K0,V,V0 | K <: K0, V <: V0> SortedMap<K0,V0> synchronizedSortedMap(SortedMap<K,V>) = native SortedMap Collections.synchronizedSortedMap(SortedMap); ! <T,U | T <: U> SortedSet<U> synchronizedSortedSet(SortedSet<T>) = native SortedSet Collections.synchronizedSortedSet(SortedSet); <T,U | T <: U> Collection<U> unmodifiableCollection(Collection<T>) = --- 342,356 ---- <K,K0,V,V0 | K <: K0, V <: V0> Map<K0,V0> singletonMap(K, V) = native Map Collections.singletonMap(Object, Object); ! <T> Collection<T> synchronizedCollection(Collection<T>) = native Collection Collections.synchronizedCollection(Collection); ! <T> List<T> synchronizedList(List<T>) = native List Collections.synchronizedList(List); ! <K,V> Map<K,V> synchronizedMap(Map<K,V>) = native Map Collections.synchronizedMap(Map); ! <T> Set<T> synchronizedSet(Set<T>) = native Set Collections.synchronizedSet(Set); ! <K,V> SortedMap<K,V> synchronizedSortedMap(SortedMap<K,V>) = native SortedMap Collections.synchronizedSortedMap(SortedMap); ! <T> SortedSet<T> synchronizedSortedSet(SortedSet<T>) = native SortedSet Collections.synchronizedSortedSet(SortedSet); <T,U | T <: U> Collection<U> unmodifiableCollection(Collection<T>) = |
From: <bo...@us...> - 2003-12-19 02:12:37
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang/inline In directory sc8-pr-cvs1:/tmp/cvs-serv3930/stdlib/nice/lang/inline Modified Files: Instanceof.java Log Message: Fixed 'instanceof Array' tests for values that are statically known to be arrays (they could still be null). Index: Instanceof.java =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/inline/Instanceof.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Instanceof.java 1 Apr 2003 20:25:09 -0000 1.3 --- Instanceof.java 19 Dec 2003 02:12:34 -0000 1.4 *************** *** 52,56 **** value.compile(comp, Target.pushObject); ! code.emitInstanceof(type); target.compileFromStack(comp, Type.boolean_type); } --- 52,71 ---- value.compile(comp, Target.pushObject); ! ! if (type == nice.tools.code.SpecialArray.wrappedType() && ! code.topType().isArray()) ! { ! /* If we want to test if the value is 'instanceof Array', and ! we know statically that it is an array, we just need to make ! sure it is not null. ! */ ! code.emitIfNull(); ! code.emitPushBoolean(false); ! code.emitElse(); ! code.emitPushBoolean(true); ! code.emitFi(); ! } ! else ! code.emitInstanceof(type); target.compileFromStack(comp, Type.boolean_type); } |
From: <bo...@us...> - 2003-12-19 02:12:37
|
Update of /cvsroot/nice/Nice/testsuite/compiler/methods In directory sc8-pr-cvs1:/tmp/cvs-serv3930/testsuite/compiler/methods Modified Files: primitive.testsuite Log Message: Fixed 'instanceof Array' tests for values that are statically known to be arrays (they could still be null). Index: primitive.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/methods/primitive.testsuite,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** primitive.testsuite 19 Dec 2003 00:48:25 -0000 1.4 --- primitive.testsuite 19 Dec 2003 02:12:34 -0000 1.5 *************** *** 20,24 **** foo(/*/// FAIL HERE */n<3) {} ! /// PASS bug assert foo(['a']); /// Toplevel --- 20,24 ---- foo(/*/// FAIL HERE */n<3) {} ! /// PASS assert foo(['a']); /// Toplevel |