nice-commit Mailing List for The Nice Programming Language (Page 30)
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: Arjan B. <ar...@us...> - 2004-11-25 19:28:32
|
Update of /cvsroot/nice/Nice/src/bossa/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7541/F:/nice/src/bossa/modules Modified Files: Package.java Log Message: Converted ClassDefinition. (patch by Luc Perrin) Index: Package.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/Package.java,v retrieving revision 1.122 retrieving revision 1.123 diff -C2 -d -r1.122 -r1.123 *** Package.java 9 Oct 2004 09:28:42 -0000 1.122 --- Package.java 25 Nov 2004 19:28:19 -0000 1.123 *************** *** 289,293 **** bossa.link.Alternative.reset(); bossa.link.Dispatch.reset(); ! ClassDefinition.reset(); TypeConstructors.reset(); JavaClasses.reset(); --- 289,293 ---- bossa.link.Alternative.reset(); bossa.link.Dispatch.reset(); ! bossa.syntax.dispatch.resetTypeDefinitionMappings(); TypeConstructors.reset(); JavaClasses.reset(); |
From: Arjan B. <ar...@us...> - 2004-11-25 19:28:31
|
Update of /cvsroot/nice/Nice/src/bossa/link In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7541/F:/nice/src/bossa/link Modified Files: Compilation.java Dispatch.java Log Message: Converted ClassDefinition. (patch by Luc Perrin) Index: Dispatch.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/link/Dispatch.java,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** Dispatch.java 3 Nov 2004 12:07:54 -0000 1.72 --- Dispatch.java 25 Nov 2004 19:28:19 -0000 1.73 *************** *** 264,268 **** private static ClassType classTypeOfNiceClass(TypeConstructor tc) { ! ClassDefinition def = ClassDefinition.get(tc); if (def == null || ! (def.getImplementation() instanceof NiceClass)) --- 264,268 ---- private static ClassType classTypeOfNiceClass(TypeConstructor tc) { ! TypeDefinition def = bossa.syntax.dispatch.getTypeDefinition(tc); if (def == null || ! (def.getImplementation() instanceof NiceClass)) Index: Compilation.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/link/Compilation.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Compilation.java 13 Jul 2004 11:05:40 -0000 1.17 --- Compilation.java 25 Nov 2004 19:28:19 -0000 1.18 *************** *** 179,183 **** { mlsub.typing.TypeConstructor firstArgument = alt.getPatterns()[0].getTC(); ! ClassDefinition def = ClassDefinition.get(firstArgument); --- 179,183 ---- { mlsub.typing.TypeConstructor firstArgument = alt.getPatterns()[0].getTC(); ! TypeDefinition def = bossa.syntax.dispatch.getTypeDefinition(firstArgument); |
From: Arjan B. <ar...@us...> - 2004-11-25 12:36:03
|
Update of /cvsroot/nice/Nice/testsuite/compiler/classes/constructors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14584/F:/nice/testsuite/compiler/classes/constructors Modified Files: custom.testsuite Log Message: Avoid NPE, fixes bug #1072970. Index: custom.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/classes/constructors/custom.testsuite,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** custom.testsuite 22 Nov 2004 21:37:04 -0000 1.14 --- custom.testsuite 25 Nov 2004 12:35:48 -0000 1.15 *************** *** 137,138 **** --- 137,146 ---- this(); } + + /// PASS + // bug #1072970 + /// Toplevel + class X { + String str; + } + new X() = this(str: "abc"); |
From: Arjan B. <ar...@us...> - 2004-11-25 12:36:02
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14584/F:/nice/src/bossa/syntax Modified Files: UserOperator.java Log Message: Avoid NPE, fixes bug #1072970. Index: UserOperator.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/UserOperator.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** UserOperator.java 15 Mar 2004 15:27:15 -0000 1.10 --- UserOperator.java 25 Nov 2004 12:35:48 -0000 1.11 *************** *** 71,74 **** --- 71,76 ---- } } + else + symbols = new MonoSymbol[0]; VarScope scope = this.scope; |
From: Arjan B. <ar...@us...> - 2004-11-22 23:21:15
|
Update of /cvsroot/nice/Nice/testsuite/compiler/typing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23666/F:/nice/testsuite/compiler/typing Modified Files: inference.testsuite Log Message: Java methods/fields with parametric types get type parameters with UnknownType instead of being ignored. Index: inference.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/typing/inference.testsuite,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** inference.testsuite 12 Aug 2004 23:21:40 -0000 1.9 --- inference.testsuite 22 Nov 2004 23:21:06 -0000 1.10 *************** *** 6,9 **** --- 6,13 ---- class B<BAR> extends A<BAR> {} + // workaround to avoid field/method ambiguity + <K, V> Set<Map.Entry<K, V>> mapEntries(Map<K, V> m) = m.entrySet(); + <K, K0, V | K <: K0> Set<K0> mapKeys(Map<K, V> m) = m.keySet(); + /// PASS let x = new A(); *************** *** 104,108 **** String key; ! for (each : table1.entrySet) { key = each.getKey; } --- 108,112 ---- String key; ! for (each : table1.mapEntries) { key = each.getKey; } *************** *** 130,134 **** /// PASS let testmap = new HashMap(); ! for(s : testmap.keySet()) { String x = s + " => " + testmap[s]; --- 134,138 ---- /// PASS let testmap = new HashMap(); ! for(s : testmap.mapKeys()) { String x = s + " => " + testmap[s]; *************** *** 139,143 **** for(s : ["1", "2", "3"]) testmap[s] = Integer.parseInt(s); ! for(s : testmap.keySet()) println(s + " => " + testmap[s]); --- 143,147 ---- for(s : ["1", "2", "3"]) testmap[s] = Integer.parseInt(s); ! for(s : testmap.mapKeys()) println(s + " => " + testmap[s]); *************** *** 146,150 **** for(s : ["1", "2", "3"]) testmap[s] = Integer.parseInt(s); ! for(String s : testmap.keySet()) println(s + " => " + testmap[s]); --- 150,154 ---- for(s : ["1", "2", "3"]) testmap[s] = Integer.parseInt(s); ! for(String s : testmap.mapKeys()) println(s + " => " + testmap[s]); *************** *** 197,201 **** for(i : 1..10) testmap[i] = i.toString(); ! for(i : testmap.keySet()) println(i + " => " + testmap[i]); --- 201,205 ---- for(i : 1..10) testmap[i] = i.toString(); ! for(i : testmap.mapKeys()) println(i + " => " + testmap[i]); *************** *** 215,219 **** while (n-- > 0) ! for (each : table1.entrySet) { key = each.getKey; v1 = each.getValue.value; --- 219,223 ---- while (n-- > 0) ! for (each : table1.mapEntries) { key = each.getKey; v1 = each.getValue.value; *************** *** 235,239 **** ?Cell c2; ! for (each : table1.entrySet) { let key = each.getKey; --- 239,243 ---- ?Cell c2; ! for (each : table1.mapEntries) { let key = each.getKey; |
From: Arjan B. <ar...@us...> - 2004-11-22 23:21:15
|
Update of /cvsroot/nice/Nice/src/nice/tools/typing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23666/F:/nice/src/nice/tools/typing Modified Files: Types.java Log Message: Java methods/fields with parametric types get type parameters with UnknownType instead of being ignored. Index: Types.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/typing/Types.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Types.java 30 Jul 2004 19:08:43 -0000 1.8 --- Types.java 22 Nov 2004 23:21:05 -0000 1.9 *************** *** 189,192 **** --- 189,205 ---- } + public static Monotype unknownArgsMonotype(TypeConstructor tc) + throws BadSizeEx + { + if (tc.variance == null || tc.arity() == 0) + return new MonotypeConstructor(tc, null); + + mlsub.typing.Monotype[] args = new mlsub.typing.Monotype[tc.arity()]; + for (int i = 0; i < tc.arity(); i++) + args[i] = UnknownMonotype.instance; + + return new MonotypeConstructor(tc, args); + } + /**************************************************************** * Type parameters |
From: Arjan B. <ar...@us...> - 2004-11-22 23:21:14
|
Update of /cvsroot/nice/Nice/src/nice/tools/code In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23666/F:/nice/src/nice/tools/code Modified Files: Types.java Log Message: Java methods/fields with parametric types get type parameters with UnknownType instead of being ignored. Index: Types.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/code/Types.java,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** Types.java 22 Nov 2004 14:40:58 -0000 1.61 --- Types.java 22 Nov 2004 23:21:04 -0000 1.62 *************** *** 412,416 **** return TopMonotype.instance; ! return getMonotype(javaType.getName()); } --- 412,433 ---- return TopMonotype.instance; ! TypeConstructor tc = bossa.syntax.Node.getGlobalTypeScope(). ! globalLookup(javaType.getName(), null); ! ! if (tc == null) ! { ! Internal.warning(javaType.getName() + " is not known"); ! throw new NotIntroducedClassException(tc); ! } ! ! if (tc.getId() == -1) ! throw new NotIntroducedClassException(tc); ! ! try { ! return nice.tools.typing.Types.unknownArgsMonotype(tc); ! } ! catch (BadSizeEx ex) { ! throw new ParametricClassException(tc.toString()); ! } } *************** *** 444,478 **** } - private static Monotype getMonotype(String name) - throws ParametricClassException, NotIntroducedClassException - { - if(name.endsWith("[]")) - { - name=name.substring(0,name.length()-2); - return new MonotypeConstructor - (PrimitiveType.arrayTC, - new Monotype[]{ getMonotype(name) }); - } - - TypeConstructor tc = bossa.syntax.Node.getGlobalTypeScope(). - globalLookup(name, null); - - if (tc == null) - { - Internal.warning(name + " is not known"); - throw new NotIntroducedClassException(tc); - } - - if (tc.getId() == -1) - throw new NotIntroducedClassException(tc); - - try { - return nice.tools.typing.Types.zeroArgMonotype(tc); - } - catch (BadSizeEx ex) { - throw new ParametricClassException(tc.toString()); - } - } - /**************************************************************** * Converting string to gnu.bytecode.Type --- 461,464 ---- |
From: Daniel B. <bo...@us...> - 2004-11-22 21:37:16
|
Update of /cvsroot/nice/Nice/src/gnu/expr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30219/src/gnu/expr Modified Files: LambdaExp.java Log Message: Do not copy the closure environment in constructors (fixes bug #1070579). Index: LambdaExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/gnu/expr/LambdaExp.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** LambdaExp.java 14 Apr 2004 15:12:07 -0000 1.25 --- LambdaExp.java 22 Nov 2004 21:37:05 -0000 1.26 *************** *** 1243,1247 **** code.emitInvokeSpecial(constructor); ! if (staticLinkField != null) { code.emitDup(heapFrame.getType()); --- 1243,1252 ---- code.emitInvokeSpecial(constructor); ! // In a constructor, the closure (this) is not valid until the ! // end, so it shouldn't be used (presumably it is not used ! // anyway). ! // There might be a deeper change that would make this test ! // unnecessary. ! if (staticLinkField != null && ! (this instanceof ConstructorExp)) { code.emitDup(heapFrame.getType()); |
From: Daniel B. <bo...@us...> - 2004-11-22 21:37:16
|
Update of /cvsroot/nice/Nice/testsuite/compiler/classes/constructors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30219/testsuite/compiler/classes/constructors Modified Files: custom.testsuite Log Message: Do not copy the closure environment in constructors (fixes bug #1070579). Index: custom.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/classes/constructors/custom.testsuite,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** custom.testsuite 21 Nov 2004 21:15:32 -0000 1.13 --- custom.testsuite 22 Nov 2004 21:37:04 -0000 1.14 *************** *** 122,130 **** /// Toplevel class A {} ! new /*/// FAIL HERE */A(int n) { this(n); } ! /// PASS bug // bug #1070579 let x = new X(5); --- 122,130 ---- /// Toplevel class A {} ! new /*/// FAIL HERE */A(int n) { this(n); } ! /// PASS // bug #1070579 let x = new X(5); *************** *** 134,138 **** int n = 0; void foo() { n++; } ! foo(); this(); } --- 134,138 ---- int n = 0; void foo() { n++; } ! foo(); this(); } |
From: Arjan B. <ar...@us...> - 2004-11-22 21:25:05
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27261/F:/nice/src/bossa/syntax Modified Files: dispatch.java.bootstrap Log Message: Removed superfluous methods from dispatch.java.bootstrap. Index: dispatch.java.bootstrap =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/dispatch.java.bootstrap,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** dispatch.java.bootstrap 21 Nov 2004 23:24:37 -0000 1.25 --- dispatch.java.bootstrap 22 Nov 2004 21:24:54 -0000 1.26 *************** *** 13,28 **** public class dispatch { - public static NiceClass createNiceClass(ClassDefinition cdef) - {return null;} - - public static Statement createReturnStmt(Expression value, boolean fake) - { return null; } - - public static Expression createLiteralArrayExp(List exps) - { return null; } - - public static Expression createNewExp(TypeIdent ti, Arguments arguments) - { return null; } - public static Expression createCallExp(Expression function, Expression param1) { return null; } --- 13,16 ---- *************** *** 81,90 **** { return false; } - public static Statement createBlock(List statements) - { return null; } - - public static ConstantExp createStringConstantExp(String value) - { return null; } - static Statement analyse(Statement s, VarScope v, TypeScope t, boolean r) { return null; } --- 69,72 ---- |
From: Arjan B. <ar...@us...> - 2004-11-22 14:41:08
|
Update of /cvsroot/nice/Nice/src/nice/tools/code In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23067/F:/nice/src/nice/tools/code Modified Files: Import.java Types.java Log Message: Made default retypings of array elements not null, cleanup of related code. Index: Import.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/code/Import.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Import.java 11 Aug 2004 16:09:35 -0000 1.6 --- Import.java 22 Nov 2004 14:40:58 -0000 1.7 *************** *** 94,121 **** (m.getDeclaringClass().getPackageName()); ! if (nonNullArgs) ! { ! for (int i = 0; i < paramTypes.length; i++) ! //arguments of a method are considered not null ! params[n++] = Types.monotype(paramTypes[i], true, typeParameters, ! niceTP, true); ! } else { ! for (int i = 0; i < paramTypes.length; i++) ! //arguments maybe null ! params[n++] = Types.monotype(paramTypes[i], false, typeParameters, ! niceTP, true); ! } - mlsub.typing.Monotype retType; - if (constructor) - { - // the return type is surely not null - retType = Types.monotype(declaringClass.thisType(), true, - typeParameters, niceTP); - } else { - // returntype not null. - retType = Types.monotype(m.getFullReturnType(), true, - typeParameters, niceTP, true); - } Constraint cst = niceTP == null ? null : new Constraint(niceTP, null); return new Polytype(cst, new FunType(params, retType)); --- 94,106 ---- (m.getDeclaringClass().getPackageName()); ! for (int i = 0; i < paramTypes.length; i++) ! params[n++] = Types.monotype(paramTypes[i], /*sure:*/nonNullArgs, ! typeParameters, niceTP); ! ! gnu.bytecode.Type javaRetType = ! constructor ? declaringClass.thisType() : m.getFullReturnType(); ! mlsub.typing.Monotype retType = ! Types.monotype(javaRetType, true, typeParameters, niceTP); Constraint cst = niceTP == null ? null : new Constraint(niceTP, null); return new Polytype(cst, new FunType(params, retType)); Index: Types.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/code/Types.java,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** Types.java 6 Nov 2004 11:23:07 -0000 1.60 --- Types.java 22 Nov 2004 14:40:58 -0000 1.61 *************** *** 319,323 **** Monotype[] res = new Monotype[len]; for (int i = 0; i < len; i++) ! res[i] = monotype(javaTypes[i], typeVariables, niceTypeVariables); return res; } --- 319,323 ---- Monotype[] res = new Monotype[len]; for (int i = 0; i < len; i++) ! res[i] = monotype(javaTypes[i], true, typeVariables, niceTypeVariables); return res; } *************** *** 329,373 **** } - public static Monotype monotype(Type javaType, boolean sure, - TypeVariable[] typeVariables, - TypeSymbol[] niceTypeVariables) - throws ParametricClassException, NotIntroducedClassException - { - return monotype(javaType, sure, typeVariables, niceTypeVariables, false); - } - - public static Monotype monotype(Type javaType) - throws ParametricClassException, NotIntroducedClassException - { - return monotype(javaType, null, null); - } - - public static Monotype monotype(Type javaType, - TypeVariable[] typeVariables, - TypeSymbol[] niceTypeVariables) - throws ParametricClassException, NotIntroducedClassException - { - Monotype res = getMonotype(javaType, typeVariables, niceTypeVariables); - if (javaType instanceof ObjectType && - ! (javaType instanceof TypeVariable)) - return bossa.syntax.Monotype.maybe(res); - else - // the sure is already there in getMonotype - return res; - } - /** Special version for use in Import.java, it always checks whether nullness info may be added. - And can handle arrays different(not yet implemented) */ public static Monotype monotype(Type javaType, boolean sure, TypeVariable[] typeVariables, ! TypeSymbol[] niceTypeVariables, ! boolean arraySure) throws ParametricClassException, NotIntroducedClassException { ! Monotype res = getMonotype(javaType, typeVariables, niceTypeVariables, ! arraySure); //primitivetypes and typevariables should not get nullness info if (javaType instanceof ObjectType && --- 329,342 ---- } /** Special version for use in Import.java, it always checks whether nullness info may be added. */ public static Monotype monotype(Type javaType, boolean sure, TypeVariable[] typeVariables, ! TypeSymbol[] niceTypeVariables) throws ParametricClassException, NotIntroducedClassException { ! Monotype res = getMonotype(javaType, typeVariables, niceTypeVariables); //primitivetypes and typevariables should not get nullness info if (javaType instanceof ObjectType && *************** *** 381,396 **** return res; } - private static Monotype getMonotype(Type javaType, - TypeVariable[] typeVariables, - TypeSymbol[] niceTypeVariables) - throws ParametricClassException, NotIntroducedClassException - { - return getMonotype(javaType, typeVariables, niceTypeVariables, false); - } private static Monotype getMonotype(Type javaType, TypeVariable[] typeVariables, ! TypeSymbol[] niceTypeVariables, ! boolean arraySure) throws ParametricClassException, NotIntroducedClassException { --- 350,357 ---- return res; } private static Monotype getMonotype(Type javaType, TypeVariable[] typeVariables, ! TypeSymbol[] niceTypeVariables) throws ParametricClassException, NotIntroducedClassException { *************** *** 415,434 **** if (javaType instanceof ArrayType) ! if (arraySure) ! //making the component of an array sure ! return new MonotypeConstructor ! (PrimitiveType.arrayTC, new Monotype[]{ monotype(((ArrayType) javaType).getComponentType(), true, ! typeVariables, niceTypeVariables, true) }); ! else ! return new MonotypeConstructor ! (PrimitiveType.arrayTC, ! new Monotype[]{ ! monotype(((ArrayType) javaType).getComponentType(), ! typeVariables, niceTypeVariables) ! }); ! if (javaType instanceof ParameterizedType) { --- 376,385 ---- if (javaType instanceof ArrayType) ! return new MonotypeConstructor(PrimitiveType.arrayTC, new Monotype[]{ monotype(((ArrayType) javaType).getComponentType(), true, ! typeVariables, niceTypeVariables) }); ! if (javaType instanceof ParameterizedType) { |
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7158/F:/nice/src/bossa/syntax Modified Files: Arguments.java Constructor.java CustomConstructor.java FormalParameters.java MethodBodyDefinition.java MethodDeclaration.java NiceClass.java Node.java VarSymbol.java dispatch.java.bootstrap new.nice niceclass.nice tools.nice Added Files: symbol.nice Removed Files: FunSymbol.java PolySymbol.java Log Message: Converted PolySymbol and subclasses. (patch by Luc Perrin) Index: dispatch.java.bootstrap =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/dispatch.java.bootstrap,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** dispatch.java.bootstrap 5 Nov 2004 14:57:57 -0000 1.24 --- dispatch.java.bootstrap 21 Nov 2004 23:24:37 -0000 1.25 *************** *** 31,34 **** --- 31,43 ---- { return null; } + public static VarSymbol createMethodSymbol(MethodDeclaration declaration, LocatedString name, Constraint constraint, Monotype returnType) + { return null; } + + public static VarSymbol createMethodSymbol(MethodDeclaration declaration, LocatedString name, mlsub.typing.Polytype type) + { return null; } + + public static VarSymbol createConstructorCallSymbol(MethodDeclaration declaration, LocatedString name, mlsub.typing.Polytype type) + { return null; } + public static gnu.bytecode.Method getImplementationAbove(JavaMethod decl, gnu.bytecode.ClassType firstArg) { return null; } Index: Constructor.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Constructor.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Constructor.java 6 Nov 2004 19:39:50 -0000 1.15 --- Constructor.java 21 Nov 2004 23:24:36 -0000 1.16 *************** *** 65,75 **** (getType().getConstraint(), new mlsub.typing.FunType(getArgTypes(), PrimitiveType.voidType)); ! classe.addConstructorCallSymbol ! (new MethodDeclaration.Symbol(name, type) { ! gnu.expr.Expression compileInCallPosition() ! { ! return getInitializationCode(true); ! } ! }); } --- 65,70 ---- (getType().getConstraint(), new mlsub.typing.FunType(getArgTypes(), PrimitiveType.voidType)); ! classe.addConstructorCallSymbol( ! dispatch.createConstructorCallSymbol(this, name, type)); } Index: Node.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Node.java,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** Node.java 17 Jun 2004 12:15:50 -0000 1.60 --- Node.java 21 Nov 2004 23:24:37 -0000 1.61 *************** *** 70,73 **** --- 70,78 ---- children.remove(n); } + + void removeChildren() + { + children = null; + } /** Index: CustomConstructor.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/CustomConstructor.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** CustomConstructor.java 19 Nov 2004 22:24:59 -0000 1.23 --- CustomConstructor.java 21 Nov 2004 23:24:36 -0000 1.24 *************** *** 78,88 **** (getType().getConstraint(), new mlsub.typing.FunType(getArgTypes(), PrimitiveType.voidType)); ! classe.addConstructorCallSymbol ! (new MethodDeclaration.Symbol(name, type) { ! gnu.expr.Expression compileInCallPosition() ! { ! return getInitializationCode(true); ! } ! }); } --- 78,83 ---- (getType().getConstraint(), new mlsub.typing.FunType(getArgTypes(), PrimitiveType.voidType)); ! classe.addConstructorCallSymbol( ! dispatch.createConstructorCallSymbol(this, name, type)); } Index: NiceClass.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/NiceClass.java,v retrieving revision 1.93 retrieving revision 1.94 diff -C2 -d -r1.93 -r1.94 *** NiceClass.java 18 Nov 2004 17:31:15 -0000 1.93 --- NiceClass.java 21 Nov 2004 23:24:36 -0000 1.94 *************** *** 56,60 **** } ! abstract void addConstructorCallSymbol(MethodDeclaration.Symbol sym); abstract public void addField(MonoSymbol sym, Expression value, --- 56,61 ---- } ! // FIXME change to MethodSymbol once this is converted to nice ! abstract void addConstructorCallSymbol(VarSymbol sym); abstract public void addField(MonoSymbol sym, Expression value, --- PolySymbol.java DELETED --- Index: niceclass.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/niceclass.nice,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** niceclass.nice 18 Nov 2004 17:31:16 -0000 1.4 --- niceclass.nice 21 Nov 2004 23:24:37 -0000 1.5 *************** *** 33,37 **** /** List of symbols for calling constructors of this class. */ ! private List<MethodDeclaration.Symbol> constructors = new ArrayList(); private Constructor[?] constructorMethod = null; --- 33,37 ---- /** List of symbols for calling constructors of this class. */ ! private List<MethodSymbol> constructors = new ArrayList(); private Constructor[?] constructorMethod = null; *************** *** 111,118 **** addConstructorCallSymbol(sym) { ! constructors.add(sym); } ! List<MethodDeclaration.Symbol> getConstructorCallSymbols() = new LinkedList(constructors); resolveClass() --- 111,118 ---- addConstructorCallSymbol(sym) { ! constructors.add(cast(sym)); } ! List<MethodSymbol> getConstructorCallSymbols() = new LinkedList(constructors); resolveClass() --- FunSymbol.java DELETED --- Index: FormalParameters.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/FormalParameters.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** FormalParameters.java 6 Nov 2004 19:39:50 -0000 1.43 --- FormalParameters.java 21 Nov 2004 23:24:36 -0000 1.44 *************** *** 417,421 **** including the default values of the optional parameters not passed. */ ! boolean match(Arguments args, FunSymbol symbol) { int[] map = new int[size]; --- 417,422 ---- including the default values of the optional parameters not passed. */ ! // FIXME change VarSymbol to FunSymbol once converted to nice ! boolean match(Arguments args, VarSymbol symbol) { int[] map = new int[size]; Index: new.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/new.nice,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** new.nice 5 Nov 2004 14:57:57 -0000 1.5 --- new.nice 21 Nov 2004 23:24:37 -0000 1.6 *************** *** 60,64 **** definition.resolve(); ! ?LinkedList<MethodDeclaration.Symbol> constructors = TypeConstructors.getConstructors(tc); if (constructors == null) { --- 60,64 ---- definition.resolve(); ! let constructors = TypeConstructors.getConstructors(tc); if (constructors == null) { --- NEW FILE: symbol.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package bossa.syntax; /** A variable symbol which has a polytype (eg a method symbol) @see MonoSymbol */ public class PolySymbol extends VarSymbol { ?mlsub.typing.Polytype type = null; ?mlsub.typing.Polytype clonedType = null; ?bossa.syntax.Polytype syntacticType = null; { if(syntacticType!=null) this.addChild(syntacticType); } getType() = notNull(type); isAssignable() = false; // No polymorphic references! resolve() { type = notNull(syntacticType).resolveToLowlevel(); syntacticType = null; this.removeChildren(); } makeClonedType() { if (clonedType != null) Internal.error(this, "clonedType in use"); clonedType = notNull(type).cloneType(); } releaseClonedType() { clonedType = null; } getClonedType() = notNull(clonedType); toString() { ?mlsub.typing.Polytype type = this.type; return (type==null ? String.valueOf(notNull(syntacticType)) : type.toString()) + " " + name; } } new PolySymbol( MonoSymbol sym ) { this(sym.name, syntacticType : new Polytype(sym.syntacticType)); } /** * A functional symbol. */ class FunSymbol extends PolySymbol { ?FormalParameters parameters; int arity; isFunSymbol() = true; getFormalParameters() = this.parameters; String describeParameters() { ?FormalParameters parameters = this.parameters; if (parameters != null) return parameters.toString(); mlsub.typing.Monotype m = nice.tools.typing.Types.rawType( notNull(this.getType()).getMonotype()); if (m instanceof mlsub.typing.FunType) return bossa.util.Util.map("", ", ", "", m.domain()); bossa.util.Internal.warning(this, "Non functional type in a functional symbol"); return ""; } /** @return 0 : doesn't match 1 : wasn't even a function 2 : matches */ match(Arguments arguments) { let parameters = this.parameters; if (parameters == null) { // true for constructors, for instance. case might be removed if (!arguments.plainApplication(arity, this)) return 0; } else if (!parameters.match(arguments, this)) return 0; return 2; } String explainWhyMatchFailsWithFunSymbol(Arguments arguments) { if (this.isFieldAccess()) { if (arguments.size() == 0) return name + " is not defined"; return name + " is a field of class " + this.describeParameters(); } return "Method " + name + " expects parameters (" + this.describeParameters() + ")"; } explainWhyMatchFails(Arguments arguments) = this.explainWhyMatchFailsWithFunSymbol(arguments); } new FunSymbol(LocatedString name, Constraint constraint, FormalParameters parameters, Monotype returnType) { this(name, parameters: parameters, arity: parameters.size, syntacticType: new Polytype(constraint, new FunType(parameters.types(), returnType))); } /** * A symbol for a declared method. */ public class MethodSymbol extends FunSymbol { MethodDeclaration declaration; getFieldAccessMethod() { let decl = this.declaration; if(decl instanceof FieldAccess) return decl; return null; } isIgnored() = this.declaration.isIgnored(); checkSpecialRequirements(arguments) = this.declaration.checkSpecialRequirements(arguments); resolve() { if (this.isIgnored()) return; // Check that resolving has not already been done. if (syntacticType != null) { super; // The method has a raw type, while the symbol needs a nullness marker declaration.type = this.type; this.type = nice.tools.typing.Types.addSure(this.type); } } getDefinition() = this.declaration; getMethodDeclaration() = this.declaration; compile() = this.declaration.getCode(); compileInCallPosition() = declaration.getCodeInCallPosition(); toString() = this.declaration.toString(); explainWhyMatchFails(Arguments arguments) = this.declaration.explainWhyMatchFails(arguments); defaultExplainWhyMatchFails(Arguments arguments) = this.explainWhyMatchFailsWithFunSymbol(arguments); } new MethodSymbol(MethodDeclaration declaration, LocatedString name, Constraint constraint, Monotype returnType ) { FormalParameters parameters = declaration.formalParameters(); this(name, declaration: declaration, parameters: parameters, arity: parameters.size, syntacticType: new Polytype(constraint, new FunType(parameters.types(), returnType))); } new MethodSymbol(MethodDeclaration declaration, LocatedString name, mlsub.typing.Polytype type) { this(name, declaration: declaration, type: nice.tools.typing.Types.addSure(type), parameters: declaration.formalParameters(), arity: declaration.arity); } // FIXME if CustomConstructor is made to extend Constructor, this code can be cleaned up class ConstructorCallSymbol extends MethodSymbol { compileInCallPosition() { let decl = this.declaration; if (decl instanceof bossa.syntax.Constructor) return decl.getInitializationCode(true); else if (decl instanceof bossa.syntax.CustomConstructor) return decl.getInitializationCode(true); Internal.error("Declaration associated with ConstructorCallSymbol is not a constructor."); return super; } } // Bootstrap (for conversion to nice) VarSymbol createMethodSymbol(MethodDeclaration declaration, LocatedString name, Constraint constraint, Monotype returnType ) = new MethodSymbol(declaration,name,constraint,returnType); VarSymbol createMethodSymbol(MethodDeclaration declaration, LocatedString name, mlsub.typing.Polytype type ) = new MethodSymbol(declaration,name,type); VarSymbol createConstructorCallSymbol(MethodDeclaration declaration, LocatedString name, mlsub.typing.Polytype type ) = new ConstructorCallSymbol(declaration,name,type); Index: MethodDeclaration.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MethodDeclaration.java,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** MethodDeclaration.java 12 Oct 2004 23:35:48 -0000 1.62 --- MethodDeclaration.java 21 Nov 2004 23:24:36 -0000 1.63 *************** *** 64,68 **** syntacticConstraint = constraint.toString(); ! symbol = new MethodDeclaration.Symbol(name, constraint, returnType); symbol.propagate = Node.global; addChild(symbol); --- 64,68 ---- syntacticConstraint = constraint.toString(); ! symbol = dispatch.createMethodSymbol(this, name, constraint, returnType); symbol.propagate = Node.global; addChild(symbol); *************** *** 101,108 **** this.arity = type.domain().length; this.type = type; ! symbol = new MethodDeclaration.Symbol(name, type); } ! private Polytype type; public final Polytype getType() --- 101,108 ---- this.arity = type.domain().length; this.type = type; ! symbol = dispatch.createMethodSymbol(this, name, type); } ! Polytype type; public final Polytype getType() *************** *** 318,410 **** } ! private MethodDeclaration.Symbol symbol; ! MethodDeclaration.Symbol getSymbol() { return symbol; } ! ! public class Symbol extends FunSymbol ! { ! Symbol(LocatedString name, bossa.syntax.Constraint constraint, ! bossa.syntax.Monotype returnType) ! { ! super(name, constraint, ! MethodDeclaration.this.formalParameters(), ! returnType); ! } ! ! Symbol(LocatedString name, Polytype type) ! { ! super(name, Types.addSure(type), ! MethodDeclaration.this.formalParameters(), ! MethodDeclaration.this.arity); ! } ! ! FieldAccess getFieldAccessMethod() ! { ! if(getMethodDeclaration() instanceof FieldAccess) ! return (FieldAccess) getMethodDeclaration(); ! ! return null; ! } ! ! boolean isIgnored() ! { ! return getMethodDeclaration().isIgnored(); ! } ! ! void checkSpecialRequirements(Expression[] arguments) ! { ! getMethodDeclaration().checkSpecialRequirements(arguments); ! } ! ! void resolve() ! { ! if (isIgnored()) ! return; ! ! // Check that resolving has not already been done. ! if (syntacticType != null) ! { ! super.resolve(); ! ! // The method has a raw type, while the symbol needs a nullness marker ! MethodDeclaration.this.type = this.type; ! this.type = Types.addSure(this.type); ! } ! } ! ! public Definition getDefinition() ! { ! return MethodDeclaration.this; ! } ! ! public MethodDeclaration getMethodDeclaration() ! { ! return MethodDeclaration.this; ! } ! ! gnu.expr.Expression compile() ! { ! return getMethodDeclaration().getCode(); ! } ! ! gnu.expr.Expression compileInCallPosition() ! { ! return getMethodDeclaration().getCodeInCallPosition(); ! } ! ! String explainWhyMatchFails(Arguments arguments) ! { ! return getMethodDeclaration().explainWhyMatchFails(arguments); ! } ! ! String defaultExplainWhyMatchFails(Arguments arguments) ! { ! return super.explainWhyMatchFails(arguments); ! } ! ! public String toString() ! { ! return getMethodDeclaration().toString(); ! } ! } /**************************************************************** --- 318,324 ---- } ! // FIXME: once this class is converted to nice, Change VarSymbol to MethodSymbol ! private VarSymbol symbol; ! VarSymbol getSymbol() { return symbol; } /**************************************************************** Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** tools.nice 21 Nov 2004 18:33:17 -0000 1.61 --- tools.nice 21 Nov 2004 23:24:37 -0000 1.62 *************** *** 198,202 **** <T> String map(String, String, String, Collection<T>) = native String bossa.util.Util.map(String, String, String, Collection); Stack<bossa.link.Alternative> sortedAlternatives(MethodDeclaration) = native Stack bossa.link.Alternative.sortedAlternatives(MethodDeclaration); ! LinkedList<VarSymbol> getConstructors(mlsub.typing.TypeConstructor) = native LinkedList TypeConstructors.getConstructors(mlsub.typing.TypeConstructor); void addValues(Pattern, List<ConstantExp>) = native void Pattern.addValues(List); ?mlsub.typing.TypeConstructor getRuntimeTC(Pattern) = native mlsub.typing.TypeConstructor Pattern.getRuntimeTC(); --- 198,202 ---- <T> String map(String, String, String, Collection<T>) = native String bossa.util.Util.map(String, String, String, Collection); Stack<bossa.link.Alternative> sortedAlternatives(MethodDeclaration) = native Stack bossa.link.Alternative.sortedAlternatives(MethodDeclaration); ! ?LinkedList<VarSymbol> getConstructors(mlsub.typing.TypeConstructor) = native LinkedList TypeConstructors.getConstructors(mlsub.typing.TypeConstructor); void addValues(Pattern, List<ConstantExp>) = native void Pattern.addValues(List); ?mlsub.typing.TypeConstructor getRuntimeTC(Pattern) = native mlsub.typing.TypeConstructor Pattern.getRuntimeTC(); *************** *** 207,210 **** --- 207,211 ---- ?FieldAccess getFieldAccessMethod(Expression) = native FieldAccess Expression.getFieldAccessMethod(); ?FieldAccess getField(Expression) = native FieldAccess Expression.getField(); + ?FieldAccess getFieldAccessMethod(VarSymbol) = native FieldAccess VarSymbol.getFieldAccessMethod(); ?mlsub.typing.Monotype Types_getTypeParameter(mlsub.typing.Polytype, int) = native mlsub.typing.Monotype nice.tools.typing.Types.getTypeParameter(mlsub.typing.Polytype, int); ?mlsub.typing.Monotype Types_getTypeParameter(mlsub.typing.Monotype, int) = native mlsub.typing.Monotype nice.tools.typing.Types.getTypeParameter(mlsub.typing.Monotype, int); *************** *** 220,224 **** FormalParameters parameters(MethodDeclaration) = native MethodDeclaration.parameters; ?gnu.expr.Expression getInitializer(NiceClass) = native gnu.expr.Expression NiceClass.getInitializer(); ! void addConstructorCallSymbol(NiceClass, MethodDeclaration.Symbol) = native void NiceClass.addConstructorCallSymbol(MethodDeclaration.Symbol); gnu.expr.Expression callSuperMethod(NiceClass, gnu.bytecode.Method) = native gnu.expr.Expression NiceClass.callSuperMethod(gnu.bytecode.Method); Module module(Definition) = native Definition.module; --- 221,225 ---- FormalParameters parameters(MethodDeclaration) = native MethodDeclaration.parameters; ?gnu.expr.Expression getInitializer(NiceClass) = native gnu.expr.Expression NiceClass.getInitializer(); ! void addConstructorCallSymbol(NiceClass, VarSymbol) = native void NiceClass.addConstructorCallSymbol(VarSymbol); gnu.expr.Expression callSuperMethod(NiceClass, gnu.bytecode.Method) = native gnu.expr.Expression NiceClass.callSuperMethod(gnu.bytecode.Method); Module module(Definition) = native Definition.module; *************** *** 231,235 **** mlsub.typing.TypeSymbol[?] getBinders(MethodContainer) = native mlsub.typing.TypeSymbol[] MethodContainer.getBinders(); ?Expression value(FormalParameters.Parameter) = native Expression FormalParameters.Parameter.value(); ! ?LinkedList<MethodDeclaration.Symbol> getConstructors(TypeConstructor) = native LinkedList TypeConstructors.getConstructors(TypeConstructor); ?gnu.bytecode.Attribute get(gnu.bytecode.AttrContainer, String) = native gnu.bytecode.Attribute gnu.bytecode.Attribute.get(gnu.bytecode.AttrContainer, String); void printInterface(Definition, java.io.PrintWriter) = native void Definition.printInterface(java.io.PrintWriter); --- 232,236 ---- mlsub.typing.TypeSymbol[?] getBinders(MethodContainer) = native mlsub.typing.TypeSymbol[] MethodContainer.getBinders(); ?Expression value(FormalParameters.Parameter) = native Expression FormalParameters.Parameter.value(); ! ?LinkedList<MethodSymbol> getConstructors(TypeConstructor) = native LinkedList TypeConstructors.getConstructors(TypeConstructor); ?gnu.bytecode.Attribute get(gnu.bytecode.AttrContainer, String) = native gnu.bytecode.Attribute gnu.bytecode.Attribute.get(gnu.bytecode.AttrContainer, String); void printInterface(Definition, java.io.PrintWriter) = native void Definition.printInterface(java.io.PrintWriter); *************** *** 239,242 **** --- 240,244 ---- ClassDefinition.Class ClassDefinition_makeClass(LocatedString, boolean, boolean, ?MethodContainer.Constraint, List<?boolean>, MonotypeConstructor, ?List<TypeIdent>, ?List<TypeIdent>) = native ClassDefinition.Class ClassDefinition.makeClass(LocatedString, boolean, boolean, MethodContainer.Constraint, List, MonotypeConstructor, List, List); MethodBodyDefinition MethodBodyDefinition(NiceClass, LocatedString, ?Collection<LocatedString>, List<Pattern>, Statement) = native new MethodBodyDefinition(NiceClass, LocatedString, Collection, List, Statement); + ?FormalParameters getFormalParameters(VarSymbol) = native FormalParameters VarSymbol.getFormalParameters(); // Retypings needed since java types are not strict. Index: MethodBodyDefinition.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MethodBodyDefinition.java,v retrieving revision 1.156 retrieving revision 1.157 diff -C2 -d -r1.156 -r1.157 *** MethodBodyDefinition.java 5 Nov 2004 15:42:42 -0000 1.156 --- MethodBodyDefinition.java 21 Nov 2004 23:24:36 -0000 1.157 *************** *** 221,225 **** if (symbols.size() > 1 && hasAdditionalTags) { ! MethodDeclaration.Symbol[] tempSymbols = new MethodDeclaration.Symbol[symbols.size()]; symbols.toArray(tempSymbols); int size = symbols.size(); --- 221,226 ---- if (symbols.size() > 1 && hasAdditionalTags) { ! // FIXME change to MethodSymbol[] once converted to nice. ! VarSymbol[] tempSymbols = new VarSymbol[symbols.size()]; symbols.toArray(tempSymbols); int size = symbols.size(); *************** *** 268,272 **** // Check that the non-dispatched parameter names match the declaration outer: for(Iterator it = symbols.iterator(); it.hasNext();) { ! MethodDeclaration m = ((MethodDeclaration.Symbol) it.next()).getMethodDeclaration(); if( m instanceof NiceMethod) { FormalParameters params = m.formalParameters(); --- 269,273 ---- // Check that the non-dispatched parameter names match the declaration outer: for(Iterator it = symbols.iterator(); it.hasNext();) { ! MethodDeclaration m = ((VarSymbol) it.next()).getMethodDeclaration(); if( m instanceof NiceMethod) { FormalParameters params = m.formalParameters(); *************** *** 301,306 **** for(Iterator i = symbols.iterator(); i.hasNext();) { ! MethodDeclaration m = ! ((MethodDeclaration.Symbol) i.next()).getMethodDeclaration(); methods += m + " defined " + m.location() + "\n"; } --- 302,306 ---- for(Iterator i = symbols.iterator(); i.hasNext();) { ! MethodDeclaration m = ((VarSymbol) i.next()).getMethodDeclaration(); methods += m + " defined " + m.location() + "\n"; } Index: Arguments.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Arguments.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** Arguments.java 6 Nov 2004 19:39:50 -0000 1.27 --- Arguments.java 21 Nov 2004 23:24:36 -0000 1.28 *************** *** 235,241 **** for (Iterator i = noMatches.iterator(); i.hasNext();) { ! Object noMatch = i.next(); ! if (noMatch instanceof FunSymbol) ! argnames.retainAll(noMatchByName(((FunSymbol)noMatch).parameters)); } if (!argnames.isEmpty()) --- 235,241 ---- for (Iterator i = noMatches.iterator(); i.hasNext();) { ! VarSymbol noMatch = (VarSymbol)i.next(); ! if (noMatch.isFunSymbol()) ! argnames.retainAll(noMatchByName(noMatch.getFormalParameters())); } if (!argnames.isEmpty()) Index: VarSymbol.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/VarSymbol.java,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** VarSymbol.java 23 Jun 2004 19:38:09 -0000 1.37 --- VarSymbol.java 21 Nov 2004 23:24:37 -0000 1.38 *************** *** 86,89 **** --- 86,102 ---- } + boolean isFunSymbol() + { + return false; + } + + /** + * Get the FormalParameters, or null if this is not a functional symbol + */ + FormalParameters getFormalParameters() + { + return null; + } + abstract Polytype getType(); *************** *** 103,106 **** --- 116,127 ---- } + /** + * Specialized by MethodSymbol only. + */ + String defaultExplainWhyMatchFails(Arguments arguments) + { + return explainWhyMatchFails(arguments); + } + /** This returns a generic explanation. A more precise message should be returned if possible in subclasses. |
From: Arjan B. <ar...@us...> - 2004-11-21 23:17:38
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29374/F:/nice/src/bossa/syntax Modified Files: enum.nice Log Message: Removed debugging statement. Index: enum.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/enum.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** enum.nice 21 Nov 2004 18:33:17 -0000 1.1 --- enum.nice 21 Nov 2004 22:36:56 -0000 1.2 *************** *** 31,35 **** { symbols.add(sym); - bossa.util.Debug.println("adding: "+sym); this.addChild(sym); } --- 31,34 ---- *************** *** 86,90 **** elements.map(LocatedString elem => new IdentExp(elem))), true))); - bossa.util.Debug.println("name: "+shortName); //generate the prettyprint string String repr = "enum " + shortName; --- 85,88 ---- |
From: Arjan B. <ar...@us...> - 2004-11-21 21:16:44
|
Update of /cvsroot/nice/Nice/testsuite/compiler/classes/constructors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11866/F:/nice/testsuite/compiler/classes/constructors Modified Files: custom.testsuite Log Message: Testcase for bug #1070579. Index: custom.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/classes/constructors/custom.testsuite,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** custom.testsuite 19 Nov 2004 22:24:59 -0000 1.12 --- custom.testsuite 21 Nov 2004 21:15:32 -0000 1.13 *************** *** 125,126 **** --- 125,138 ---- this(n); } + + /// PASS bug + // bug #1070579 + let x = new X(5); + /// Toplevel + class X {} + new X(int a) { + int n = 0; + void foo() { n++; } + foo(); + this(); + } |
From: Arjan B. <ar...@us...> - 2004-11-21 19:32:31
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10969/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Converted EnumDefinition. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.273 retrieving revision 1.274 diff -C2 -d -r1.273 -r1.274 *** Parser.jj 7 Nov 2004 01:07:25 -0000 1.273 --- Parser.jj 21 Nov 2004 18:33:17 -0000 1.274 *************** *** 1238,1242 **** ( "," enumElement(elements, argsList) )+ "}" ! { return new EnumDefinition(name, elements, fields, argsList, definitions, imp); } } --- 1238,1242 ---- ( "," enumElement(elements, argsList) )+ "}" ! { return bossa.syntax.dispatch.createEnumDefinition(name, elements, fields, argsList, definitions, imp); } } |
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10969/F:/nice/src/bossa/syntax Modified Files: AST.java Definition.java MonoSymbol.java literalarray.nice pattern.nice tools.nice Added Files: enum.nice Removed Files: EnumDefinition.java Log Message: Converted EnumDefinition. Index: Definition.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Definition.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** Definition.java 7 Nov 2004 01:07:26 -0000 1.23 --- Definition.java 21 Nov 2004 18:33:17 -0000 1.24 *************** *** 83,86 **** --- 83,96 ---- } + boolean isEnumDefinition() + { + return false; + } + + ClassDefinition getEnumClass() + { + return null; + } + /**************************************************************** * Name and location of the definition Index: AST.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/AST.java,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** AST.java 7 Nov 2004 01:07:26 -0000 1.59 --- AST.java 21 Nov 2004 18:33:17 -0000 1.60 *************** *** 65,70 **** else if (node instanceof MethodBodyDefinition) methodImplementations.add(node); ! else if (node instanceof EnumDefinition) ! classes.add(((EnumDefinition)node).classDef); else if (node.isGlobalVarDeclaration()) globals.add(node); --- 65,70 ---- else if (node instanceof MethodBodyDefinition) methodImplementations.add(node); ! else if (node.isEnumDefinition()) ! classes.add(node.getEnumClass()); else if (node.isGlobalVarDeclaration()) globals.add(node); Index: pattern.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/pattern.nice,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** pattern.nice 7 Nov 2004 01:07:26 -0000 1.8 --- pattern.nice 21 Nov 2004 18:33:17 -0000 1.9 *************** *** 244,250 **** addValues(values) { ! let EnumDefinition.EnumSymbol esym = cast(atValue.value); ! let EnumDefinition edef = cast(esym.getDefinition()); ! for (sym : edef.symbols) values.add(new ConstantExp(null, tc, sym, sym.name.toString(), this.location)); } --- 244,249 ---- addValues(values) { ! let EnumSymbol esym = cast(atValue.value); ! for (sym : esym.getDefinition().symbols) values.add(new ConstantExp(null, tc, sym, sym.name.toString(), this.location)); } *************** *** 468,472 **** for (sym : Node.getGlobalScope().lookup(refName)) if (sym instanceof GlobalVarSymbol || ! sym instanceof EnumDefinition.EnumSymbol ) return sym; --- 467,471 ---- for (sym : Node.getGlobalScope().lookup(refName)) if (sym instanceof GlobalVarSymbol || ! sym instanceof EnumSymbol ) return sym; *************** *** 507,511 **** return pattern; ! if (symbol instanceof EnumDefinition.EnumSymbol) { NewExp val = cast(symbol.getValue()); --- 506,510 ---- return pattern; ! if (symbol instanceof EnumSymbol) { NewExp val = cast(symbol.getValue()); Index: literalarray.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/literalarray.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** literalarray.nice 30 Jul 2004 18:31:10 -0000 1.2 --- literalarray.nice 21 Nov 2004 18:33:17 -0000 1.3 *************** *** 20,27 **** The array type is infered as the minimal possible type. */ - public class LiteralArrayExp extends Expression { - Expression[] elements; --- 20,25 ---- --- EnumDefinition.java DELETED --- Index: MonoSymbol.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MonoSymbol.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** MonoSymbol.java 23 Jun 2004 19:38:09 -0000 1.30 --- MonoSymbol.java 21 Nov 2004 18:33:17 -0000 1.31 *************** *** 156,159 **** --- 156,162 ---- public String toString() { + if (type == null) + return syntacticType+" "+name; + return type+" "+name; } Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** tools.nice 18 Nov 2004 17:31:16 -0000 1.60 --- tools.nice 21 Nov 2004 18:33:17 -0000 1.61 *************** *** 199,203 **** Stack<bossa.link.Alternative> sortedAlternatives(MethodDeclaration) = native Stack bossa.link.Alternative.sortedAlternatives(MethodDeclaration); LinkedList<VarSymbol> getConstructors(mlsub.typing.TypeConstructor) = native LinkedList TypeConstructors.getConstructors(mlsub.typing.TypeConstructor); - List<VarSymbol> symbols(EnumDefinition) = native EnumDefinition.symbols; void addValues(Pattern, List<ConstantExp>) = native void Pattern.addValues(List); ?mlsub.typing.TypeConstructor getRuntimeTC(Pattern) = native mlsub.typing.TypeConstructor Pattern.getRuntimeTC(); --- 199,202 ---- *************** *** 238,241 **** --- 237,242 ---- void printInterface(ClassImplementation, java.io.PrintWriter) = native void ClassImplementation.printInterface(java.io.PrintWriter); ?gnu.bytecode.Type TypeImport_lookup(LocatedString) = native gnu.bytecode.Type nice.tools.code.TypeImport.lookup(LocatedString); + ClassDefinition.Class ClassDefinition_makeClass(LocatedString, boolean, boolean, ?MethodContainer.Constraint, List<?boolean>, MonotypeConstructor, ?List<TypeIdent>, ?List<TypeIdent>) = native ClassDefinition.Class ClassDefinition.makeClass(LocatedString, boolean, boolean, MethodContainer.Constraint, List, MonotypeConstructor, List, List); + MethodBodyDefinition MethodBodyDefinition(NiceClass, LocatedString, ?Collection<LocatedString>, List<Pattern>, Statement) = native new MethodBodyDefinition(NiceClass, LocatedString, Collection, List, Statement); // Retypings needed since java types are not strict. --- NEW FILE: enum.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package bossa.syntax; import bossa.util.*; /** Definition of an enum */ public class EnumDefinition extends Definition { ClassDefinition classDef; List<EnumSymbol> symbols; String representation; { this.addChild(classDef); } void addElement(EnumSymbol sym) { symbols.add(sym); bossa.util.Debug.println("adding: "+sym); this.addChild(sym); } isEnumDefinition() = true; getEnumClass() = classDef; resolve() { for (symbol : symbols) symbol.resolveValue(notNull(scope), notNull(typeScope)); } typecheck() { for (symbol : symbols) symbol.typecheckValue(); } printInterface(s) { s.print(representation+"\n"); } compile() { for (symbol : symbols) symbol.compileValue(); } toString() = representation; } public EnumDefinition createEnumDefinition(LocatedString name, List<LocatedString> elements, List<MonoSymbol> fields, List<List<Expression>> argsList, List<Definition> globalDefs, ?List<TypeIdent> interfaces) { let shortName = name.toString(); let classDef = ClassDefinition.makeClass (name,true,false, null, new ArrayList(), new MonotypeConstructor(new TypeIdent(new LocatedString("nice.lang.Enum", name.location())), null, name.location()), interfaces, null); let impl = createNiceClass(classDef); for (fieldsym : fields) impl.addField(fieldsym, null, true, false, false, null); classDef.setImplementation(impl); if (! notNull(Definition.currentModule).interfaceFile()) // create the method implementation of family() globalDefs.add(new MethodBodyDefinition(impl, new LocatedString("family"), null, new LinkedList(), createReturnStmt(createLiteralArrayExp( elements.map(LocatedString elem => new IdentExp(elem))), true))); bossa.util.Debug.println("name: "+shortName); //generate the prettyprint string String repr = "enum " + shortName; if (! fields.isEmpty()) repr += Util.map("(", ", ", ")", fields); if (interfaces != null) repr += " implements " + Util.map(""," , ","", interfaces); if (fields.isEmpty()) repr += Util.map(" {", " , ", " }", elements); else { repr += " {"; for (int i = 0; i < elements.size(); i++) { if (i != 0) repr += ", "; repr += elements[i] + Util.map("(", ", ", ")", argsList[i]); } repr += "}"; } let res = new EnumDefinition(name, Node.global, classDef: classDef, symbols: new ArrayList(), representation: repr); for (int ord = 0; ord<elements.size(); ord++) { if (argsList[ord].size() != fields.size()) User.error(elements[ord], "the number of arguments doesn't match the number of enum fields"); res.addElement(createEnumSymbol(res, name, elements[ord], ord, fields, argsList[ord])); } return res; } class EnumSymbol extends MonoSymbol { EnumDefinition definition; Expression value; isAssignable() = false; getDeclaration() { ?gnu.expr.Declaration res = super; if (res == null) { res = new gnu.expr.Declaration(name.toString(), nice.tools.code.Types.javaType(type)); this.setDeclaration(res); definition.module.addGlobalVar(res, true); } return res; } void resolveValue(VarScope scope, TypeScope typeScope) { value = analyse(value, scope, typeScope); } void typecheckValue() { try { value = value.resolveOverloading(this.getType()); typecheck(value); mlsub.typing.Typing.leq(value.getType(), this.getType()); } catch(TypingEx e) { Internal.error(this,"Typing error in enum:"); } } void compileValue() { let declaration = this.getDeclaration(); notNull(declaration).setFlag(gnu.expr.Declaration.IS_CONSTANT); notNull(declaration).noteValue(value.compile()); } Expression getValue() { return value; } override EnumDefinition getDefinition() = definition; } EnumSymbol createEnumSymbol(EnumDefinition def, LocatedString enumName, LocatedString name, int ordinal, List<MonoSymbol> fields, List<Expression> argExps) { Monotype type = new TypeIdent(enumName); type.nullness = Monotype.absent; List<Arguments.Argument> args = new ArrayList(2 + fields.size()); args.add(new Arguments.Argument(createStringConstantExp(name.toString()), new LocatedString("name",name.location))); args.add(new Arguments.Argument(new ConstantExp(PrimitiveType.intTC, ordinal, ordinal.toString(), name.location()), new LocatedString("ordinal", name.location))); for (int i = 0; i < fields.size(); i++) args.add(new Arguments.Argument(argExps[i], fields[i].getName())); return new EnumSymbol(name, type, definition: def, value: createNewExp(new TypeIdent(enumName), new Arguments(args))); } |
From: Arjan B. <ar...@us...> - 2004-11-21 16:27:42
|
Update of /cvsroot/nice/Nice/testsuite/compiler/abstractInterfaces In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17491/F:/nice/testsuite/compiler/abstractInterfaces Modified Files: existingClass.testsuite Log Message: Testcase for primitives implementing an interface. Index: existingClass.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/abstractInterfaces/existingClass.testsuite,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** existingClass.testsuite 11 Oct 2004 16:21:05 -0000 1.9 --- existingClass.testsuite 21 Nov 2004 16:26:04 -0000 1.10 *************** *** 123,124 **** --- 123,133 ---- interface /*/// FAIL HERE */ java.util.Collection implements ITest; test(Collection a) = "done"; + + /// FAIL + // a primitive can't implement a non abstract interface + /// Toplevel + interface I { + int foo(); + } + class /*/// FAIL HERE */nice.lang.int implements I; + foo(x) = x; |
From: Daniel B. <bo...@us...> - 2004-11-21 16:21:46
|
Update of /cvsroot/nice/Nice/src/gnu/bytecode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16483/src/gnu/bytecode Modified Files: Access.java Log Message: Cleanup. Index: Access.java =================================================================== RCS file: /cvsroot/nice/Nice/src/gnu/bytecode/Access.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Access.java 6 Nov 2004 11:23:08 -0000 1.8 --- Access.java 21 Nov 2004 16:20:31 -0000 1.9 *************** *** 78,82 **** /*** ! * Returns true if classType is legally accessible in the given package. */ public static boolean legal(ClassType classType, String packageName) --- 78,82 ---- /*** ! * Returns true if classType is legally accessible in the given package. */ public static boolean legal(ClassType classType, String packageName) *************** *** 93,97 **** return false; ! return true; } } --- 93,97 ---- return false; ! return true; } } |
From: Arjan B. <ar...@us...> - 2004-11-20 00:39:51
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23526/F:/nice/src/bossa/syntax Modified Files: ClassDefinition.java Log Message: Avoid BadSizeEx with new fields in classes with fixed typeparams, fixes bug #1069263. Index: ClassDefinition.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/ClassDefinition.java,v retrieving revision 1.111 retrieving revision 1.112 diff -C2 -d -r1.111 -r1.112 *** ClassDefinition.java 18 Nov 2004 17:31:15 -0000 1.111 --- ClassDefinition.java 20 Nov 2004 00:39:42 -0000 1.112 *************** *** 479,485 **** public abstract mlsub.typing.Interface getAssociatedInterface(); ! protected mlsub.typing.Monotype lowlevelMonotype() { ! return new mlsub.typing.MonotypeConstructor(tc, getTypeParameters()); } --- 479,490 ---- public abstract mlsub.typing.Interface getAssociatedInterface(); ! mlsub.typing.Monotype lowlevelMonotype() { ! try { ! return new mlsub.typing.MonotypeConstructor(tc, getTypeParameters()); ! } ! catch(mlsub.typing.BadSizeEx e) { ! return toType(tc, getTypeParameters()); ! } } |
From: Arjan B. <ar...@us...> - 2004-11-20 00:39:51
|
Update of /cvsroot/nice/Nice/testsuite/compiler/classes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23526/F:/nice/testsuite/compiler/classes Modified Files: specialization.testsuite Log Message: Avoid BadSizeEx with new fields in classes with fixed typeparams, fixes bug #1069263. Index: specialization.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/classes/specialization.testsuite,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** specialization.testsuite 1 Sep 2004 12:06:50 -0000 1.3 --- specialization.testsuite 20 Nov 2004 00:39:42 -0000 1.4 *************** *** 48,49 **** --- 48,56 ---- /// Toplevel class Foo extends HashMap<String, String> {} + + /// PASS + /// Toplevel + class A<T> {} + class B extends A<String> { + int x; + } |
From: Arjan B. <ar...@us...> - 2004-11-19 22:25:09
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23324/F:/nice/src/bossa/syntax Modified Files: CustomConstructor.java Log Message: Check for cyclic custom constructor calls, fixes bug #1069263. Index: CustomConstructor.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/CustomConstructor.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** CustomConstructor.java 5 Nov 2004 14:57:57 -0000 1.22 --- CustomConstructor.java 19 Nov 2004 22:24:59 -0000 1.23 *************** *** 144,149 **** --- 144,156 ---- } + private boolean generatingCode = false; + protected gnu.expr.Expression computeCode() { + if (generatingCode) + User.error(this, "recursive custom constructor calls not allowed"); + + generatingCode = true; + ConstructorExp lambda = Gen.createCustomConstructor ((ClassType) javaReturnType(), javaArgTypes(), getSymbols()); *************** *** 152,155 **** --- 159,164 ---- classe.getClassExp().addMethod(lambda); + generatingCode = false; + // In the bytecode, we want to use the same type parameter names // as the class definition, even if the source of this custom constructor |
From: Arjan B. <ar...@us...> - 2004-11-19 22:25:09
|
Update of /cvsroot/nice/Nice/testsuite/compiler/classes/constructors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23324/F:/nice/testsuite/compiler/classes/constructors Modified Files: custom.testsuite Log Message: Check for cyclic custom constructor calls, fixes bug #1069263. Index: custom.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/classes/constructors/custom.testsuite,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** custom.testsuite 11 Jun 2004 05:01:38 -0000 1.11 --- custom.testsuite 19 Nov 2004 22:24:59 -0000 1.12 *************** *** 118,119 **** --- 118,126 ---- this(); } + + /// FAIL + /// Toplevel + class A {} + new /*/// FAIL HERE */A(int n) { + this(n); + } |
From: Arjan B. <ar...@us...> - 2004-11-18 17:31:27
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24235/F:/nice/src/bossa/syntax Modified Files: AbstractInterfaceImplementation.java ClassDefinition.java NiceClass.java PrimitiveType.java niceclass.nice tools.nice Added Files: ClassImplementation.java javaclass.nice Removed Files: JavaClass.java Log Message: Converted JavaClass and extracted ClassImplementation. --- JavaClass.java DELETED --- Index: ClassDefinition.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/ClassDefinition.java,v retrieving revision 1.110 retrieving revision 1.111 diff -C2 -d -r1.110 -r1.111 *** ClassDefinition.java 6 Nov 2004 11:23:07 -0000 1.110 --- ClassDefinition.java 18 Nov 2004 17:31:15 -0000 1.111 *************** *** 905,918 **** } - abstract static class ClassImplementation - { - abstract void resolveClass(); - void resolveBody() {} - void typecheck() {} - void compile() {} - void recompile() {} - abstract void printInterface(java.io.PrintWriter s); - } - ClassImplementation implementation; --- 905,908 ---- --- NEW FILE: ClassImplementation.java --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package bossa.syntax; public abstract class ClassImplementation { abstract void resolveClass(); void resolveBody() {} void typecheck() {} void compile() {} void recompile() {} abstract void printInterface(java.io.PrintWriter s); } Index: PrimitiveType.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/PrimitiveType.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** PrimitiveType.java 5 Aug 2004 19:01:18 -0000 1.13 --- PrimitiveType.java 18 Nov 2004 17:31:16 -0000 1.14 *************** *** 32,36 **** */ ! public class PrimitiveType extends ClassDefinition.ClassImplementation { public PrimitiveType(ClassDefinition definition) --- 32,36 ---- */ ! public class PrimitiveType extends ClassImplementation { public PrimitiveType(ClassDefinition definition) --- NEW FILE: javaclass.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package bossa.syntax; import bossa.util.*; /** A class definition which reflects an existing native java class. This is usefull when you want to add type parameters to an existing java class. */ public class JavaClass extends ClassImplementation { ClassDefinition definition; LocatedString javaName; boolean ignoredRetyping = false; { this.lookup(); } /** This must be called in a first pass, before bytecode types are implicitely loaded, so that the retyping is taken into account. */ private void lookup() { let classType = nice.tools.code.TypeImport.lookup(javaName); if (classType == null) { if (!definition.inInterfaceFile()) User.warning(javaName, javaName + " was not found in classpath so this retyping is ignored"); ignoredRetyping = true; return; } if (! (classType instanceof gnu.bytecode.ClassType)) throw User.error(definition, javaName + " is a primitive type"); // Check that we don't give a wrong arity to a generic class. int nativeArity = classType.getArity(); if (nativeArity != -1 && nativeArity != notNull(definition.tc).arity()) User.error(definition, javaName + " has " + nativeArity + " type parameters"); let old = JavaClasses.setTypeConstructorForJavaClass (definition.compilation(), definition.tc, classType); if (old != null) User.error(definition, javaName + " was already associated with the Nice class " + old); definition.setJavaType(classType); } resolveClass() { if (ignoredRetyping) return; JavaClasses.fetchMethods(definition.tc, cast(definition.getJavaType())); } printInterface(s) { s.print(" = native " + javaName.toString() + ";\n"); } } Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** tools.nice 7 Nov 2004 01:07:26 -0000 1.59 --- tools.nice 18 Nov 2004 17:31:16 -0000 1.60 *************** *** 236,239 **** --- 236,241 ---- void printInterface(Definition, java.io.PrintWriter) = native void Definition.printInterface(java.io.PrintWriter); ?gnu.expr.Declaration getDeclaration(VarSymbol) = native gnu.expr.Declaration VarSymbol.getDeclaration(); + void printInterface(ClassImplementation, java.io.PrintWriter) = native void ClassImplementation.printInterface(java.io.PrintWriter); + ?gnu.bytecode.Type TypeImport_lookup(LocatedString) = native gnu.bytecode.Type nice.tools.code.TypeImport.lookup(LocatedString); // Retypings needed since java types are not strict. Index: NiceClass.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/NiceClass.java,v retrieving revision 1.92 retrieving revision 1.93 diff -C2 -d -r1.92 -r1.93 *** NiceClass.java 5 Nov 2004 14:57:57 -0000 1.92 --- NiceClass.java 18 Nov 2004 17:31:15 -0000 1.93 *************** *** 31,35 **** */ ! public abstract class NiceClass extends ClassDefinition.ClassImplementation { abstract public LocatedString getName(); --- 31,35 ---- */ ! public abstract class NiceClass extends ClassImplementation { abstract public LocatedString getName(); Index: niceclass.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/niceclass.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** niceclass.nice 6 Nov 2004 00:28:17 -0000 1.3 --- niceclass.nice 18 Nov 2004 17:31:16 -0000 1.4 *************** *** 336,340 **** printInterface(s) { ! notNull(s).print(" {\n" + Util.map("", ";\n", ";\n", fields) + Util.map("", ";\n", ";\n", overrides) --- 336,340 ---- printInterface(s) { ! s.print(" {\n" + Util.map("", ";\n", ";\n", fields) + Util.map("", ";\n", ";\n", overrides) Index: AbstractInterfaceImplementation.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/AbstractInterfaceImplementation.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** AbstractInterfaceImplementation.java 11 Oct 2004 16:21:06 -0000 1.8 --- AbstractInterfaceImplementation.java 18 Nov 2004 17:31:15 -0000 1.9 *************** *** 68,72 **** boolean isNiceClass = def != null && ! ! (def.getImplementation() instanceof JavaClass); if (!isNiceClass && interfaceITF.associatedTC() != null) --- 68,72 ---- boolean isNiceClass = def != null && ! (def.getImplementation() instanceof NiceClass); if (!isNiceClass && interfaceITF.associatedTC() != null) |
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7531/F:/nice/src/bossa/syntax Modified Files: AST.java Definition.java overloadedsymbol.nice pattern.nice tools.nice Added Files: globalvar.nice Removed Files: GlobalVarDeclaration.java Log Message: Converted GlobalVarDeclaration. Index: Definition.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Definition.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** Definition.java 15 Dec 2003 14:04:13 -0000 1.22 --- Definition.java 7 Nov 2004 01:07:26 -0000 1.23 *************** *** 78,81 **** --- 78,86 ---- } + boolean isGlobalVarDeclaration() + { + return false; + } + /**************************************************************** * Name and location of the definition Index: AST.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/AST.java,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** AST.java 5 Mar 2004 14:07:14 -0000 1.58 --- AST.java 7 Nov 2004 01:07:26 -0000 1.59 *************** *** 53,57 **** for(Iterator i = children.iterator(); i.hasNext();) { ! Object node = i.next(); if (node instanceof ClassDefinition) classes.add(node); --- 53,57 ---- for(Iterator i = children.iterator(); i.hasNext();) { ! Definition node = (Definition)i.next(); if (node instanceof ClassDefinition) classes.add(node); *************** *** 67,71 **** else if (node instanceof EnumDefinition) classes.add(((EnumDefinition)node).classDef); ! else if (node instanceof GlobalVarDeclaration) globals.add(node); else if (node instanceof DefaultMethodImplementation) --- 67,71 ---- else if (node instanceof EnumDefinition) classes.add(((EnumDefinition)node).classDef); ! else if (node.isGlobalVarDeclaration()) globals.add(node); else if (node instanceof DefaultMethodImplementation) *************** *** 79,84 **** methods.toArray(new MethodDeclaration[methods.size()]); ! this.globals = (GlobalVarDeclaration[]) ! globals.toArray(new GlobalVarDeclaration[globals.size()]); this.customConstructors = (CustomConstructor[]) --- 79,84 ---- methods.toArray(new MethodDeclaration[methods.size()]); ! this.globals = (Definition[]) ! globals.toArray(new Definition[globals.size()]); this.customConstructors = (CustomConstructor[]) *************** *** 234,238 **** private MethodDeclaration[] methods; private MethodBodyDefinition[] methodImplementations; ! private GlobalVarDeclaration[] globals; private CustomConstructor[] customConstructors; } --- 234,238 ---- private MethodDeclaration[] methods; private MethodBodyDefinition[] methodImplementations; ! private Definition[] globals; private CustomConstructor[] customConstructors; } Index: pattern.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/pattern.nice,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** pattern.nice 13 Oct 2004 23:22:22 -0000 1.7 --- pattern.nice 7 Nov 2004 01:07:26 -0000 1.8 *************** *** 467,471 **** { for (sym : Node.getGlobalScope().lookup(refName)) ! if (sym instanceof GlobalVarDeclaration.GlobalVarSymbol || sym instanceof EnumDefinition.EnumSymbol ) return sym; --- 467,471 ---- { for (sym : Node.getGlobalScope().lookup(refName)) ! if (sym instanceof GlobalVarSymbol || sym instanceof EnumDefinition.EnumSymbol ) return sym; *************** *** 484,490 **** { let symbol = findRefSymbol(notNull(pattern.refName)); ! if (symbol instanceof GlobalVarDeclaration.GlobalVarSymbol) { ! if (symbol.getValue() instanceof ConstantExp && symbol.constant) { ConstantExp val = cast(symbol.getValue()); --- 484,490 ---- { let symbol = findRefSymbol(notNull(pattern.refName)); ! if (symbol instanceof GlobalVarSymbol) { ! if (symbol.getValue() instanceof ConstantExp && !symbol.isAssignable()) { ConstantExp val = cast(symbol.getValue()); *************** *** 515,524 **** } ! if (! (symbol instanceof GlobalVarDeclaration.GlobalVarSymbol)) return pattern; if (symbol.getValue() instanceof ConstantExp) { ! if (!symbol.constant) User.error(pattern.name, "" + pattern.name + " is not constant"); --- 515,524 ---- } ! if (! (symbol instanceof GlobalVarSymbol)) return pattern; if (symbol.getValue() instanceof ConstantExp) { ! if (symbol.isAssignable()) User.error(pattern.name, "" + pattern.name + " is not constant"); Index: overloadedsymbol.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/overloadedsymbol.nice,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** overloadedsymbol.nice 6 Nov 2004 19:39:50 -0000 1.6 --- overloadedsymbol.nice 7 Nov 2004 01:07:26 -0000 1.7 *************** *** 298,302 **** List<VarSymbol> globalvars = symbols.filter(VarSymbol sym => ! sym instanceof GlobalVarDeclaration.GlobalVarSymbol); // If there are global variables, give them the priority --- 298,302 ---- List<VarSymbol> globalvars = symbols.filter(VarSymbol sym => ! sym instanceof GlobalVarSymbol); // If there are global variables, give them the priority Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** tools.nice 6 Nov 2004 19:39:50 -0000 1.58 --- tools.nice 7 Nov 2004 01:07:26 -0000 1.59 *************** *** 41,45 **** //don't allow nullness inference on global variables. ! if (sym instanceof GlobalVarDeclaration.GlobalVarSymbol && sym.isAssignable()) return null; --- 41,45 ---- //don't allow nullness inference on global variables. ! if (sym instanceof GlobalVarSymbol && sym.isAssignable()) return null; *************** *** 234,237 **** --- 234,239 ---- ?LinkedList<MethodDeclaration.Symbol> getConstructors(TypeConstructor) = native LinkedList TypeConstructors.getConstructors(TypeConstructor); ?gnu.bytecode.Attribute get(gnu.bytecode.AttrContainer, String) = native gnu.bytecode.Attribute gnu.bytecode.Attribute.get(gnu.bytecode.AttrContainer, String); + void printInterface(Definition, java.io.PrintWriter) = native void Definition.printInterface(java.io.PrintWriter); + ?gnu.expr.Declaration getDeclaration(VarSymbol) = native gnu.expr.Declaration VarSymbol.getDeclaration(); // Retypings needed since java types are not strict. --- NEW FILE: globalvar.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package bossa.syntax; import bossa.util.*; /** Declaration of a global variable */ public class GlobalVarDeclaration extends Definition { GlobalVarSymbol left; Expression value; boolean constant; isGlobalVarDeclaration() = true; resolve() { value = analyse(value, notNull(scope), notNull(typeScope)); } typecheck() { try{ value = value.resolveOverloading(left.getType()); typecheck(value); Typing.leq(value.getType(),left.getType()); } catch(TypingEx e){ User.error(this,"Typing error : "+left+" cannot be assigned value "+value+ " of type "+value.getType()+" : \n"+ e); } } printInterface(s) { s.print((constant? "let ": "var ") +left +" = " +value.toString() +";\n"); } compile() { left.getDeclaration(); } ?gnu.expr.Expression compileValue() = value.compile(); toString() = left + " = " + value; } class GlobalVarSymbol extends MonoSymbol { GlobalVarDeclaration definition; isAssignable() = ! definition.constant; getDeclaration() { ?gnu.expr.Declaration res = super; if (res == null) { res = new gnu.expr.Declaration (name.toString(), nice.tools.code.Types.javaType(type)); this.setDeclaration(res); if (! definition.inInterfaceFile()) { // Compute the value first, which might use another global value, // which will then be properly initialized before use. notNull(res).noteValue(definition.compileValue()); } definition.module.addGlobalVar(res, definition.constant); } return res; } Expression getValue() = definition.value; getDefinition() = definition; } public GlobalVarDeclaration createGlobalVarDeclaration(LocatedString name, Monotype type, Expression value, boolean constant) { let res = new GlobalVarDeclaration(name, Node.global, left: cast(null), value: value, constant: constant); res.left = new GlobalVarSymbol(name, type, definition: res); res.addChild(res.left); return res; } --- GlobalVarDeclaration.java DELETED --- |
From: Arjan B. <ar...@us...> - 2004-11-07 01:07:38
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7531/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Converted GlobalVarDeclaration. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.272 retrieving revision 1.273 diff -C2 -d -r1.272 -r1.273 *** Parser.jj 5 Nov 2004 14:57:57 -0000 1.272 --- Parser.jj 7 Nov 2004 01:07:25 -0000 1.273 *************** *** 1507,1511 **** ) ";" ! { return new GlobalVarDeclaration(name,t,value,constant); } } --- 1507,1511 ---- ) ";" ! { return bossa.syntax.dispatch.createGlobalVarDeclaration(name,t,value,constant); } } |