nice-commit Mailing List for The Nice Programming Language (Page 32)
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-10-14 15:42:21
|
Update of /cvsroot/nice/Nice/testsuite/compiler/classes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19244/F:/nice/testsuite/compiler/classes Added Files: value-override.testsuite Log Message: Added field default value overriding. --- NEW FILE: value-override.testsuite --- /// PASS assert new B().x == 3; /// Toplevel class A { int x; } class B extends A { override x = 3; } /// PASS assert new A().x.equals("abc"); assert new B().x.equals("xyz"); /// Toplevel class A { final String x = "abc"; } class B extends A { override x = "xyz"; } /// FAIL /// Toplevel class A { int x; } class B extends A { override /* /// FAIL HERE */ x = "abc"; } /// PASS assert new C().x == 5; /// Toplevel class A { final int x; } class B extends A { override byte x = 0; } class C extends B { override x = 5; } /// FAIL /// Toplevel class A { final int x; } class B extends A { override byte x = 0; } class C extends B { override /* /// FAIL HERE */ x = 1000; } /// PASS assert new A().x == 1; assert new B().x == 3; assert new C().x == 5; /// Toplevel class A { int x = 1; } class B extends A { override x = 3; } class C extends B { override x = 5; } /// FAIL /// Toplevel class A { final int x; } class B extends A { override x = 3; override /* /// FAIL HERE */ x = 5; } /// FAIL /// Toplevel class A { final int x; } class B extends A { override int x = 3; override /* /// FAIL HERE */ x = 5; } /// FAIL bug /// Toplevel class A { final int x = 1; } class B extends A { override x = 1000; } class C extends B { override /* /// FAIL HERE */ byte x; } |
From: Arjan B. <ar...@us...> - 2004-10-14 15:42:21
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19244/F:/nice/src/bossa/syntax Modified Files: EnumDefinition.java NiceClass.java Log Message: Added field default value overriding. Index: NiceClass.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/NiceClass.java,v retrieving revision 1.88 retrieving revision 1.89 diff -C2 -d -r1.88 -r1.89 *** NiceClass.java 13 Oct 2004 20:42:21 -0000 1.88 --- NiceClass.java 14 Oct 2004 15:42:11 -0000 1.89 *************** *** 80,83 **** --- 80,91 ---- } + public void setValueOverrides(List valueOverrides) + { + if (valueOverrides == null) + this.valueOverrides = new LinkedList(); + else + this.valueOverrides = valueOverrides; + } + ClassDefinition definition; *************** *** 147,150 **** --- 155,166 ---- } + public ValueOverride makeValueOverride(LocatedString fname, Expression value) + { + if (isInterface()) + User.error(fname, "An interface cannot have a field."); + + return new ValueOverride(fname, value); + } + abstract class Field { *************** *** 408,411 **** --- 424,471 ---- } + public final class ValueOverride + { + ValueOverride(LocatedString name, Expression value) + { + this.name = name; + this.value = value; + } + + void updateConstructorParameter(List inherited) + { + for (int i = 1; i < inherited.size(); i++) { + FormalParameters.Parameter param = (FormalParameters.Parameter) + inherited.get(i); + if (param.match(name.toString())) + { + inherited.set(i, new FormalParameters.OptionalParameter + (param.type, name, true, value, + param.value() == null || param.isOverriden())); + } + } + } + + void resolve(VarScope scope, TypeScope typeScope) + { + value = dispatch.analyse(value, scope, typeScope); + } + + + void typecheck() + { + boolean exists = false; + + NiceClass parent = getParent(); + if (parent != null) + exists = parent.checkValueOverride(name, value); + + if (! exists) + throw User.error(name, "No field with this name exists in a super-class"); + } + + LocatedString name; + Expression value; + } + // Used to resolve fields, and constructor constraint. private TypeScope localScope; *************** *** 429,432 **** --- 489,496 ---- for (int i = 0; i < overrides.length; i++) overrides[i].resolve(definition.scope, localScope); + + for (Iterator it = valueOverrides.iterator(); it.hasNext(); ) + ((ValueOverride)it.next()).resolve(definition.scope, localScope); + } *************** *** 465,468 **** --- 529,571 ---- } + private boolean checkValueOverride(LocatedString name, Expression value) + { + + Field original = null; + + for (int i = 0; i < fields.length; i++) + if (fields[i].sym.getName().toString().equals(name.toString())) + original = fields[i]; + + for (int i = 0; i < overrides.length; i++) + if (overrides[i].sym.getName().toString().equals(name.toString())) + original = overrides[i]; + + if (original != null) + { + NiceClass.this.enterTypingContext(); + + mlsub.typing.Polytype declaredType = original.sym.getType(); + value = value.resolveOverloading(declaredType); + + dispatch.typecheck(value); + + try { + Typing.leq(value.getType(), declaredType); + } + catch (mlsub.typing.TypingEx ex) { + User.error(name, "Value does not fit in the overriden field of type " + declaredType); + } + + return true; + } + + NiceClass parent = getParent(); + if (parent != null) + return parent.checkValueOverride(name, value); + else + return false; + } + /**************************************************************** * Initializers *************** *** 569,572 **** --- 672,678 ---- overrides[i].typecheck(); + for (Iterator it = valueOverrides.iterator(); it.hasNext(); ) + ((ValueOverride)it.next()).typecheck(); + if (initializers.length != 0) { *************** *** 818,822 **** res = sup.getParentConstructorParameters(constraints, typeParameters); ! if (overrides.length > 0) for (Iterator i = res.iterator(); i.hasNext();) updateConstructorParameters((List) i.next()); --- 924,928 ---- res = sup.getParentConstructorParameters(constraints, typeParameters); ! if (overrides.length > 0 || (! valueOverrides.isEmpty())) for (Iterator i = res.iterator(); i.hasNext();) updateConstructorParameters((List) i.next()); *************** *** 844,847 **** --- 950,956 ---- for (int f = 0; f < overrides.length; f++) overrides[f].updateConstructorParameter(inherited); + + for (Iterator it = valueOverrides.iterator(); it.hasNext();) + ((ValueOverride)it.next()).updateConstructorParameter(inherited); } *************** *** 860,863 **** --- 969,985 ---- "A field override of the same field exists in this class"); + for (int i = 0; i < valueOverrides.size(); i++) + for (int k = i+1; k < valueOverrides.size(); k++) + if (((ValueOverride)valueOverrides.get(i)).name.equals(((ValueOverride)valueOverrides.get(k)).name)) + User.error(((ValueOverride)valueOverrides.get(k)).name, + "A field override of the same field exists in this class"); + + for (int i = 0; i < overrides.length; i++) + for (int k = 0; k < valueOverrides.size(); k++) + if (overrides[i].sym.hasName(((ValueOverride)valueOverrides.get(k)).name)) + User.error(((ValueOverride)valueOverrides.get(k)).name, + "A field override of the same field exists in this class"); + + } *************** *** 1076,1079 **** --- 1198,1202 ---- private NewField[] fields; private OverridenField[] overrides; + private List valueOverrides; private Long serialVersionUIDValue; } Index: EnumDefinition.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/EnumDefinition.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** EnumDefinition.java 13 Oct 2004 23:22:22 -0000 1.15 --- EnumDefinition.java 14 Oct 2004 15:42:11 -0000 1.16 *************** *** 51,54 **** --- 51,55 ---- impl.setOverrides(null); + impl.setValueOverrides(null); if (! inInterfaceFile()) |
From: Arjan B. <ar...@us...> - 2004-10-14 09:37:37
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1551/F:/nice/src/bossa/syntax Modified Files: analyse.nice locals.nice tools.nice Log Message: Resolved null warning. Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** tools.nice 13 Oct 2004 23:22:22 -0000 1.53 --- tools.nice 14 Oct 2004 09:37:27 -0000 1.54 *************** *** 227,230 **** --- 227,231 ---- int[?] getUsedArguments(Arguments, VarSymbol) = native int[] Arguments.getUsedArguments(VarSymbol); ?mlsub.typing.Constraint getConstraint(mlsub.typing.Polytype) = native mlsub.typing.Constraint mlsub.typing.Polytype.getConstraint(); + MonoSymbol[?] getMonoSymbols(FormalParameters) = native MonoSymbol[] FormalParameters.getMonoSymbols(); // Retypings needed since java types are not strict. Index: analyse.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/analyse.nice,v retrieving revision 1.113 retrieving revision 1.114 diff -C2 -d -r1.113 -r1.114 *** analyse.nice 13 Oct 2004 23:22:22 -0000 1.113 --- analyse.nice 14 Oct 2004 09:37:27 -0000 1.114 *************** *** 460,465 **** e.constraint = null; ! if (e.formals != null) ! addVars(info, e.formals); analyse(e.body, info); --- 460,464 ---- e.constraint = null; ! addVars(info, e.formals); analyse(e.body, info); Index: locals.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/locals.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** locals.nice 13 Oct 2004 23:22:22 -0000 1.2 --- locals.nice 14 Oct 2004 09:37:27 -0000 1.3 *************** *** 208,212 **** public Statement createLocalFunction(LocatedString name, Monotype returnType, FormalParameters parameters, Statement body) { ! let value = createFunExp(Constraint.True, parameters.getMonoSymbols(), body); let symbol = new FunSymbol(name, Constraint.True, parameters, returnType); notNull(notNull(symbol.syntacticType).getMonotype()).nullness = Monotype.sure; --- 208,212 ---- public Statement createLocalFunction(LocatedString name, Monotype returnType, FormalParameters parameters, Statement body) { ! let value = createFunExp(Constraint.True, parameters.getMonoSymbols() || new MonoSymbol[0], body); let symbol = new FunSymbol(name, Constraint.True, parameters, returnType); notNull(notNull(symbol.syntacticType).getMonotype()).nullness = Monotype.sure; |
From: Arjan B. <ar...@us...> - 2004-10-13 23:22:35
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7665/F:/nice/src/bossa/syntax Modified Files: EnumDefinition.java LocatedString.java analyse.nice assign.nice call.nice constant.nice increment.nice locals.nice new.nice overloadedsymbol.nice pattern.nice super.nice tools.nice typecheck.nice Log Message: Cleanup of nullness issues. Index: analyse.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/analyse.nice,v retrieving revision 1.112 retrieving revision 1.113 diff -C2 -d -r1.112 -r1.113 *** analyse.nice 7 Oct 2004 22:03:44 -0000 1.112 --- analyse.nice 13 Oct 2004 23:22:22 -0000 1.113 *************** *** 534,538 **** { CallExp res = new CallExp(function: createOverloadedSymbolExp(symbols, notNull(e.ident)), ! arguments: new Arguments([new Arguments.Argument(Node.thisExp)])); res.setLocation(e.location()); return res; --- 534,538 ---- { CallExp res = new CallExp(function: createOverloadedSymbolExp(symbols, notNull(e.ident)), ! arguments: Arguments.singleArgument(Node.thisExp)); res.setLocation(e.location()); return res; Index: pattern.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/pattern.nice,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pattern.nice 9 Oct 2004 09:28:41 -0000 1.6 --- pattern.nice 13 Oct 2004 23:22:22 -0000 1.7 *************** *** 603,612 **** if (name[0] == '-') ! return createPattern(ConstantExp.makeNumber(new LocatedString(name, ! loc))); if (name[0] == '+') ! return createPattern(ConstantExp.makeNumber(new LocatedString( ! name.substring(1), loc))); if (name[0] == '\"') --- 603,610 ---- if (name[0] == '-') ! return createPattern(ConstantExp.makeNumber(new LocatedString(name))); if (name[0] == '+') ! return createPattern(ConstantExp.makeNumber(new LocatedString(name.substring(1)))); if (name[0] == '\"') *************** *** 618,630 **** let prefix = name.substring(0, (name[1] == '=') ? 2 : 1); return createPattern(prefix, null, ConstantExp.makeNumber( ! new LocatedString(name.substring(prefix.length()), loc)), null, loc); } if (name[0] == '=') ! return resolveGlobalConstants(new VariablePattern(new LocatedString(name.substring(1), loc), loc)); } if (name.equals("_")) ! return createPattern(new LocatedString("_", loc)); if (name.equals("NONNULL")) --- 616,628 ---- let prefix = name.substring(0, (name[1] == '=') ? 2 : 1); return createPattern(prefix, null, ConstantExp.makeNumber( ! new LocatedString(name.substring(prefix.length()))), null, loc); } if (name[0] == '=') ! return resolveGlobalConstants(new VariablePattern(new LocatedString(name.substring(1)), loc)); } if (name.equals("_")) ! return createPattern(new LocatedString("_")); if (name.equals("NONNULL")) Index: LocatedString.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/LocatedString.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** LocatedString.java 29 May 2003 14:17:18 -0000 1.18 --- LocatedString.java 13 Oct 2004 23:22:22 -0000 1.19 *************** *** 29,32 **** --- 29,37 ---- } + public LocatedString(String content) + { + this(content, Location.nowhere(), false); + } + /** * @param content the underlying raw string Index: typecheck.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typecheck.nice,v retrieving revision 1.116 retrieving revision 1.117 diff -C2 -d -r1.116 -r1.117 *** typecheck.nice 7 Oct 2004 22:03:44 -0000 1.116 --- typecheck.nice 13 Oct 2004 23:22:22 -0000 1.117 *************** *** 1058,1062 **** try { Typing.enter(); ! type.getConstraint().enter(); Typing.leq(type.getMonotype(), PrimitiveType.sureTC); Typing.implies(); --- 1058,1062 ---- try { Typing.enter(); ! notNull(type.getConstraint()).enter(); Typing.leq(type.getMonotype(), PrimitiveType.sureTC); Typing.implies(); Index: constant.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/constant.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** constant.nice 2 Sep 2004 15:46:32 -0000 1.1 --- constant.nice 13 Oct 2004 23:22:22 -0000 1.2 *************** *** 59,63 **** } ! let LocatedString voidName = new LocatedString("void", bossa.util.Location.nowhere()); /** --- 59,63 ---- } ! let LocatedString voidName = new LocatedString("void"); /** *************** *** 88,92 **** } ! let LocatedString stringClassName = new LocatedString("java.lang.String", Location.nowhere()); // cf. JLS 3.10.6 --- 88,92 ---- } ! let LocatedString stringClassName = new LocatedString("java.lang.String"); // cf. JLS 3.10.6 *************** *** 198,204 **** } ! TypeConstructor getTC() { ! return nice.tools.typing.Types.rawType(representedType).head(); } --- 198,204 ---- } ! ?TypeConstructor getTC() { ! return notNull(nice.tools.typing.Types.rawType(representedType)).head(); } Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** tools.nice 7 Oct 2004 22:03:44 -0000 1.52 --- tools.nice 13 Oct 2004 23:22:22 -0000 1.53 *************** *** 76,80 **** MethodDeclaration.enterLocalContext(); ! type.getConstraint.enter(true); } --- 76,80 ---- MethodDeclaration.enterLocalContext(); ! notNull(type.getConstraint).enter(true); } *************** *** 192,195 **** --- 192,197 ---- LocatedString name(VarSymbol) = native VarSymbol.name; Arguments.Argument[] arguments(Arguments) = native Arguments.arguments; + Arguments Argument(List<Arguments.Argument>) = native new Arguments(List); + Arguments Argument(Arguments.Argument[]) = native new Arguments(Arguments.Argument[]); mlsub.typing.Polytype getType(Expression) = native mlsub.typing.Polytype Expression.getType(); *************** *** 212,217 **** ?mlsub.typing.TypeConstructor getRuntimeTC(Pattern) = native mlsub.typing.TypeConstructor Pattern.getRuntimeTC(); boolean matchesValue(Pattern, ConstantExp) = native boolean Pattern.matchesValue(ConstantExp); ! public ?LocatedString getName(Pattern) = native LocatedString Pattern.getName(); ! // Retypings needed since java types are not strict. --- 214,230 ---- ?mlsub.typing.TypeConstructor getRuntimeTC(Pattern) = native mlsub.typing.TypeConstructor Pattern.getRuntimeTC(); boolean matchesValue(Pattern, ConstantExp) = native boolean Pattern.matchesValue(ConstantExp); ! ?LocatedString getName(Pattern) = native LocatedString Pattern.getName(); ! ?mlsub.typing.lowlevel.Kind getKind(mlsub.typing.lowlevel.Element) = native mlsub.typing.lowlevel.Kind mlsub.typing.lowlevel.Element.getKind(); ! ?gnu.expr.Declaration getDeclaration(Expression) = native gnu.expr.Declaration Expression.getDeclaration(); ! ?FieldAccess getFieldAccessMethod(Expression) = native FieldAccess Expression.getFieldAccessMethod(); ! ?FieldAccess getField(Expression) = native FieldAccess Expression.getField(); ! ?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); ! mlsub.typing.Monotype[?] Types_parameters(mlsub.typing.Polytype) = native mlsub.typing.Monotype[] nice.tools.typing.Types.parameters(mlsub.typing.Polytype); ! ?mlsub.typing.TypeConstructor head(mlsub.typing.Monotype) = native mlsub.typing.TypeConstructor mlsub.typing.Monotype.head(); ! ?ClassDefinition ClassDefinition_get(mlsub.typing.TypeConstructor) = native ClassDefinition ClassDefinition.get(mlsub.typing.TypeConstructor); ! ?gnu.bytecode.ClassType getSuperclass(gnu.bytecode.ClassType) = native gnu.bytecode.ClassType gnu.bytecode.ClassType.getSuperclass(); ! int[?] getUsedArguments(Arguments, VarSymbol) = native int[] Arguments.getUsedArguments(VarSymbol); ! ?mlsub.typing.Constraint getConstraint(mlsub.typing.Polytype) = native mlsub.typing.Constraint mlsub.typing.Polytype.getConstraint(); // Retypings needed since java types are not strict. Index: locals.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/locals.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** locals.nice 8 Aug 2004 21:51:54 -0000 1.1 --- locals.nice 13 Oct 2004 23:22:22 -0000 1.2 *************** *** 126,136 **** } ! display() ! { ! if (left.constant) ! return "let "+ super; ! else ! return "var " + super; ! } } --- 126,130 ---- } ! display() = (left.constant ? "let " : "var ") + super; } Index: new.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/new.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** new.nice 13 Aug 2004 21:04:41 -0000 1.3 --- new.nice 13 Oct 2004 23:22:22 -0000 1.4 *************** *** 56,64 **** // Make sure that the constructors have been created. ! ClassDefinition definition = ClassDefinition.get(tc); if (definition != null) definition.resolve(); ! LinkedList<VarSymbol> constructors = TypeConstructors.getConstructors(tc); if (constructors == null) { --- 56,64 ---- // Make sure that the constructors have been created. ! let definition = ClassDefinition.get(tc); if (definition != null) definition.resolve(); ! ?LinkedList<VarSymbol> constructors = TypeConstructors.getConstructors(tc); if (constructors == null) { *************** *** 75,79 **** constructors = constructors.clone(); ! function = createOverloadedSymbolExp(constructors, new LocatedString("new " + tc, this.location())); } --- 75,79 ---- constructors = constructors.clone(); ! function = createOverloadedSymbolExp(notNull(constructors), new LocatedString("new " + tc, this.location())); } *************** *** 85,89 **** } ! toString() = "new " + ti.toString() + arguments; } --- 85,89 ---- } ! toString() = "new " + ti + arguments; } Index: EnumDefinition.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/EnumDefinition.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** EnumDefinition.java 2 Sep 2004 15:46:32 -0000 1.14 --- EnumDefinition.java 13 Oct 2004 23:22:22 -0000 1.15 *************** *** 60,64 **** Statement body = bossa.syntax.dispatch.createReturnStmt(bossa.syntax.dispatch.createLiteralArrayExp(exps), true); ! LocatedString mName = new LocatedString("family", bossa.util.Location.nowhere()); Definition mBodyDef = new MethodBodyDefinition(impl, mName, null, new LinkedList(), body); --- 60,64 ---- Statement body = bossa.syntax.dispatch.createReturnStmt(bossa.syntax.dispatch.createLiteralArrayExp(exps), true); ! LocatedString mName = new LocatedString("family"); Definition mBodyDef = new MethodBodyDefinition(impl, mName, null, new LinkedList(), body); Index: assign.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/assign.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** assign.nice 2 Sep 2004 19:12:09 -0000 1.3 --- assign.nice 13 Oct 2004 23:22:22 -0000 1.4 *************** *** 39,43 **** { // Rewrite "get(e, i, ...) = v" into "set(e, i, ... , v)" ! if (to instanceof CallExp && "get".equals(notNull(to.function).toString())) { List<Arguments.Argument> args = new ArrayList(to.arguments.arguments); --- 39,43 ---- { // Rewrite "get(e, i, ...) = v" into "set(e, i, ... , v)" ! if (to instanceof CallExp && "get".equals(to.function.toString())) { List<Arguments.Argument> args = new ArrayList(to.arguments.arguments); *************** *** 45,50 **** return createCallExp( ! new IdentExp(new LocatedString("set", notNull(to.function).location())), ! new Arguments(args.toArray())); } --- 45,50 ---- return createCallExp( ! new IdentExp(new LocatedString("set", to.function.location())), ! new Arguments(args)); } Index: super.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/super.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** super.nice 7 Aug 2004 14:20:29 -0000 1.2 --- super.nice 13 Oct 2004 23:22:22 -0000 1.3 *************** *** 122,126 **** mlsub.typing.Monotype[] m = monotype.domain(); List<mlsub.typing.AtomicConstraint> newAtoms = new ArrayList(); ! mlsub.typing.AtomicConstraint[?] oldAtoms = type.getConstraint().atoms(); if (oldAtoms != null) --- 122,126 ---- mlsub.typing.Monotype[] m = monotype.domain(); List<mlsub.typing.AtomicConstraint> newAtoms = new ArrayList(); ! mlsub.typing.AtomicConstraint[?] oldAtoms = notNull(type.getConstraint()).atoms(); if (oldAtoms != null) *************** *** 149,153 **** } ! constraint = new mlsub.typing.Constraint(type.getConstraint().binders(), new mlsub.typing.AtomicConstraint[newAtoms.size()].fillWith(newAtoms)); --- 149,153 ---- } ! constraint = new mlsub.typing.Constraint(notNull(type.getConstraint()).binders(), new mlsub.typing.AtomicConstraint[newAtoms.size()].fillWith(newAtoms)); *************** *** 170,174 **** // the base method), a call to super is emited. { ! let NiceClass nc = cast(ClassDefinition.get(notNull(currentMethod).firstArgument()).implementation); code = nc.callSuperMethod(notNull(superMethod)); } --- 170,174 ---- // the base method), a call to super is emited. { ! let NiceClass nc = cast(notNull(ClassDefinition.get(notNull(currentMethod).firstArgument())).implementation); code = nc.callSuperMethod(notNull(superMethod)); } Index: overloadedsymbol.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/overloadedsymbol.nice,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** overloadedsymbol.nice 13 Aug 2004 21:04:41 -0000 1.4 --- overloadedsymbol.nice 13 Oct 2004 23:22:22 -0000 1.5 *************** *** 574,578 **** } ! private Domain domain(mlsub.typing.Polytype t, int[] usedArguments) { // remove nullness marker --- 574,578 ---- } ! private Domain domain(mlsub.typing.Polytype t, int[?] usedArguments) { // remove nullness marker Index: increment.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/increment.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** increment.nice 13 Aug 2004 21:04:41 -0000 1.2 --- increment.nice 13 Oct 2004 23:22:22 -0000 1.3 *************** *** 42,63 **** // variable is not a local variable, so it must be a field ! ?CallExp call = null; ! if (variable instanceof CallExp) ! call = cast(variable); ! ! if (call == null) Internal.error(this, "\"var\" is assignable and not a local, " + "so it should be a call to a FieldAccessMethod"); ! let access = notNull(call).function.getFieldAccessMethod(); if (access == null) Internal.error(this, "\"var\" is assignable and not a local, " + "so it should be a call to a FieldAccessMethod"); ! if (access.isFinal()) User.error(this, "Field " + access + " is final"); ! return NiceUtils.doInline(new nice.tools.code.IncrementProc(access.fieldDecl, returnOld, increment), ! notNull(call).arguments.getExp(0).generateCode()); } --- 42,61 ---- // variable is not a local variable, so it must be a field ! if (! (variable instanceof CallExp)) Internal.error(this, "\"var\" is assignable and not a local, " + "so it should be a call to a FieldAccessMethod"); ! CallExp call = cast(variable); ! ! let access = call.function.getFieldAccessMethod(); if (access == null) Internal.error(this, "\"var\" is assignable and not a local, " + "so it should be a call to a FieldAccessMethod"); ! if (notNull(access).isFinal()) User.error(this, "Field " + access + " is final"); ! return NiceUtils.doInline(new nice.tools.code.IncrementProc(notNull(access).fieldDecl, returnOld, increment), ! call.arguments.getExp(0).generateCode()); } Index: call.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/call.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** call.nice 11 Aug 2004 12:34:30 -0000 1.3 --- call.nice 13 Oct 2004 23:22:22 -0000 1.4 *************** *** 156,160 **** gnu.expr.Expression res; if (function.isFieldAccess()) ! res = function.getFieldAccessMethod().compileAccess(this.compileParams()); else res = new gnu.expr.ApplyExp(function.generateCodeInCallPosition(), this.compileParams()); --- 156,160 ---- gnu.expr.Expression res; if (function.isFieldAccess()) ! res = notNull(function.getFieldAccessMethod()).compileAccess(this.compileParams()); else res = new gnu.expr.ApplyExp(function.generateCodeInCallPosition(), this.compileParams()); *************** *** 198,202 **** Internal.error(this, "Assignment to a call that is not a field access"); ! FieldAccess access = function.getFieldAccessMethod(); if (access.isFinal()) --- 198,202 ---- Internal.error(this, "Assignment to a call that is not a field access"); ! FieldAccess access = notNull(function.getFieldAccessMethod()); if (access.isFinal()) |
From: Arjan B. <ar...@us...> - 2004-10-13 20:42:31
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23250/F:/nice/src/bossa/syntax Modified Files: Arguments.java Contract.java FormalParameters.java NiceClass.java loop.nice Log Message: Parser cleanup. Index: FormalParameters.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/FormalParameters.java,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** FormalParameters.java 30 Jun 2004 14:12:37 -0000 1.41 --- FormalParameters.java 13 Oct 2004 20:42:21 -0000 1.42 *************** *** 259,262 **** --- 259,274 ---- } + public static Parameter createParameter(Monotype type, LocatedString name, + Expression defaultValue) + { + if (defaultValue != null) + return new OptionalParameter(type, name, defaultValue); + + if (name != null) + return new NamedParameter(type, name); + + return new Parameter(type); + } + /**************************************************************** * Main class Index: Contract.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Contract.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Contract.java 5 Aug 2004 10:45:29 -0000 1.9 --- Contract.java 13 Oct 2004 20:42:21 -0000 1.10 *************** *** 25,28 **** --- 25,42 ---- public class Contract { + public void addElement(Expression condition, Expression name, boolean precond) + { + if (precond) + { + if (name == null) addRequire(condition); + else addRequire(condition, name); + } + else + { + if (name == null) addEnsure(condition); + else addEnsure(condition, name); + } + } + public void addRequire(Expression condition) { Index: loop.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/loop.nice,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** loop.nice 13 Aug 2004 21:04:41 -0000 1.4 --- loop.nice 13 Oct 2004 20:42:21 -0000 1.5 *************** *** 110,117 **** } ! public LoopStmt createForLoop ! (Expression test, Statement update, Statement body) { ! return new LoopStmt(whileExp:test, loopBody: body, iterationStatements: update, testFirst: true); } --- 110,118 ---- } ! public Statement createForLoop ! (Expression test, Statement update, Statement body, List<Statement> inits) { ! inits.add(new LoopStmt(whileExp:test, loopBody: body, iterationStatements: update, testFirst: true)); ! return createBlock(inits); } Index: NiceClass.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/NiceClass.java,v retrieving revision 1.87 retrieving revision 1.88 diff -C2 -d -r1.87 -r1.88 *** NiceClass.java 9 Oct 2004 09:28:41 -0000 1.87 --- NiceClass.java 13 Oct 2004 20:42:21 -0000 1.88 *************** *** 473,477 **** public void setInitializers(List inits) { ! initializers = (Statement[]) inits.toArray(new Statement[inits.size()]); } --- 473,478 ---- public void setInitializers(List inits) { ! if (inits != null) ! initializers = (Statement[]) inits.toArray(new Statement[inits.size()]); } Index: Arguments.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Arguments.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Arguments.java 8 Aug 2004 21:51:54 -0000 1.25 --- Arguments.java 13 Oct 2004 20:42:21 -0000 1.26 *************** *** 62,65 **** --- 62,71 ---- } + public static Arguments singleArgument(Expression value) + { + Argument[] args = {new Argument(value)}; + return new Arguments(args); + } + public void addReceiver(Expression value) { |
From: Arjan B. <ar...@us...> - 2004-10-13 20:42:30
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23250/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Parser cleanup. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.269 retrieving revision 1.270 diff -C2 -d -r1.269 -r1.270 *** Parser.jj 13 Oct 2004 18:28:47 -0000 1.269 --- Parser.jj 13 Oct 2004 20:42:21 -0000 1.270 *************** *** 73,76 **** --- 73,80 ---- } + private static boolean isDocStringToken(Token t) + { + return t.specialToken != null && t.specialToken.kind == FORMAL_COMMENT; + } } *************** *** 851,855 **** FormalParameters.Parameter formalParameter(List statements): { ! Monotype t = null; LocatedString id = null; Expression val = null; --- 855,859 ---- FormalParameters.Parameter formalParameter(List statements): { ! Monotype t; LocatedString id = null; Expression val = null; *************** *** 858,871 **** ( LOOKAHEAD(monotype()) ! t = monotype() ! [ ! id = ident() ! [ ! "=" val = Expression() ! { return new FormalParameters.OptionalParameter(t, id, val); } ! ] ! { return new FormalParameters.NamedParameter(t, id); } ! ] ! { return new FormalParameters.Parameter(t); } | { Token first,last; --- 862,867 ---- ( LOOKAHEAD(monotype()) ! t=monotype() [ id=ident() [ "=" val=Expression() ]] ! { return FormalParameters.createParameter(t, id ,val); } | { Token first,last; *************** *** 888,895 **** t = new TupleType(types, makeLocation(first, last)); t.nullness = Monotype.absent; - if (val != null) - return new FormalParameters.OptionalParameter(t, ident, val); ! return new FormalParameters.NamedParameter(t, ident); } ) --- 884,889 ---- t = new TupleType(types, makeLocation(first, last)); t.nullness = Monotype.absent; ! return FormalParameters.createParameter(t, ident ,val); } ) *************** *** 983,987 **** { { ! if (storeDocString && t.specialToken != null && t.specialToken.kind == FORMAL_COMMENT) docString = t.specialToken.image; } --- 977,981 ---- { { ! if (storeDocString && isDocStringToken(t)) docString = t.specialToken.image; } *************** *** 1004,1012 **** { if (isOverride) ! { ! if (overrides == null) ! overrides = new LinkedList(); ! overrides.add(c.makeOverride(field, value)); ! } else fields.add(c.makeField(field, value, isFinal, isTransient, isVolatile, docString)); --- 998,1002 ---- { if (isOverride) ! overrides.add(c.makeOverride(field, value)); else fields.add(c.makeField(field, value, isFinal, isTransient, isVolatile, docString)); *************** *** 1063,1077 **** { NiceClass impl = new NiceClass(res); } // internal fields and methods ! { List fields = new LinkedList(), overrides = null, ! methods = null, initializers = null; } ( // Initializer { Statement init; } init = Block() ! { ! if (initializers == null) ! initializers = new LinkedList(); ! initializers.add(init); ! } | LOOKAHEAD( fieldLookahead() ) --- 1053,1063 ---- { NiceClass impl = new NiceClass(res); } // internal fields and methods ! { List fields = new LinkedList(), overrides = new LinkedList(), ! methods = new ArrayList(5), initializers = new LinkedList(); } ( // Initializer { Statement init; } init = Block() ! { initializers.add(init); } | LOOKAHEAD( fieldLookahead() ) *************** *** 1086,1096 **** | m = internalMethodOrFunction(res, isOverride) ! { ! if (methods == null) ! methods = new ArrayList(5); ! methods.add(m); ! } ) ! { if (storeDocString && t.specialToken != null && t.specialToken.kind == FORMAL_COMMENT) m.docString = t.specialToken.image; } --- 1072,1078 ---- | m = internalMethodOrFunction(res, isOverride) ! { methods.add(m); } ) ! { if (storeDocString && isDocStringToken(t)) m.docString = t.specialToken.image; } *************** *** 1100,1110 **** impl.setFields(fields); impl.setOverrides(overrides); ! if (initializers != null) ! impl.setInitializers(initializers); ! res.setImplementation(impl); ! ! if (methods != null) ! definitions.addAll(methods); } | --- 1082,1088 ---- impl.setFields(fields); impl.setOverrides(overrides); ! impl.setInitializers(initializers); res.setImplementation(impl); ! definitions.addAll(methods); } | *************** *** 1559,1575 **** void contractElement(Contract contract, boolean precond) : ! { ! Expression condition, name=null; ! } { condition = SideEffectFreeExpression() [ ":" name = SideEffectFreeExpression() ] ! { if (precond) ! if (name == null) contract.addRequire(condition); ! else contract.addRequire(condition, name); ! else ! if (name == null) contract.addEnsure(condition); ! else contract.addEnsure(condition, name); ! } } --- 1537,1545 ---- void contractElement(Contract contract, boolean precond) : ! { Expression condition, name=null; } { condition = SideEffectFreeExpression() [ ":" name = SideEffectFreeExpression() ] ! { contract.addElement(condition, name, precond); } } *************** *** 1612,1616 **** ( d = definition(definitions, storeDocString) { ! if (storeDocString && t.specialToken != null && t.specialToken.kind == FORMAL_COMMENT) d.docString = t.specialToken.image; --- 1582,1586 ---- ( d = definition(definitions, storeDocString) { ! if (storeDocString && isDocStringToken(t)) d.docString = t.specialToken.image; *************** *** 1652,1657 **** { "-" representation=integerLiteral() ! { return ConstantExp.makeNumber( ! new LocatedString("-"+representation.toString(), representation.location())); } } --- 1622,1628 ---- { "-" representation=integerLiteral() ! { ! representation.prepend("-"); ! return ConstantExp.makeNumber(representation); } } *************** *** 1830,1836 **** Statement ShortStatement() : ! { ! Statement res; ! } { ( res = RootShortStatement() --- 1801,1805 ---- Statement ShortStatement() : ! { Statement res; } { ( res = RootShortStatement() *************** *** 2105,2125 **** { Expression e1 = null,e2 = null; Token t = null; } { ! ((e1=ShiftExpression() ! [(t=<RANGE>) [e2=ShiftExpression()]]) ! | ! ((t = <RANGE>) [e2 = ShiftExpression()])) ! { ! if (t != null) ! { ! if (e1 == null) ! e1 = ConstantExp.makeNumber( ! new LocatedString("0", makeLocation(t))); ! if (e2 == null) ! e2 = bossa.syntax.dispatch.createNullExp(makeLocation(t)); ! e1=bossa.syntax.dispatch.createCallExp(symb(t),e1,e2); ! } ! } ! ! { return e1; } } --- 2074,2096 ---- { Expression e1 = null,e2 = null; Token t = null; } { ! ( ! e1=ShiftExpression() [ t=".." [e2=ShiftExpression()]] ! | ! t=".." [e2 = ShiftExpression()] ! ) ! { ! if (t != null) ! { ! if (e1 == null) ! e1 = ConstantExp.makeNumber(new LocatedString("0", makeLocation(t))); ! ! if (e2 == null) ! e2 = bossa.syntax.dispatch.createNullExp(makeLocation(t)); ! ! e1=bossa.syntax.dispatch.createCallExp(symb(t),e1,e2); ! } ! ! return e1; ! } } *************** *** 2164,2168 **** } - Expression ExponentialExpression() : { Expression e1,e2; Token t; } --- 2135,2138 ---- *************** *** 2253,2257 **** } - Expression PrimarySuffix(Expression start) : { --- 2223,2226 ---- *************** *** 2274,2284 **** if (args == null) ! { ! List l = new LinkedList(); ! l.add(new Arguments.Argument(start)); ! args = new Arguments(l); ! } else args.addReceiver(start); return bossa.syntax.dispatch.createCallExp(res, args, true, hasBrackets); } --- 2243,2250 ---- if (args == null) ! args = Arguments.singleArgument(start); else args.addReceiver(start); + return bossa.syntax.dispatch.createCallExp(res, args, true, hasBrackets); } *************** *** 2322,2334 **** Expression atExpression() : { ! Token t; ! } ! { ! (t = <AT>) { return bossa.syntax.dispatch.createCallExp(symb(t), Arguments.noArguments()); } } - ConstantExp patternLiteral() : //restricted literal for use in dispatch patterns --- 2288,2297 ---- Expression atExpression() : + { Token t; } { ! (t="@") { return bossa.syntax.dispatch.createCallExp(symb(t), Arguments.noArguments()); } } ConstantExp patternLiteral() : //restricted literal for use in dispatch patterns *************** *** 2776,2786 **** [ cond=Expression() ] ";" [ update=StatementExpressionList() ] ")" body=Statement() ! { ! loop=bossa.syntax.dispatch.createForLoop(cond,update,body); ! List l = new LinkedList(); ! l.addAll(init); ! l.add(loop); ! loop = bossa.syntax.dispatch.createBlock(l); ! } ) { return loop; } --- 2739,2743 ---- [ cond=Expression() ] ";" [ update=StatementExpressionList() ] ")" body=Statement() ! { loop=bossa.syntax.dispatch.createForLoop(cond,update,body,init); } ) { return loop; } *************** *** 2801,2805 **** List LocalDeclarationList() : ! { Statement d; List declarations = new ArrayList(); } { d=LocalDeclaration() {declarations.add(d);} --- 2758,2762 ---- List LocalDeclarationList() : ! { Statement d; List declarations = new LinkedList(); } { d=LocalDeclaration() {declarations.add(d);} |
From: Arjan B. <ar...@us...> - 2004-10-13 18:38:05
|
Update of /cvsroot/nice/Nice/testsuite/compiler/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21204/F:/nice/testsuite/compiler/syntax Modified Files: anonymousFunctions.testsuite Log Message: Testcase for compiler NPE on constrained anonymous functions. Index: anonymousFunctions.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/syntax/anonymousFunctions.testsuite,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** anonymousFunctions.testsuite 13 Oct 2004 18:28:50 -0000 1.10 --- anonymousFunctions.testsuite 13 Oct 2004 18:37:54 -0000 1.11 *************** *** 40,41 **** --- 40,43 ---- void foobar(boolean b) = assert b; + /// PASS bug + String s = (<String T>(T x)=>x)("ABC"); |
From: Arjan B. <ar...@us...> - 2004-10-13 18:29:39
|
Update of /cvsroot/nice/Nice/testsuite/compiler/typing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18045/F:/nice/testsuite/compiler/typing Modified Files: arrays.testsuite final.testsuite null.testsuite polymorphism.testsuite Log Message: Removed the deprecated 'Any' keyword. Index: final.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/typing/final.testsuite,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** final.testsuite 25 Jun 2002 07:06:05 -0000 1.1 --- final.testsuite 13 Oct 2004 18:28:51 -0000 1.2 *************** *** 4,8 **** final class F2 extends F1 {} ! <Any T> T ff(T); ff(x) = x; --- 4,8 ---- final class F2 extends F1 {} ! <T> T ff(T); ff(x) = x; Index: arrays.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/typing/arrays.testsuite,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** arrays.testsuite 2 Mar 2004 17:25:33 -0000 1.2 --- arrays.testsuite 13 Oct 2004 18:28:51 -0000 1.3 *************** *** 7,24 **** /// PASS /// Toplevel ! <Any T> T id(T x) = x; ! <Any Z> void f(Z[] a) { id(new Z[1]); } /// FAIL /// Toplevel // The result is optional even if R is not. ! <Any R> R[] f(int size) = new R[size]; /// PASS /// Toplevel ! <Any R> R[] myReverse(R[] x) = superfill(new R[x.length], int i => x[x.length - 1 - i]); ! <Any T, Any U | U <: T> U[] superfill(T[] array, int->U value) { for (int i = 0; i < array.length; i++) --- 7,24 ---- /// PASS /// Toplevel ! <T> T id(T x) = x; ! <Z> void f(Z[] a) { id(new Z[1]); } /// FAIL /// Toplevel // The result is optional even if R is not. ! <R> R[] f(int size) = new R[size]; /// PASS /// Toplevel ! <R> R[] myReverse(R[] x) = superfill(new R[x.length], int i => x[x.length - 1 - i]); ! <T, U | U <: T> U[] superfill(T[] array, int->U value) { for (int i = 0; i < array.length; i++) Index: polymorphism.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/typing/polymorphism.testsuite,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** polymorphism.testsuite 14 Mar 2003 19:44:50 -0000 1.4 --- polymorphism.testsuite 13 Oct 2004 18:28:51 -0000 1.5 *************** *** 9,22 **** } ! <Any C, Any R | C <: Ref<R> > void accessRef (Ref<R> r) {} /// FAIL /// COMMENT Currently we allow only <C T> if C is a type constructor. /// Toplevel ! <Any T, T U> void f(); /// PASS /// Toplevel ! <Any T> int m(T); m(x) = 0; m(c@Collection) = c.size(); --- 9,22 ---- } ! <C, R | C <: Ref<R> > void accessRef (Ref<R> r) {} /// FAIL /// COMMENT Currently we allow only <C T> if C is a type constructor. /// Toplevel ! <T, T U> void f(); /// PASS /// Toplevel ! <T> int m(T); m(x) = 0; m(c@Collection) = c.size(); Index: null.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/typing/null.testsuite,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** null.testsuite 31 Aug 2003 00:32:56 -0000 1.8 --- null.testsuite 13 Oct 2004 18:28:51 -0000 1.9 *************** *** 2,8 **** /// PASS /// toplevel ! <Any T> void nonnull(!T); ! nonnull(x@String) {} nonnull(x) {} --- 2,8 ---- /// PASS /// toplevel ! <T> void nonnull(!T); ! nonnull(String x) {} nonnull(x) {} |
From: Arjan B. <ar...@us...> - 2004-10-13 18:29:32
|
Update of /cvsroot/nice/Nice/testsuite/compiler/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18045/F:/nice/testsuite/compiler/syntax Modified Files: anonymousFunctions.testsuite Log Message: Removed the deprecated 'Any' keyword. Index: anonymousFunctions.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/syntax/anonymousFunctions.testsuite,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** anonymousFunctions.testsuite 15 Jun 2003 14:20:57 -0000 1.9 --- anonymousFunctions.testsuite 13 Oct 2004 18:28:50 -0000 1.10 *************** *** 27,31 **** /// PASS ! String s = (<Any T>(T x)=>x)("ABC"); /// PASS --- 27,31 ---- /// PASS ! String s = (<T>(T x)=>x)("ABC"); /// PASS |
From: Arjan B. <ar...@us...> - 2004-10-13 18:29:31
|
Update of /cvsroot/nice/Nice/testsuite/compiler/statements/variables In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18045/F:/nice/testsuite/compiler/statements/variables Modified Files: bytecode.testsuite Log Message: Removed the deprecated 'Any' keyword. Index: bytecode.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/statements/variables/bytecode.testsuite,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** bytecode.testsuite 6 Mar 2003 01:47:15 -0000 1.1 --- bytecode.testsuite 13 Oct 2004 18:28:50 -0000 1.2 *************** *** 2,6 **** assert foo([1.0,2.0], true) == 1.0; /// Toplevel ! <Any T | T <: double, int <: T > T foo(T[] a, boolean first) { --- 2,6 ---- assert foo([1.0,2.0], true) == 1.0; /// Toplevel ! <T | T <: double, int <: T > T foo(T[] a, boolean first) { |
From: Arjan B. <ar...@us...> - 2004-10-13 18:29:31
|
Update of /cvsroot/nice/Nice/testsuite/compiler/methods In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18045/F:/nice/testsuite/compiler/methods Modified Files: implementations.testsuite Log Message: Removed the deprecated 'Any' keyword. Index: implementations.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/methods/implementations.testsuite,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** implementations.testsuite 7 Aug 2004 12:34:06 -0000 1.16 --- implementations.testsuite 13 Oct 2004 18:28:49 -0000 1.17 *************** *** 100,104 **** A<T> cons; } ! <Any T> A<T> j(A<A<T>>); j(b@B) = new B(cons: j(b.cons)); j(c@C) = new C(cons: j(c.cons)); --- 100,104 ---- A<T> cons; } ! <T> A<T> j(A<A<T>>); j(b@B) = new B(cons: j(b.cons)); j(c@C) = new C(cons: j(c.cons)); |
From: Arjan B. <ar...@us...> - 2004-10-13 18:29:30
|
Update of /cvsroot/nice/Nice/testsuite/compiler/expressions/operators In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18045/F:/nice/testsuite/compiler/expressions/operators Modified Files: null.testsuite Log Message: Removed the deprecated 'Any' keyword. Index: null.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/expressions/operators/null.testsuite,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** null.testsuite 2 Apr 2003 16:44:49 -0000 1.5 --- null.testsuite 13 Oct 2004 18:28:49 -0000 1.6 *************** *** 12,16 **** /// Global ! <Any T> T fail() { throw new Error(); } /// PASS --- 12,16 ---- /// Global ! <T> T fail() { throw new Error(); } /// PASS |
From: Arjan B. <ar...@us...> - 2004-10-13 18:29:30
|
Update of /cvsroot/nice/Nice/testsuite/compiler/classes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18045/F:/nice/testsuite/compiler/classes Modified Files: methods.testsuite Log Message: Removed the deprecated 'Any' keyword. Index: methods.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/classes/methods.testsuite,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** methods.testsuite 7 May 2003 08:26:11 -0000 1.2 --- methods.testsuite 13 Oct 2004 18:28:48 -0000 1.3 *************** *** 14,18 **** /// Toplevel class A { ! <Any T> T local(void -> T f) { return f(); } --- 14,18 ---- /// Toplevel class A { ! <T> T local(void -> T f) { return f(); } |
From: Arjan B. <ar...@us...> - 2004-10-13 18:29:30
|
Update of /cvsroot/nice/Nice/testsuite/compiler/expressions/arrays In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18045/F:/nice/testsuite/compiler/expressions/arrays Modified Files: compilation.testsuite zeroElements.testsuite Log Message: Removed the deprecated 'Any' keyword. Index: zeroElements.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/expressions/arrays/zeroElements.testsuite,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** zeroElements.testsuite 9 Dec 2002 19:56:01 -0000 1.1 --- zeroElements.testsuite 13 Oct 2004 18:28:48 -0000 1.2 *************** *** 22,26 **** /// PASS /// Toplevel ! <Any T> void f() { T[] a = new T[0]; --- 22,26 ---- /// PASS /// Toplevel ! <T> void f() { T[] a = new T[0]; Index: compilation.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/expressions/arrays/compilation.testsuite,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** compilation.testsuite 27 Jun 2004 20:33:06 -0000 1.11 --- compilation.testsuite 13 Oct 2004 18:28:48 -0000 1.12 *************** *** 38,42 **** assert d[1] == 0; /// Toplevel ! <Any T | T <: double, int <: T > void heapsort(T[] ra) { ra[1] = ra[0]; --- 38,42 ---- assert d[1] == 0; /// Toplevel ! <T | T <: double, int <: T > void heapsort(T[] ra) { ra[1] = ra[0]; |
From: Arjan B. <ar...@us...> - 2004-10-13 18:29:29
|
Update of /cvsroot/nice/Nice/testsuite/compiler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18045/F:/nice/testsuite/compiler Modified Files: globalVariables.testsuite Log Message: Removed the deprecated 'Any' keyword. Index: globalVariables.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/globalVariables.testsuite,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** globalVariables.testsuite 5 Mar 2004 16:24:25 -0000 1.16 --- globalVariables.testsuite 13 Oct 2004 18:28:48 -0000 1.17 *************** *** 21,25 **** /// PASS /// TOPLEVEL ! <Any T> T id(T x) = x; var int->int x = id(int y => y + 1); --- 21,25 ---- /// PASS /// TOPLEVEL ! <T> T id(T x) = x; var int->int x = id(int y => y + 1); |
From: Arjan B. <ar...@us...> - 2004-10-13 18:29:28
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18045/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Removed the deprecated 'Any' keyword. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.268 retrieving revision 1.269 diff -C2 -d -r1.268 -r1.269 *** Parser.jj 12 Oct 2004 16:57:19 -0000 1.268 --- Parser.jj 13 Oct 2004 18:28:47 -0000 1.269 *************** *** 189,193 **** | < AT: "@" > | < EXACTLY_AT: "#" > - | < ANY_: "Any" > /* Nice specific */ // Assertions --- 189,192 ---- *************** *** 448,452 **** { ( t = <IDENT> - | t = "Any" | t = "alike" | t = "var" --- 447,450 ---- *************** *** 586,592 **** } | { boolean sure = false; } ! [ t="Any" { User.warning(makeLocation(t), "The 'Any' keyword is deprecated, leave it away."); } ! | "!" { sure = true; } ! ] id=monotypeVar() { --- 584,588 ---- } | { boolean sure = false; } ! [ "!" { sure = true; } ] id=monotypeVar() { |
From: Daniel B. <bo...@us...> - 2004-10-13 15:57:06
|
Update of /cvsroot/nice/Nice/src/mlsub/typing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10830/src/mlsub/typing Modified Files: Enumeration.java Log Message: Decrease default verbosity of debugging statements. Index: Enumeration.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/Enumeration.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Enumeration.java 29 Jun 2004 18:38:18 -0000 1.13 --- Enumeration.java 13 Oct 2004 15:55:53 -0000 1.14 *************** *** 155,161 **** c != bossa.syntax.PrimitiveType.nullTC.getKind()) { ! if(linkDbg) Debug.println("Choosing kind " + c + " for " + tag); ! if (tag instanceof MonotypeVar) Engine.forceKind(tag, c.associatedKind); --- 155,161 ---- c != bossa.syntax.PrimitiveType.nullTC.getKind()) { ! if(linkDbg && Typing.dbg) Debug.println("Choosing kind " + c + " for " + tag); ! if (tag instanceof MonotypeVar) Engine.forceKind(tag, c.associatedKind); |
From: Daniel B. <bo...@us...> - 2004-10-13 15:45:25
|
Update of /cvsroot/nice/Nice/testsuite/compiler/methods In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8381/testsuite/compiler/methods Modified Files: generalization.testsuite Log Message: Handle new implementations that cover both a new method and an existing method that new one generalizes. Index: generalization.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/methods/generalization.testsuite,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** generalization.testsuite 13 Oct 2004 14:27:49 -0000 1.3 --- generalization.testsuite 13 Oct 2004 15:44:08 -0000 1.4 *************** *** 91,92 **** --- 91,109 ---- // as implementing the foo(I) method for C. } + + /// PASS + /// package a + /// Toplevel + interface A { boolean foo(); } + + /// package b import a + assert new D().foo(); + assert test(new D()); + /// Toplevel + abstract interface I { boolean foo(); } + <I T> boolean test(T x) = x.foo(); + + interface a.A implements I; + + // New implementation, which should satisfy both methods. + class D implements A { foo() = true; } |
From: Daniel B. <bo...@us...> - 2004-10-13 15:45:24
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8381/src/bossa/syntax Modified Files: NiceMethod.java Log Message: Handle new implementations that cover both a new method and an existing method that new one generalizes. Index: NiceMethod.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/NiceMethod.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** NiceMethod.java 12 Oct 2004 23:35:48 -0000 1.42 --- NiceMethod.java 13 Oct 2004 15:44:09 -0000 1.43 *************** *** 239,246 **** || Types.typeParameterDispatch(getType(), s.getType())) { ! // If the method is imported (so it has not computed what ! // methods it specializes), // check if the reverse relation holds with that method ! if (! d.specializesMethods() && Typing.smaller(itsDomain, ourDomain, true) && ! Types.typeParameterDispatch(s.getType(), getType())) --- 239,245 ---- || Types.typeParameterDispatch(getType(), s.getType())) { ! // If the method is imported, // check if the reverse relation holds with that method ! if (d.module != null && d.module.interfaceFile() && Typing.smaller(itsDomain, ourDomain, true) && ! Types.typeParameterDispatch(s.getType(), getType())) *************** *** 254,257 **** --- 253,259 ---- // d is a specialized version of this. + if (d instanceof NiceMethod) + ((NiceMethod) d).addSpecializedMethod(this); + // Therefore, all its implementations also belong to this. bossa.link.Alternative.addAll(d, this); |
From: Daniel B. <bo...@us...> - 2004-10-13 15:06:47
|
Update of /cvsroot/nice/Nice/testsuite/compiler/methods In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31659/testsuite/compiler/methods Modified Files: overriding.testsuite Log Message: When generalizing an imported method, requalify its default patterns. Index: overriding.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/methods/overriding.testsuite,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** overriding.testsuite 15 Sep 2004 12:58:57 -0000 1.8 --- overriding.testsuite 13 Oct 2004 15:05:21 -0000 1.9 *************** *** 72,78 **** override boolean foo(B); foo(B x) = true; ! /// PASS bug ! // Should we allow a more general method to be declared in a later package ! // and still discover overriding? /// package a /// Toplevel --- 72,76 ---- override boolean foo(B); foo(B x) = true; ! /// PASS /// package a /// Toplevel |
From: Daniel B. <bo...@us...> - 2004-10-13 14:29:31
|
Update of /cvsroot/nice/Nice/testsuite/compiler/methods In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22810/testsuite/compiler/methods Modified Files: generalization.testsuite Log Message: When generalizing an imported method, requalify its default patterns. Index: generalization.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/methods/generalization.testsuite,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** generalization.testsuite 12 Oct 2004 23:35:48 -0000 1.2 --- generalization.testsuite 13 Oct 2004 14:27:49 -0000 1.3 *************** *** 70,71 **** --- 70,92 ---- <Addable A, T> void addTwice(A<T> a, T e) { a.add(e); a.add(e); } + + /// FAIL + /// package a + /// Toplevel + interface A { void foo() {} } + + /// package b import a + new C().doAdd(); + /// Toplevel + class B { void foo() {} } + + abstract interface I { void /*/// FAIL HERE */ foo(); } + <I T> void doAdd(T x) = x.foo(); + + interface a.A implements I; + + class C extends B implements I { + // Missing implementation of foo. + // Another option would be to accept the foo(B) implementation + // as implementing the foo(I) method for C. + } |
From: Daniel B. <bo...@us...> - 2004-10-13 14:29:31
|
Update of /cvsroot/nice/Nice/src/bossa/link In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22810/src/bossa/link Modified Files: Alternative.java Log Message: When generalizing an imported method, requalify its default patterns. Index: Alternative.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/link/Alternative.java,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** Alternative.java 12 Oct 2004 23:35:49 -0000 1.54 --- Alternative.java 13 Oct 2004 14:27:49 -0000 1.55 *************** *** 28,31 **** --- 28,32 ---- import nice.tools.code.Gen; + import nice.tools.typing.Types; import java.util.*; *************** *** 236,243 **** { Alternative a = (Alternative) i.next(); ! a.add(fullName); } } public static Stack sortedAlternatives(MethodDeclaration m) { --- 237,274 ---- { Alternative a = (Alternative) i.next(); ! a.addDefaultPatterns(from).add(fullName); } } + Alternative addDefaultPatterns(MethodDeclaration def) + { + Monotype[] parameters = Types.parameters(def.getType()); + Pattern[] newPatterns = null; + + for (int i = 0; i < patterns.length; i++) + if (patterns[i].getTC() == null) + { + if (newPatterns == null) + { + newPatterns = new Pattern[patterns.length]; + System.arraycopy(patterns, 0, newPatterns, 0, i); + } + newPatterns[i] = bossa.syntax.dispatch.createPattern + (patterns[i].getName(), + Types.concreteConstructor(parameters[i]), + Types.isSure(parameters[i])); + } + + if (newPatterns == null) + return this; + else + return new Alternative(methodName, newPatterns) { + public Expression methodExp() + { + return Alternative.this.methodExp(); + } + }; + } + public static Stack sortedAlternatives(MethodDeclaration m) { |
From: Daniel B. <bo...@us...> - 2004-10-12 23:35:59
|
Update of /cvsroot/nice/Nice/src/bossa/link In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6059/src/bossa/link Modified Files: Alternative.java Added Files: JavaAlternative.java Log Message: Allow existing Java methods to be generalized. --- NEW FILE: JavaAlternative.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.link; import bossa.syntax.JavaMethod; import bossa.syntax.Pattern; import nice.tools.typing.Types; /** An alternative for calling an existing Java method. @author Daniel Bonniot (bo...@us...) */ class JavaAlternative extends Alternative { JavaAlternative(JavaMethod method) { super(method.getName().toString(), patterns(method)); this.method = method; } JavaMethod method; static Pattern[] patterns(bossa.syntax.MethodDeclaration method) { mlsub.typing.Monotype[] parameters = Types.parameters(method.getType()); Pattern[] res = new Pattern[parameters.length]; for (int i = 0; i < res.length; i++) res[i] = bossa.syntax.dispatch.createPattern (null, Types.concreteConstructor(parameters[i]), Types.isSure(parameters[i])); return res; } public gnu.expr.Expression methodExp() { return method.getCode(); } } Index: Alternative.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/link/Alternative.java,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** Alternative.java 12 Oct 2004 18:39:18 -0000 1.53 --- Alternative.java 12 Oct 2004 23:35:49 -0000 1.54 *************** *** 18,21 **** --- 18,22 ---- import bossa.syntax.MethodDeclaration; + import bossa.syntax.JavaMethod; import bossa.syntax.Pattern; import bossa.syntax.LocatedString; *************** *** 33,37 **** * Represents a method alternative in the link. * ! * It can be build either from information in a Bossa source, * or read from a compiled bytecode file. * --- 34,38 ---- * Represents a method alternative in the link. * ! * It can be build either from information in a Nice source, * or read from a compiled bytecode file. * *************** *** 222,225 **** --- 223,231 ---- public static void addAll(MethodDeclaration from, MethodDeclaration to) { + String fullName = to.getFullName(); + + if (from instanceof JavaMethod) + new JavaAlternative((JavaMethod) from).add(fullName); + List list = (List) alternatives.get(from.getFullName()); *************** *** 227,232 **** return; - String fullName = to.getFullName(); - for(Iterator i = list.iterator(); i.hasNext();) { --- 233,236 ---- |
From: Daniel B. <bo...@us...> - 2004-10-12 23:35:59
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6059/src/bossa/syntax Modified Files: NiceMethod.java MethodDeclaration.java JavaMethod.java InlinedMethod.java Log Message: Allow existing Java methods to be generalized. Index: JavaMethod.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/JavaMethod.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** JavaMethod.java 24 Feb 2004 14:05:48 -0000 1.30 --- JavaMethod.java 12 Oct 2004 23:35:48 -0000 1.31 *************** *** 98,106 **** } ! gnu.expr.Expression getCode() { return nice.tools.code.Gen.wrapInLambda(new PrimProcedure(reflectMethod)); } ! /**************************************************************** * Module interface --- 98,106 ---- } ! public gnu.expr.Expression getCode() { return nice.tools.code.Gen.wrapInLambda(new PrimProcedure(reflectMethod)); } ! /**************************************************************** * Module interface Index: NiceMethod.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/NiceMethod.java,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** NiceMethod.java 12 Oct 2004 18:39:18 -0000 1.41 --- NiceMethod.java 12 Oct 2004 23:35:48 -0000 1.42 *************** *** 244,249 **** if (! d.specializesMethods() && Typing.smaller(itsDomain, ourDomain, true) && ! ! Types.typeParameterDispatch(getType(), s.getType())) { // d is a specialized version of this. // Therefore, all its implementations also belong to this. --- 244,256 ---- if (! d.specializesMethods() && Typing.smaller(itsDomain, ourDomain, true) && ! ! Types.typeParameterDispatch(s.getType(), getType())) { + if (! Types.covariantSpecialization(s.getType(), getType())) + User.error + (returnTypeLocation!=null ? returnTypeLocation :location(), + "The return type should be less precise than the return type of method\n" + + d + "\ndefined in:\n" + + d.location()); + // d is a specialized version of this. // Therefore, all its implementations also belong to this. Index: InlinedMethod.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/InlinedMethod.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** InlinedMethod.java 11 Feb 2004 13:16:26 -0000 1.17 --- InlinedMethod.java 12 Oct 2004 23:35:48 -0000 1.18 *************** *** 170,174 **** } ! gnu.expr.Expression getCode() { return nice.tools.code.Gen.wrapInLambda(getProcedure()); --- 170,174 ---- } ! public gnu.expr.Expression getCode() { return nice.tools.code.Gen.wrapInLambda(getProcedure()); Index: MethodDeclaration.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MethodDeclaration.java,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** MethodDeclaration.java 24 Jun 2004 08:11:09 -0000 1.61 --- MethodDeclaration.java 12 Oct 2004 23:35:48 -0000 1.62 *************** *** 455,459 **** protected abstract gnu.expr.Expression computeCode(); ! gnu.expr.Expression getCode() { // Default implementation. --- 455,459 ---- protected abstract gnu.expr.Expression computeCode(); ! public gnu.expr.Expression getCode() { // Default implementation. |
From: Daniel B. <bo...@us...> - 2004-10-12 23:35:58
|
Update of /cvsroot/nice/Nice/testsuite/compiler/methods In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6059/testsuite/compiler/methods Modified Files: generalization.testsuite Log Message: Allow existing Java methods to be generalized. Index: generalization.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/methods/generalization.testsuite,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** generalization.testsuite 12 Oct 2004 18:39:05 -0000 1.1 --- generalization.testsuite 12 Oct 2004 23:35:48 -0000 1.2 *************** *** 34,40 **** class a.Collection implements Fooable; ! /// PASS bug /// Toplevel abstract interface Addable<T> { void add(T item); } interface java.util.Collection implements Addable; --- 34,71 ---- class a.Collection implements Fooable; ! /// PASS ! let c = new ArrayList(); ! c.addTwice("A"); ! assert c.size() == 2; ! ! // Check that overrides work ! let l = new SilentlyEmptyList(); ! l.addTwice("A"); ! assert l.size() == 0; /// Toplevel abstract interface Addable<T> { void add(T item); } interface java.util.Collection implements Addable; + + <Addable A, T> void addTwice(A<T> a, T e) { a.add(e); a.add(e); } + + class SilentlyEmptyList<T> extends LinkedList + { + add(e) = false; + } + + /// FAIL + let c = new ArrayList(); + c.addTwice("A"); + assert c.size() == 2; + + /// Toplevel + abstract interface Addable<T> + { + // Wrong return type + /*/// FAIL HERE */ String add(T item); + } + + interface java.util.Collection implements Addable; + + <Addable A, T> void addTwice(A<T> a, T e) { a.add(e); a.add(e); } |