nice-commit Mailing List for The Nice Programming Language (Page 38)
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-08-26 23:45:44
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27163/F:/nice/stdlib/nice/lang Modified Files: java.nice Log Message: Removed some retypings on StringBuffer because of ambigiuty when using java 1.4.2 or newer. Index: java.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/java.nice,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** java.nice 12 Aug 2004 09:30:54 -0000 1.57 --- java.nice 26 Aug 2004 23:45:33 -0000 1.58 *************** *** 52,66 **** String concat(String, String) = native String String.concat(String); - StringBuffer append(StringBuffer, ?String) = - native StringBuffer StringBuffer.append(String); - StringBuffer append(StringBuffer, char) = - native StringBuffer StringBuffer.append(char); StringBuffer append(StringBuffer, char[] str, int offset, int len) = native StringBuffer StringBuffer.append(char[], int, int); char[] toCharArray(String) = native char[] String.toCharArray(); - <T> StringBuffer append(StringBuffer, T) = - native StringBuffer StringBuffer.append(Object); - <T> StringBuffer insert(StringBuffer, int, T) = - native StringBuffer StringBuffer.insert(int, Object); String substring(StringBuffer, int) = native String StringBuffer.substring(int); --- 52,58 ---- |
From: Arjan B. <ar...@us...> - 2004-08-25 20:49:49
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27508/F:/nice/src/bossa/syntax Modified Files: dispatch.java.bootstrap Log Message: Removed superfluous signatures from dispatch.java Index: dispatch.java.bootstrap =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/dispatch.java.bootstrap,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** dispatch.java.bootstrap 8 Aug 2004 21:51:54 -0000 1.20 --- dispatch.java.bootstrap 25 Aug 2004 20:49:39 -0000 1.21 *************** *** 16,31 **** { return null; } - public static Expression createFunExp(bossa.syntax.Constraint cst, List formals, Statement body) - { return null; } - - static Expression createFunExp(bossa.syntax.Constraint cst, MonoSymbol[] formals, Statement body) - { return null; } - public static Expression createLiteralArrayExp(List exps) { return null; } - static Expression createOverloadedSymbolExp(List l, LocatedString s) - { return null; } - public static Expression createNewExp(TypeIdent ti, Arguments arguments) { return null; } --- 16,22 ---- *************** *** 37,51 **** { return null; } - public static Expression createCallExp(Expression function, Expression param1, Expression param2, Expression param3) - { return null; } - - public static Expression createCallExp(Expression func, Arguments args, boolean infix, boolean hasBrackets) - { return null; } - - public static Expression createCallExp(Expression func, Arguments args) - { return null; } - - public static void addBlockArgument(Expression callexp, Statement block, LocatedString name) {} - public static gnu.bytecode.Method getImplementationAbove(JavaMethod decl, gnu.bytecode.ClassType firstArg) { return null; } --- 28,31 ---- *************** *** 89,103 **** { return false; } - public static Expression createExpLocalVariable(LocatedString name, Expression value, boolean constant, Monotype type) - { return null; } - - public static Statement createLocalVariable(LocatedString name, Monotype type, boolean constant, Expression value) - { return null; } - - public void addNextLocal(Statement localValue, LocatedString name, Expression value) {} - - public static Statement createLocalFunction(LocatedString name, Monotype returnType, FormalParameters parameters, Statement body) - { return null; } - public static Statement createBlock(List statements) { return null; } --- 69,72 ---- |
From: Arjan B. <ar...@us...> - 2004-08-25 19:57:32
|
Update of /cvsroot/nice/Nice/testsuite/compiler/null In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17355/F:/nice/testsuite/compiler/null Modified Files: inference.testsuite Log Message: Take in account nullness test in asserts. Index: inference.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/null/inference.testsuite,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** inference.testsuite 21 Jan 2004 13:16:39 -0000 1.10 --- inference.testsuite 25 Aug 2004 19:57:22 -0000 1.11 *************** *** 390,391 **** --- 390,406 ---- } while(x++ < 10); } + + /// PASS + ?String s = foo(); + assert s != null; + String x = s; + /// Toplevel + ?String foo() = ""; + + /// FAIL + ?String s = foo(); + assert s != null; + s = null; + String /*/// FAIL HERE*/ x = s; + /// Toplevel + ?String foo() = ""; |
From: Arjan B. <ar...@us...> - 2004-08-25 19:57:31
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17355/F:/nice/src/bossa/syntax Modified Files: typecheck.nice Log Message: Take in account nullness test in asserts. Index: typecheck.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typecheck.nice,v retrieving revision 1.113 retrieving revision 1.114 diff -C2 -d -r1.113 -r1.114 *** typecheck.nice 13 Aug 2004 21:04:41 -0000 1.113 --- typecheck.nice 25 Aug 2004 19:57:20 -0000 1.114 *************** *** 211,214 **** --- 211,222 ---- if (e.isCallTo("assert") && 1 <= e.arguments.size() <= 2) { + ?List<MonoSymbol> l = variablesNotNullIfTestSucceeds(e.arguments.getExp(0)); + if (l != null) + l.foreach(MonoSymbol variable => { + mlsub.typing.Monotype type = notNull(variable.type); + mlsub.typing.Monotype sureType = makeSure(type); + setVarType(variable, now: sureType, out: type); + }); + ?List<(MonoSymbol, mlsub.typing.Monotype)> instanceofIfSucceeds = first_(instanceofInfo(e.arguments.getExp(0))); |
From: Arjan B. <ar...@us...> - 2004-08-23 13:31:22
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22362/F:/nice/stdlib/nice/lang Modified Files: collections.nice Log Message: Simplified the type of apply. Index: collections.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/collections.nice,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** collections.nice 16 Aug 2004 09:21:21 -0000 1.73 --- collections.nice 23 Aug 2004 13:30:56 -0000 1.74 *************** *** 126,130 **** /** self modifying map over an list */ ! <T,U,V | U <: T, T <: V> void apply(List<T> list, V->U func) { for (int i = 0; i < list.size(); i++) --- 126,130 ---- /** self modifying map over an list */ ! <T> void apply(List<T> list, T->T func) { for (int i = 0; i < list.size(); i++) |
From: Arjan B. <ar...@us...> - 2004-08-22 18:27:28
|
Update of /cvsroot/nice/Nice/testsuite/compiler/classes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15637/F:/nice/testsuite/compiler/classes Modified Files: specialization.testsuite Log Message: Testcase for bug in extending a java class with less type parameters. Index: specialization.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/classes/specialization.testsuite,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** specialization.testsuite 12 Aug 2004 23:21:41 -0000 1.1 --- specialization.testsuite 22 Aug 2004 18:27:18 -0000 1.2 *************** *** 41,42 **** --- 41,46 ---- class B<T,V> extends A<T, String, V> {} class C<T,V> extends A<V, String, T> {} + + /// PASS bug + /// Toplevel + class Foo extends HashMap<String, String> {} |
From: Arjan B. <ar...@us...> - 2004-08-19 14:38:25
|
Update of /cvsroot/nice/Nice/testsuite/compiler/statements/loops In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16611/F:/nice/testsuite/compiler/statements/loops Modified Files: break.testsuite Log Message: Testcase for bug in codegeneration when breaking out of a try-finally block. Index: break.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/statements/loops/break.testsuite,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** break.testsuite 13 Jun 2003 21:54:30 -0000 1.4 --- break.testsuite 19 Aug 2004 14:38:15 -0000 1.5 *************** *** 42,43 **** --- 42,53 ---- for(;;) continue /*/// FAIL HERE */ undefined_label; + + /// PASS bug + boolean doneFinally = false; + for(;;) + try { + break; + } finally { + doneFinally = true; + } + assert doneFinally; |
From: Arjan B. <ar...@us...> - 2004-08-16 09:21:30
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv362/F:/nice/stdlib/nice/lang Modified Files: collections.nice Log Message: Added List.apply. Index: collections.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/collections.nice,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** collections.nice 13 Aug 2004 06:24:39 -0000 1.72 --- collections.nice 16 Aug 2004 09:21:21 -0000 1.73 *************** *** 125,128 **** --- 125,135 ---- } + /** self modifying map over an list */ + <T,U,V | U <: T, T <: V> void apply(List<T> list, V->U func) + { + for (int i = 0; i < list.size(); i++) + list[i] = func(list[i]); + } + /**************************************************************** * Implementations |
From: Arjan B. <ar...@us...> - 2004-08-14 11:14:24
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25287/F:/nice/src/bossa/syntax Modified Files: pattern.nice Log Message: Regrouped methods in pattern.nice. Index: pattern.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/pattern.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pattern.nice 7 Aug 2004 14:20:29 -0000 1.1 --- pattern.nice 14 Aug 2004 11:14:15 -0000 1.2 *************** *** 98,111 **** public class VariablePattern extends Pattern { - matches(tag) = true; - - matchesValue(ConstantExp val) = true; - - toString() = (name != null) ? notNull(name).toString() : "_"; - - bytecodeRepresentation() = "@_"; - - matchTest(parameter, dispatchMade) = notNull(gnu.expr.QuoteExp.trueExp); - atAny() = true; } --- 98,101 ---- *************** *** 113,144 **** public class NullPattern extends Pattern { - matches(tag) = tag == PrimitiveType.nullTC; - - matchesValue(ConstantExp val) = false; - - toString() = "null"; - - bytecodeRepresentation() = "@NULL"; - - matchTest(parameter, dispatchMade) = nice.tools.code.Gen.isNullExp(parameter); - atNull() = true; } ! public class NotNullPattern extends Pattern ! { ! matches(tag) = tag != PrimitiveType.nullTC; ! ! matchesValue(ConstantExp val) = false; ! ! toString() = "!null"; ! ! bytecodeRepresentation() = "@NONNULL"; ! ! matchTest(parameter, dispatchMade) ! { ! return nice.tools.code.Gen.boolNotExp(nice.tools.code.Gen.isNullExp(parameter)); ! } ! } public class TypePattern extends Pattern --- 103,110 ---- public class NullPattern extends Pattern { atNull() = true; } ! public class NotNullPattern extends Pattern {} public class TypePattern extends Pattern *************** *** 162,212 **** } - matches(tag) - { - if (tag == null) - return false; - - if (exactlyAt) - return mlsub.typing.Typing.testRigidLeq(tag, tc) && mlsub.typing.Typing.testRigidLeq(tc, tag); - - return mlsub.typing.Typing.testRigidLeq(tag, tc); - } - - matchesValue(ConstantExp val) = false; - - toString() - { - StringBuffer res = new StringBuffer(); - res.append(exactlyAt ? "#" : (name != null ? "" : "@")); - - if (typeConstructor != null) - res.append(typeConstructor); - else if (tc != null) - res.append(tc); - - if (name != null) - res.append(" " + name); - - return res.toString(); - } - - bytecodeRepresentation() - { - return (exactlyAt ? "#" : "@") + notNull(tc).toString().replace('$','.'); - } - - matchTest(parameter, dispatchMade) - { - if (dispatchMade && ! exactlyAt) - return notNull(gnu.expr.QuoteExp.trueExp); - - let ct = nice.tools.code.Types.javaType(tc); - - if (exactlyAt) - return nice.tools.code.Gen.isOfClass(parameter, ct); - - return nice.tools.code.Gen.instanceOfExp(parameter, ct); - } - exactlyAtType() = exactlyAt; } --- 128,131 ---- *************** *** 216,225 **** final ConstantExp atValue; - matches(tag) = false; - - matchesValue(ConstantExp val) = atValue.equals(val); - - toString() = atValue.toString(); - addValues(values) { --- 135,138 ---- *************** *** 238,253 **** } - matches(tag) = tag == PrimitiveType.boolTC; - - bytecodeRepresentation() = atValue.isTrue() ? "@true" : "@false"; - - matchTest(parameter, dispatchMade) - { - if (atValue.isFalse()) - return nice.tools.code.Gen.boolNotExp(parameter); - - return cast(parameter); - } - atTypeMatchingValue() = true; } --- 151,154 ---- *************** *** 256,275 **** { override StringConstantExp atValue; - - bytecodeRepresentation() { - return "@\"" + atValue.escapedValue + "\""; - } - - matchTest(parameter, dispatchMade) - { - let String val = cast(atValue.value); - return nice.tools.code.Gen.stringEquals(val, parameter); - } } public class CharPattern extends ValuePattern { - bytecodeRepresentation() = "@\'" + atValue.value + "\'"; - setDomainTC(domaintc) { --- 157,164 ---- *************** *** 280,297 **** User.error(this.location, "Character value patterns are not allowed for methods where the declared parameter isn't a primitive type."); } - - matchTest(parameter, dispatchMade) - { - return nice.tools.code.Gen.integerComparison("Eq", parameter, atValue.longValue()); - } } public class IntPattern extends ValuePattern { - matchesValue(ConstantExp val) - { - return (val.value instanceof Number) && atValue.longValue() == val.longValue(); - } - setDomainTC(domaintc) { --- 169,176 ---- *************** *** 310,323 **** } User.error(this.location, "Integer value patterns are not allowed for methods where the declared parameter isn't a primitive type."); - } - - bytecodeRepresentation() = "@" + (atValue.longValue() >= 0 ? "+" : "") + atValue; - - matchTest(parameter, dispatchMade) - { - return nice.tools.code.Gen.integerComparison("Eq", parameter, atValue.longValue()); - } - } --- 189,193 ---- *************** *** 336,355 **** ?LocatedString refName; - matches(tag) = tag != null && mlsub.typing.Typing.testRigidLeq(tag, PrimitiveType.longTC); - - matchesValue(ConstantExp val) - { - return val.value instanceof Number && matches(kind, val.longValue(), atValue.longValue()); - } - - toString() = (name!=null? notNull(name).toString() : "") + kind.prefix + atValue; - - bytecodeRepresentation() = "@" + kind.prefix + atValue; - - matchTest(parameter, dispatchMade) - { - return nice.tools.code.Gen.integerComparison(kind.abbrev, parameter, atValue.longValue()); - } - addValues(values) { --- 206,209 ---- *************** *** 376,392 **** atTypeMatchingValue() = true; - } public class ReferencePattern extends ValuePattern { - - bytecodeRepresentation() = "@=" + name; - - matchTest(parameter, dispatchMade) - { - return nice.tools.code.Gen.referenceEqualsExp(atValue.compile(), parameter); - } - getName() = cast(null); } --- 230,237 ---- *************** *** 394,399 **** public class EnumPattern extends ReferencePattern { - matches(tag) = (tag != null) && mlsub.typing.Typing.testRigidLeq(tag, tc); - addValues(values) { --- 239,242 ---- *************** *** 407,410 **** --- 250,285 ---- } + matches(VariablePattern p, tag) = true; + matches(NullPattern p, tag) = tag == PrimitiveType.nullTC; + matches(NotNullPattern p, tag) = tag != PrimitiveType.nullTC; + matches(TypePattern p, tag) + { + if (tag == null) + return false; + + if (p.exactlyAt) + return mlsub.typing.Typing.testRigidLeq(tag, p.tc) && mlsub.typing.Typing.testRigidLeq(p.tc, tag); + + return mlsub.typing.Typing.testRigidLeq(tag, p.tc); + } + matches(ValuePattern p, tag) = false; + matches(BoolPattern p, tag) = tag == PrimitiveType.boolTC; + matches(IntComparePattern p, tag) = tag != null && mlsub.typing.Typing.testRigidLeq(tag, PrimitiveType.longTC); + matches(EnumPattern p, tag) = (tag != null) && mlsub.typing.Typing.testRigidLeq(tag, p.tc); + + matchesValue(VariablePattern p, ConstantExp val) = true; + matchesValue(NullPattern p, ConstantExp val) = false; + matchesValue(NotNullPattern p, ConstantExp val) = false; + matchesValue(TypePattern p, ConstantExp val) = false; + matchesValue(ValuePattern p, ConstantExp val) = p.atValue.equals(val); + matchesValue(IntPattern p, ConstantExp val) + { + return (val.value instanceof Number) && p.atValue.longValue() == val.longValue(); + } + matchesValue(IntComparePattern p, ConstantExp val) + { + return val.value instanceof Number && matches(p.kind, val.longValue(), p.atValue.longValue()); + } + /** Order on pattern that is compatible with the specificity of patterns. *************** *** 517,520 **** --- 392,463 ---- } + matchTest(VariablePattern p, parameter, dispatchMade) = gnu.expr.QuoteExp.trueExp; + matchTest(NullPattern p, parameter, dispatchMade) = nice.tools.code.Gen.isNullExp(parameter); + matchTest(NotNullPattern p, parameter, dispatchMade) + { + return nice.tools.code.Gen.boolNotExp(nice.tools.code.Gen.isNullExp(parameter)); + } + matchTest(TypePattern p, parameter, dispatchMade) + { + if (dispatchMade && ! p.exactlyAt) + return gnu.expr.QuoteExp.trueExp; + + let ct = nice.tools.code.Types.javaType(p.tc); + + if (p.exactlyAt) + return nice.tools.code.Gen.isOfClass(parameter, ct); + + return nice.tools.code.Gen.instanceOfExp(parameter, ct); + } + matchTest(BoolPattern p, parameter, dispatchMade) + { + if (p.atValue.isFalse()) + return nice.tools.code.Gen.boolNotExp(parameter); + + return cast(parameter); + } + matchTest(StringPattern p, parameter, dispatchMade) + { + let String val = cast(p.atValue.value); + return nice.tools.code.Gen.stringEquals(val, parameter); + } + matchTest(CharPattern p, parameter, dispatchMade) + { + return nice.tools.code.Gen.integerComparison("Eq", parameter, p.atValue.longValue()); + } + matchTest(IntPattern p, parameter, dispatchMade) + { + return nice.tools.code.Gen.integerComparison("Eq", parameter, p.atValue.longValue()); + } + matchTest(IntComparePattern p, parameter, dispatchMade) + { + return nice.tools.code.Gen.integerComparison(p.kind.abbrev, parameter, p.atValue.longValue()); + } + matchTest(ReferencePattern p, parameter, dispatchMade) + { + return nice.tools.code.Gen.referenceEqualsExp(p.atValue.compile(), parameter); + } + + toString(VariablePattern p) = (p.name != null) ? notNull(p.name).toString() : "_"; + toString(NullPattern p) = "null"; + toString(NotNullPattern p) = "!null"; + toString(TypePattern p) + { + let res = new StringBuffer(); + res.append(p.exactlyAt ? "#" : (p.name != null ? "" : "@")); + + if (p.typeConstructor != null) + res.append(p.typeConstructor); + else if (p.tc != null) + res.append(p.tc); + + if (p.name != null) + res.append(" " +p.name); + + return res.toString(); + } + toString(ValuePattern p) = p.atValue.toString(); + toString(IntComparePattern p) = (p.name!=null? notNull(p.name).toString() : "") + p.kind.prefix + p.atValue; + private ?VarSymbol findRefSymbol(LocatedString refName) *************** *** 597,665 **** } public ?Pattern readPattern(String rep, int[]/*ref*/ pos) { ! if (pos[0] >= rep.length()) return null; ! if (rep.charAt(pos[0]) != '@' && rep.charAt(pos[0]) != '#') ! Internal.error("Invalid pattern representation at character " + pos[0] + ": " + rep); ! boolean exact = rep.charAt(pos[0]) == '#'; ! int start = pos[0]+1; ! pos[0] += 1; int len = rep.length(); ! if (rep.charAt(pos[0]) == '\'') { //char literal patterns are 3 chars ! pos[0] += 3; } ! else if (rep.charAt(pos[0]) == '\"') { //we need to skip possible '@' or '#' content of the string literal ! pos[0] += 2; ! while(pos[0] < len && ! ! ( ( rep.charAt(pos[0]) == '@' || rep.charAt(pos[0]) != '#') ! && rep.charAt(pos[0]-1) == '\"' ! && rep.charAt(pos[0]-2) != '\\') ) ! pos[0] += 1; } else { ! while(pos[0] < len && rep.charAt(pos[0]) != '@' && rep.charAt(pos[0]) != '#') ! pos[0] += 1; } ! String name = rep.substring(start, pos[0]); let loc = Location.nowhere(); if (name.length() > 1) { ! if (name.charAt(0) == '\'') return createPattern(new ConstantExp(PrimitiveType.charTC, ! new Character(name.charAt(1)), name, loc)); ! if (name.charAt(0) == '-') return createPattern(ConstantExp.makeNumber(new LocatedString(name, loc))); ! if (name.charAt(0) == '+') return createPattern(ConstantExp.makeNumber(new LocatedString( name.substring(1), loc))); ! if (name.charAt(0) == '\"') return createPattern(ConstantExp.makeString(new LocatedString( name.substring(1,name.length()-1), loc))); ! if (name.charAt(0) == '<' || name.charAt(0) == '>') { ! let prefix = (name.charAt(1) == '=') ? name.substring(0,2) : name.substring(0,1); return createPattern(prefix, null, ConstantExp.makeNumber( new LocatedString(name.substring(prefix.length()), loc)), null, loc); } ! if (name.charAt(0) == '=') return resolveGlobalConstants(new VariablePattern(new LocatedString(name.substring(1), loc), loc)); - } --- 540,623 ---- } + bytecodeRepresentation(VariablePattern p) = "@_"; + bytecodeRepresentation(NullPattern p) = "@NULL"; + bytecodeRepresentation(NotNullPattern p) = "@NONNULL"; + bytecodeRepresentation(TypePattern p) + { + return (p.exactlyAt ? "#" : "@") + notNull(p.tc).toString().replace('$','.'); + } + bytecodeRepresentation(BoolPattern p) = p.atValue.isTrue() ? "@true" : "@false"; + bytecodeRepresentation(StringPattern p) = "@\"" + p.atValue.escapedValue + "\""; + bytecodeRepresentation(CharPattern p) = "@\'" + p.atValue.value + "\'"; + bytecodeRepresentation(IntPattern p) = "@" + (p.atValue.longValue() >= 0 ? "+" : "") + p.atValue; + bytecodeRepresentation(IntComparePattern p) = "@" + p.kind.prefix + p.atValue; + bytecodeRepresentation(ReferencePattern p) = "@=" + p.name; + public ?Pattern readPattern(String rep, int[]/*ref*/ pos) { ! int cpos = pos[0]; ! ! if (cpos >= rep.length()) return null; ! if (rep[cpos] != '@' && rep[cpos] != '#') ! Internal.error("Invalid pattern representation at character " + cpos + ": " + rep); ! boolean exact = rep[cpos] == '#'; ! int start = ++cpos; int len = rep.length(); ! if (rep[cpos] == '\'') { //char literal patterns are 3 chars ! cpos += 3; } ! else if (rep[cpos] == '\"') { //we need to skip possible '@' or '#' content of the string literal ! cpos += 2; ! while(cpos < len && ! ! ( ( rep[cpos] == '@' || rep[cpos] != '#') ! && rep[cpos-1] == '\"' ! && rep[cpos-2] != '\\') ) ! cpos++; } else { ! while(cpos < len && rep[cpos] != '@' && rep[cpos] != '#') ! cpos++; } ! String name = rep.substring(start, cpos); ! pos[0] = cpos; let loc = Location.nowhere(); if (name.length() > 1) { ! if (name[0] == '\'') return createPattern(new ConstantExp(PrimitiveType.charTC, ! new Character(name[1]), name, loc)); ! 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] == '\"') return createPattern(ConstantExp.makeString(new LocatedString( name.substring(1,name.length()-1), loc))); ! if (name[0] == '<' || name[0] == '>') { ! 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)); } *************** *** 678,686 **** // This can happen if the class exists only in a later version // of the JDK. ! throw new Unknown(); let mlsub.typing.TypeConstructor tc = cast(sym); return new TypePattern(null, tc, Location.nowhere(), exactlyAt:exact); } - - public class Unknown extends RuntimeException {} --- 636,642 ---- // This can happen if the class exists only in a later version // of the JDK. ! throw new Pattern.Unknown(); let mlsub.typing.TypeConstructor tc = cast(sym); return new TypePattern(null, tc, Location.nowhere(), exactlyAt:exact); } |
From: Arjan B. <ar...@us...> - 2004-08-13 21:04:52
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11917/F:/nice/src/bossa/syntax Modified Files: analyse.nice block.nice break.nice increment.nice loop.nice new.nice overloadedsymbol.nice return.nice statementexp.nice tools.nice typecheck.nice Log Message: Cleanup of nullness things in converted code. Index: analyse.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/analyse.nice,v retrieving revision 1.109 retrieving revision 1.110 diff -C2 -d -r1.109 -r1.110 *** analyse.nice 8 Aug 2004 21:51:54 -0000 1.109 --- analyse.nice 13 Aug 2004 21:04:41 -0000 1.110 *************** *** 273,277 **** } ! void analyseExps(?Expression[] exps, Info info) { for (int i = 0; i < exps.length; i++) --- 273,277 ---- } ! void analyseExps(Expression[] exps, Info info) { for (int i = 0; i < exps.length; i++) *************** *** 303,307 **** { e.initValue = analyse(e.initValue, info); ! setInitialized(notNull(notNull(e.variable).left), info, e.location()); return e; } --- 303,307 ---- { e.initValue = analyse(e.initValue, info); ! setInitialized(e.variable.left, info, e.location()); return e; } *************** *** 358,362 **** e.isCallTo("assert") && args.size() > 0 && args.getExp(0).isFalse(); ! markAsCallFun(notNull(e.function), e.infix); e.function = analyse(e.function, info); --- 358,362 ---- e.isCallTo("assert") && args.size() > 0 && args.getExp(0).isFalse(); ! markAsCallFun(e.function, e.infix); e.function = analyse(e.function, info); *************** *** 569,573 **** analyse(LiteralArrayExp e, info) { ! analyseExps(cast(e.elements), info); return e; } --- 569,573 ---- analyse(LiteralArrayExp e, info) { ! analyseExps(e.elements, info); return e; } *************** *** 576,580 **** { e.resolveTC(info.typeMap); ! analyseExps(cast(notNull(e.knownDimensions)), info); return e; } --- 576,580 ---- { e.resolveTC(info.typeMap); ! analyseExps(e.knownDimensions, info); return e; } *************** *** 667,671 **** analyse(TupleExp e, info) { ! analyseExps(cast(notNull(e.expressions)), info); return e; } --- 667,671 ---- analyse(TupleExp e, info) { ! analyseExps(e.expressions, info); return e; } *************** *** 691,698 **** decl.setIndex(++info.varIndex); ! info.addVar(notNull(decl.left)); ! if (info.localsOfCurrentLoop != null && notNull(decl.left).constant) ! notNull(info.localsOfCurrentLoop).add(notNull(decl.left)); } --- 691,698 ---- decl.setIndex(++info.varIndex); ! info.addVar(decl.left); ! if (info.localsOfCurrentLoop != null && decl.left.constant) ! notNull(info.localsOfCurrentLoop).add(decl.left); } *************** *** 700,711 **** { decl.value = analyse(decl.value, info); ! info.addVar(notNull(decl.left)); } analyse(LocalFunction decl, info) { ! notNull(decl.parameters).resolveCalledFromAnalyse(cast(info)); ! info.addVar(notNull(decl.left)); decl.value = analyse(decl.value, info); } --- 700,711 ---- { decl.value = analyse(decl.value, info); ! info.addVar(decl.left); } analyse(LocalFunction decl, info) { ! decl.parameters.resolveCalledFromAnalyse(cast(info)); ! info.addVar(decl.left); decl.value = analyse(decl.value, info); } *************** *** 797,801 **** analyse(LabeledStmt s, info) { ! mustNotFindLabel(notNull(s.getLabel()), info); info.labels.push(s); analyse(s.getStatement(), info); --- 797,801 ---- analyse(LabeledStmt s, info) { ! mustNotFindLabel(s.getLabel(), info); info.labels.push(s); analyse(s.getStatement(), info); *************** *** 830,834 **** analyse(BreakLabelStmt b, info) { ! LabeledStmt target = b.statement = mustFindLabel(notNull(b.label), info); ?LoopStmt loop = target.getLoop(); --- 830,834 ---- analyse(BreakLabelStmt b, info) { ! LabeledStmt target = b.statement = mustFindLabel(b.label, info); ?LoopStmt loop = target.getLoop(); *************** *** 884,888 **** info.otherCase(); info.begin(); ! info.addVar(notNull(c.exnVar)); c.t = notNull(c.tc).resolveToTC(info.typeMap); c.tc = null; --- 884,888 ---- info.otherCase(); info.begin(); ! info.addVar(c.exnVar); c.t = notNull(c.tc).resolveToTC(info.typeMap); c.tc = null; Index: break.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/break.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** break.nice 11 Aug 2004 13:36:09 -0000 1.2 --- break.nice 13 Aug 2004 21:04:41 -0000 1.3 *************** *** 86,92 **** generateCode() { - // if (statement == null) - // return notNull(gnu.expr.QuoteExp.voidExp); - let res = block = new gnu.expr.BlockExp(); notNull(block).setBody(statement.generateCode()); --- 86,89 ---- Index: return.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/return.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** return.nice 28 Jul 2004 20:48:28 -0000 1.2 --- return.nice 13 Aug 2004 21:04:41 -0000 1.3 *************** *** 45,49 **** mlsub.typing.Polytype returnType() { ! return notNull(PrimitiveType.voidPolytype); } --- 45,49 ---- mlsub.typing.Polytype returnType() { ! return PrimitiveType.voidPolytype; } Index: typecheck.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typecheck.nice,v retrieving revision 1.112 retrieving revision 1.113 diff -C2 -d -r1.112 -r1.113 *** typecheck.nice 8 Aug 2004 21:51:54 -0000 1.112 --- typecheck.nice 13 Aug 2004 21:04:41 -0000 1.113 *************** *** 40,44 **** typecheck(AssignExp e) { ! Expression to = notNull(notNull(e.to).noOverloading()); e.to = to; typecheck(to); --- 40,44 ---- typecheck(AssignExp e) { ! Expression to = e.to.noOverloading(); e.to = to; typecheck(to); *************** *** 52,57 **** try{ ! e.value = notNull(e.value).resolveOverloading(to.getType()); ! checkAssignment(to.getType(), notNull(e.value)); } catch(TypingEx t){ --- 52,57 ---- try{ ! e.value = e.value.resolveOverloading(to.getType()); ! checkAssignment(to.getType(), e.value); } catch(TypingEx t){ *************** *** 61,65 **** try { ! checkAssignment(originalType, notNull(e.value)); // It is OK to assign the variable, considering it has the original --- 61,65 ---- try { ! checkAssignment(originalType, e.value); // It is OK to assign the variable, considering it has the original *************** *** 80,89 **** toName = field.getName().toString(); ! reportNullAssignmentError(e, t, value: notNull(e.value), toName, to.getType().getMonotype(), field != null); throw assignmentError(e, to.toString(), ! to.getType().toString(), notNull(e.value)); } --- 80,89 ---- toName = field.getName().toString(); ! reportNullAssignmentError(e, t, value: e.value, toName, to.getType().getMonotype(), field != null); throw assignmentError(e, to.toString(), ! to.getType().toString(), e.value); } *************** *** 93,100 **** if (originalType != null) try { ! checkAssignment(originalType, notNull(e.value)); } catch (TypingEx t) { throw assignmentError(e, to.toString(), ! to.getType().toString(), notNull(e.value)); } } --- 93,100 ---- if (originalType != null) try { ! checkAssignment(originalType, e.value); } catch (TypingEx t) { throw assignmentError(e, to.toString(), ! to.getType().toString(), e.value); } } *************** *** 102,106 **** } ! void typecheckExps(?Expression[] exps) { for (int i = 0; i < exps.length; i++) --- 102,106 ---- } ! void typecheckExps(Expression[] exps) { for (int i = 0; i < exps.length; i++) *************** *** 508,514 **** typecheck(IfExp e) { ! Expression condition = notNull(e.condition); ! Expression thenExp = notNull(e.thenExp); ! Expression elseExp = notNull(e.elseExp); condition = condition.resolveOverloading(PrimitiveType.boolPolytype); --- 508,514 ---- typecheck(IfExp e) { ! Expression condition = e.condition; ! Expression thenExp = e.thenExp; ! Expression elseExp = e.elseExp; condition = condition.resolveOverloading(PrimitiveType.boolPolytype); *************** *** 539,543 **** setVarType(variable, now: type, otherBranch: variable.type)); ! e.thenExp = thenExp = notNull(thenExp.noOverloading()); typecheck(thenExp); // since the type of the variable is destructively changed, --- 539,543 ---- setVarType(variable, now: type, otherBranch: variable.type)); ! e.thenExp = thenExp = thenExp.noOverloading(); typecheck(thenExp); // since the type of the variable is destructively changed, *************** *** 561,565 **** setVarType(variable, now: type, out: variable.type)); ! e.elseExp = elseExp = notNull(elseExp.noOverloading()); typecheck(elseExp); // since the type of the variable is destructively changed, --- 561,565 ---- setVarType(variable, now: type, out: variable.type)); ! e.elseExp = elseExp = elseExp.noOverloading(); typecheck(elseExp); // since the type of the variable is destructively changed, *************** *** 610,615 **** { try{ ! e.variable = notNull(e.variable).resolveOverloading(PrimitiveType.longPolytype); ! checkAssignment(PrimitiveType.longType, notNull(e.variable)); } catch(TypingEx t){ --- 610,615 ---- { try{ ! e.variable = e.variable.resolveOverloading(PrimitiveType.longPolytype); ! checkAssignment(PrimitiveType.longType, e.variable); } catch(TypingEx t){ *************** *** 617,622 **** throw new bossa.util.UserError (e, ! notNull(e.description()) + " is only valid on integers.\n" + ! e.variable + " has type " + notNull(e.variable).getType()); } } --- 617,622 ---- throw new bossa.util.UserError (e, ! e.description() + " is only valid on integers.\n" + ! e.variable + " has type " + e.variable.getType()); } } *************** *** 624,633 **** typecheck(LiteralArrayExp e) { ! typecheckExps(cast(e.elements)); } typecheck(NewArrayExp e) { ! Expression[] knownDimensions = notNull(e.knownDimensions); for (int i=0; i<knownDimensions.length; i++) --- 624,633 ---- typecheck(LiteralArrayExp e) { ! typecheckExps(e.elements); } typecheck(NewArrayExp e) { ! Expression[] knownDimensions = e.knownDimensions; for (int i=0; i<knownDimensions.length; i++) *************** *** 662,666 **** typecheck(TupleExp e) { ! typecheckExps(cast(notNull(e.expressions))); } --- 662,666 ---- typecheck(TupleExp e) { ! typecheckExps(e.expressions); } *************** *** 678,682 **** { let decl = e.variable; ! MonoSymbol target = notNull(decl.left); if (! target.used) --- 678,682 ---- { let decl = e.variable; ! MonoSymbol target = decl.left; if (! target.used) *************** *** 684,688 **** ?mlsub.typing.Monotype type = target.getMonotype(); ! Expression value = notNull(e.initValue); if (type == null) --- 684,688 ---- ?mlsub.typing.Monotype type = target.getMonotype(); ! Expression value = e.initValue; if (type == null) *************** *** 733,742 **** b.statements = rewrite(b.statements); ! b.locals.foreach(?LocalDeclaration d => typecheck(d)); b.statements.foreach ! (?Statement s => { try { typecheck(s); } catch (bossa.util.UserError ex) ! { throw ensureLocated(ex, notNull(s)); } }); } --- 733,742 ---- b.statements = rewrite(b.statements); ! b.locals.foreach(LocalDeclaration d => typecheck(d)); b.statements.foreach ! (Statement s => { try { typecheck(s); } catch (bossa.util.UserError ex) ! { throw ensureLocated(ex, s); } }); } *************** *** 748,752 **** typecheck(LocalVariable decl) { ! MonoSymbol target = notNull(decl.left()); if (! target.used) --- 748,752 ---- typecheck(LocalVariable decl) { ! MonoSymbol target = decl.left; if (! target.used) *************** *** 765,769 **** if (target.type == PrimitiveType.byteType || target.type == PrimitiveType.shortType) ! target.type = notNull(PrimitiveType.intType); if (nice.tools.typing.Types.isVoid(target.type)) --- 765,769 ---- if (target.type == PrimitiveType.byteType || target.type == PrimitiveType.shortType) ! target.type = PrimitiveType.intType; if (nice.tools.typing.Types.isVoid(target.type)) *************** *** 791,796 **** typecheck(LocalConstant decl) { ! if (! notNull(decl.left).used) ! bossa.util.User.warning(decl, "Unused local variable " + notNull(decl.left).name); typecheck(decl.value); --- 791,796 ---- typecheck(LocalConstant decl) { ! if (! decl.left.used) ! bossa.util.User.warning(decl, "Unused local variable " + decl.left.name); typecheck(decl.value); *************** *** 798,804 **** mlsub.typing.Polytype type = notNull(decl.value).getType(); ! notNull(decl.left).type = ensureMonomorphic(type, decl); ! if (nice.tools.typing.Types.isVoid(notNull(decl.left).type)) throw error(decl, "A variable cannot have a void type"); --- 798,804 ---- mlsub.typing.Polytype type = notNull(decl.value).getType(); ! decl.left.type = ensureMonomorphic(type, decl); ! if (nice.tools.typing.Types.isVoid(decl.left.type)) throw error(decl, "A variable cannot have a void type"); *************** *** 883,887 **** ?mlsub.typing.Monotype expectedType = function.getExpectedType(); if (expectedType == null) ! r.value = notNull(r.value).noOverloading(); else { --- 883,887 ---- ?mlsub.typing.Monotype expectedType = function.getExpectedType(); if (expectedType == null) ! r.value = r.value.noOverloading(); else { *************** *** 889,894 **** throw bossa.util.User.error(r, "Cannot return a value here"); ! r.value = notNull(r.value).resolveOverloading ! (new mlsub.typing.Polytype(expectedType)); } --- 889,893 ---- throw bossa.util.User.error(r, "Cannot return a value here"); ! r.value = r.value.resolveOverloading(new mlsub.typing.Polytype(expectedType)); } *************** *** 902,906 **** catch(Function.WrongReturnType e){ if (notNullError(notNull(e.typingException), r, String.valueOf(r.value))) ! wrongReturnType(r, notNull(r.returnType()).toString(), valueOf(e.expectedReturnType), notNull(e.typingException)); } --- 901,905 ---- catch(Function.WrongReturnType e){ if (notNullError(notNull(e.typingException), r, String.valueOf(r.value))) ! wrongReturnType(r, r.returnType().toString(), valueOf(e.expectedReturnType), notNull(e.typingException)); } *************** *** 923,927 **** } catch(Function.WrongReturnType e){ ! wrongReturnType(r, notNull(r.returnType()).toString(), valueOf(e.expectedReturnType), notNull(e.typingException)); } --- 922,926 ---- } catch(Function.WrongReturnType e){ ! wrongReturnType(r, r.returnType().toString(), valueOf(e.expectedReturnType), notNull(e.typingException)); } *************** *** 941,946 **** typecheck(SynchronizedStmt s) { ! s.object = notNull(s.object).noOverloading(); ! mlsub.typing.Polytype type = notNull(s.object).getType(); if (nice.tools.typing.Types.isPrimitive(type)) throw bossa.util.User.error(s.object, --- 940,945 ---- typecheck(SynchronizedStmt s) { ! s.object = s.object.noOverloading(); ! mlsub.typing.Polytype type = s.object.getType(); if (nice.tools.typing.Types.isPrimitive(type)) throw bossa.util.User.error(s.object, Index: statementexp.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/statementexp.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** statementexp.nice 28 Jul 2004 14:40:33 -0000 1.1 --- statementexp.nice 13 Aug 2004 21:04:41 -0000 1.2 *************** *** 27,33 **** compile() { - if (statement == null) - return notNull(gnu.expr.QuoteExp.voidExp); - return new gnu.expr.BeginExp(statement.generateCode(), gnu.expr.QuoteExp.voidExp); } --- 27,30 ---- Index: loop.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/loop.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** loop.nice 8 Aug 2004 21:51:54 -0000 1.3 --- loop.nice 13 Aug 2004 21:04:41 -0000 1.4 *************** *** 60,69 **** if (whileExp == null) ! test = notNull(gnu.expr.QuoteExp.trueExp); else test = notNull(whileExp).generateCode(); if (iterationStatements == null) ! iteration = notNull(gnu.expr.QuoteExp.voidExp); else iteration = notNull(iterationStatements).generateCode(); --- 60,69 ---- if (whileExp == null) ! test = gnu.expr.QuoteExp.trueExp; else test = notNull(whileExp).generateCode(); if (iterationStatements == null) ! iteration = gnu.expr.QuoteExp.voidExp; else iteration = notNull(iterationStatements).generateCode(); *************** *** 77,81 **** res = notNull(code); ! notNull(code).setBody(loopBody != null ? notNull(loopBody).generateCode() : null); code = null; --- 77,81 ---- res = notNull(code); ! notNull(code).setBody(loopBody.generateCode()); code = null; *************** *** 91,100 **** { if (!testFirst) ! return "do {\n" + (loopBody == null ? " " : loopBody.toString()) + ! "}\n while (" + whileExp + ");"; if (iterationStatements == null) ! return "while (" + whileExp + ")" + ! (loopBody == null ? ";" : loopBody.toString()); Block itbl = cast(iterationStatements); --- 91,98 ---- { if (!testFirst) ! return "do {\n" + loopBody + "}\n while (" + whileExp + ");"; if (iterationStatements == null) ! return "while (" + whileExp + ")" + loopBody; Block itbl = cast(iterationStatements); *************** *** 108,113 **** } ! return "for(; " + whileExp + " ;" + itStats + ")\n " + ! (loopBody == null ? "" : loopBody.toString()); } } --- 106,110 ---- } ! return "for(; " + whileExp + " ;" + itStats + ")\n " + loopBody; } } Index: new.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/new.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** new.nice 5 Aug 2004 10:45:30 -0000 1.2 --- new.nice 13 Aug 2004 21:04:41 -0000 1.3 *************** *** 14,18 **** import bossa.util.*; - import java.util.*; /** --- 14,17 ---- Index: block.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/block.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** block.nice 8 Aug 2004 21:51:54 -0000 1.1 --- block.nice 13 Aug 2004 21:04:41 -0000 1.2 *************** *** 149,153 **** let stmts = res.cutInBlocks(statements); res.statements = stmts; ! if (stmts != null && stmts.length > 0 && stmts[0] != null) res.setLocation(stmts[0].location()); return res; --- 149,153 ---- let stmts = res.cutInBlocks(statements); res.statements = stmts; ! if (stmts.length > 0) res.setLocation(stmts[0].location()); return res; Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** tools.nice 8 Aug 2004 21:51:54 -0000 1.47 --- tools.nice 13 Aug 2004 21:04:41 -0000 1.48 *************** *** 211,217 **** --- 211,220 ---- mlsub.typing.Polytype boolPolytype() = native PrimitiveType.boolPolytype; mlsub.typing.Polytype longPolytype() = native PrimitiveType.longPolytype; + mlsub.typing.Polytype voidPolytype() = native PrimitiveType.voidPolytype; mlsub.typing.Monotype boolType() = native PrimitiveType.boolType; mlsub.typing.Monotype intType() = native PrimitiveType.intType; mlsub.typing.Monotype longType() = native PrimitiveType.longType; + gnu.expr.QuoteExp trueExp() = native gnu.expr.QuoteExp.trueExp; + gnu.expr.QuoteExp voidExp() = native gnu.expr.QuoteExp.voidExp; // Local Variables: Index: overloadedsymbol.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/overloadedsymbol.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** overloadedsymbol.nice 5 Aug 2004 10:45:30 -0000 1.3 --- overloadedsymbol.nice 13 Aug 2004 21:04:41 -0000 1.4 *************** *** 420,426 **** Expression createOverloadedSymbolExp(List<VarSymbol> symbols, LocatedString ident) { - if(symbols == null) - Internal.error("No symbols"); - let res = new OverloadedSymbolExp(symbols: symbols, ident: ident); res.setLocation(ident.location()); --- 420,423 ---- *************** *** 431,437 **** boolean noImplicitThis) { - if(symbols == null) - Internal.error("No symbols"); - let res = new OverloadedSymbolExp(symbols: symbols, ident: ident, noImplicitThis: noImplicitThis); res.setLocation(ident.location()); --- 428,431 ---- Index: increment.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/increment.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** increment.nice 28 Jul 2004 14:40:33 -0000 1.1 --- increment.nice 13 Aug 2004 21:04:41 -0000 1.2 *************** *** 50,54 **** "so it should be a call to a FieldAccessMethod"); ! let access = notNull(notNull(call).function).getFieldAccessMethod(); if (access == null) Internal.error(this, "\"var\" is assignable and not a local, " + --- 50,54 ---- "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, " + |
From: Daniel B. <bo...@us...> - 2004-08-13 17:25:13
|
Update of /cvsroot/nice/Nice/debian In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6488/debian Modified Files: control Log Message: Use short-form email address, so that no tool thinks there are NMUs. Index: control =================================================================== RCS file: /cvsroot/nice/Nice/debian/control,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** control 30 Jun 2004 10:15:27 -0000 1.19 --- control 13 Aug 2004 17:25:05 -0000 1.20 *************** *** 2,6 **** Section: devel Priority: optional ! Maintainer: Daniel Bonniot <bo...@us...> Build-Depends-Indep: debhelper (>> 3.0.0), jikes-classpath (>= 1:1.18), kaffe (>= 1:1.1.1), javacc, groff, libant1.6-java Standards-Version: 3.6.1 --- 2,6 ---- Section: devel Priority: optional ! Maintainer: Daniel Bonniot <bo...@us...> Build-Depends-Indep: debhelper (>> 3.0.0), jikes-classpath (>= 1:1.18), kaffe (>= 1:1.1.1), javacc, groff, libant1.6-java Standards-Version: 3.6.1 |
From: Arjan B. <ar...@us...> - 2004-08-13 17:11:45
|
Update of /cvsroot/nice/Nice/testsuite/compiler/typing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3511/F:/nice/testsuite/compiler/typing Modified Files: dti.testsuite Log Message: Added failure positions. Index: dti.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/typing/dti.testsuite,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** dti.testsuite 12 Aug 2004 13:26:47 -0000 1.1 --- dti.testsuite 13 Aug 2004 17:11:36 -0000 1.2 *************** *** 28,32 **** s = null; ! s.substring(1); /// PASS bug --- 28,32 ---- s = null; ! s. /*/// FAIL HERE*/ substring(1); /// PASS bug *************** *** 76,80 **** } ! s.substring(1); /// FAIL --- 76,80 ---- } ! s. /*/// FAIL HERE*/ substring(1); /// FAIL *************** *** 99,106 **** try { s = null; ! maybeException(); s = "xyz"; } catch (Exception e) { ! s.substring(1); } --- 99,106 ---- try { s = null; ! maybeThrow(); s = "xyz"; } catch (Exception e) { ! s. /*/// FAIL HERE*/ substring(1); } *************** *** 108,112 **** ?String s = "abc"; try { ! maybeException(); } catch (Exception e) { s = null; --- 108,112 ---- ?String s = "abc"; try { ! maybeThrow(); } catch (Exception e) { s = null; *************** *** 114,118 **** s = "xyz"; } finally { ! s.substring(1); } --- 114,118 ---- s = "xyz"; } finally { ! s. /*/// FAIL HERE*/ substring(1); } *************** *** 122,126 **** int x = 0; while (x++ < 10) { ! s.substring(1); func = () => {s = null; }; func(); --- 122,126 ---- int x = 0; while (x++ < 10) { ! s. /*/// FAIL HERE*/ substring(1); func = () => {s = null; }; func(); |
From: Daniel B. <bo...@us...> - 2004-08-13 15:51:29
|
Update of /cvsroot/nice/Nice/debian In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21050/debian Modified Files: changelog Log Message: 0.9.8-2 Index: changelog =================================================================== RCS file: /cvsroot/nice/Nice/debian/changelog,v retrieving revision 1.240 retrieving revision 1.241 diff -C2 -d -r1.240 -r1.241 *** changelog 30 Jun 2004 09:48:58 -0000 1.240 --- changelog 13 Aug 2004 15:51:15 -0000 1.241 *************** *** 1,2 **** --- 1,12 ---- + nice (0.9.8-2) unstable; urgency=low + + * New upload for 0.9.8. Version 0.9.8-1 was never uploaded to the archive + (closes: #262246). + * Added watch file. + * Apply upstream fix to nicec unix script, so that the emacs mode gets + the right exit code. + + -- Daniel Bonniot <bo...@us...> Fri, 13 Aug 2004 15:02:17 +0200 + nice (0.9.8-1) unstable; urgency=low |
From: Daniel B. <bo...@us...> - 2004-08-13 12:52:27
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18139/src/bossa/parser Modified Files: Parser.jj Log Message: Remove parsing for "= ...;". It was only used for compiled toplevel functions, which do not exist anymore. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.258 retrieving revision 1.259 diff -C2 -d -r1.258 -r1.259 *** Parser.jj 13 Aug 2004 06:24:39 -0000 1.258 --- Parser.jj 13 Aug 2004 12:52:11 -0000 1.259 *************** *** 1365,1372 **** // An expression { Expression exp; } ! "=" ! ( "..." { return null; } // toplevel function in interface file ! | ! exp=Expression() ";" { code = bossa.syntax.dispatch.createReturnStmt(exp, /* fake */ true); } | {Statement res;} --- 1365,1372 ---- // An expression { Expression exp; } ! "=" ! ( ! exp=Expression() ";" ! { code = bossa.syntax.dispatch.createReturnStmt(exp, /* fake */ true); } | {Statement res;} |
From: Daniel B. <bo...@us...> - 2004-08-13 12:44:13
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17174/stdlib/nice/lang Modified Files: range.nice Log Message: Range does not support remove and removeAll. Index: range.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/range.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** range.nice 13 Aug 2004 06:24:39 -0000 1.3 --- range.nice 13 Aug 2004 12:44:04 -0000 1.4 *************** *** 57,62 **** listIterator() = new RangeIterator(range: this, pos: begin.index-1); ! listIterator(index) = new RangeIterator(range: this, pos: begin.index + index-1); } --- 57,64 ---- listIterator() = new RangeIterator(range: this, pos: begin.index-1); ! listIterator(index) = new RangeIterator(range: this, pos: begin.index + index-1); + remove(elem) = throw new UnsupportedOperationException(); + removeAll(elems) = throw new UnsupportedOperationException(); } |
From: Bryn K. <xo...@us...> - 2004-08-13 06:24:49
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24699/stdlib/nice/lang Modified Files: ForInIters.nice collections.nice range.nice Added Files: slice.nice Log Message: Added new [] overloads for lists - slicing, relative-to-end indexing, filters, etc. Index: collections.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/collections.nice,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** collections.nice 29 Jul 2004 12:36:12 -0000 1.71 --- collections.nice 13 Aug 2004 06:24:39 -0000 1.72 *************** *** 172,175 **** --- 172,176 ---- similarEmptyCollection(#HashSet c) = new HashSet(c.size()); + /**************************************************************** * Sort Index: range.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/range.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** range.nice 19 Nov 2003 16:04:45 -0000 1.2 --- range.nice 13 Aug 2004 06:24:39 -0000 1.3 *************** *** 18,58 **** package nice.lang; - public class Range<T | T <: int, int <: T> extends AbstractList<T> { ! private final int begin; ! private final int end; isEmpty() = false; ! size() = 1+end-begin; get(index) { ! if (index < 0 || index >= 1+end-begin) throw new IndexOutOfBoundsException(); ! return begin + index; } add(elem) = throw new UnsupportedOperationException(); ! contains(elem) = begin <= cast(elem) <= end; - iterator() = new RangeIterator(range: this, pos: begin-1); ! listIterator() = new RangeIterator(range: this, pos: begin-1); ! listIterator(index) = new RangeIterator(range: this, pos: begin + index-1); } ! public class RangeIterator<T | T <: int, int <: T> implements ListIterator<T> { ! final Range<int> range; int pos; ! hasNext() = pos+1 <= range.end; next() = ++pos; ! hasPrevious() = pos-1 >= range.begin; previous() = --pos; ! nextIndex() = (pos-range.begin) + 1; ! previousIndex() = pos - range.begin; remove() = throw new UnsupportedOperationException(); --- 18,82 ---- package nice.lang; ! public class OpenRange<T | T <: int, int <: T> extends Slice<T> ! { ! { ! assert !begin.relativeToEnd: ! "OpenRange objects cannot be relative to a list end"; ! assert !end.relativeToEnd || end.index == 0: ! "OpenRange objects cannot be relative to a list end"; ! } ! Iterator<T> openIterator() = new OpenRangeIterator(range: this, ! pos: begin.index-1); ! } ! ! public class Range<T | T <: int, int <: T> extends OpenRange<T> ! implements List<T> { ! ! { ! assert !end.relativeToEnd: ! "Range objects must have fixed dimensions"; ! } isEmpty() = false; ! size() = 1+end.index-begin.index; get(index) { ! if (index < 0 || index >= 1+end.index-begin.index) ! throw new IndexOutOfBoundsException(); ! return int(begin.index) + int(index); } add(elem) = throw new UnsupportedOperationException(); ! contains(elem) = begin.index <= cast(elem) <= end.index; ! iterator() = new RangeIterator(range: this, pos: begin.index - 1); ! listIterator() = new RangeIterator(range: this, pos: begin.index-1); ! listIterator(index) = new RangeIterator(range: this, pos: begin.index + index-1); } ! public class OpenRangeIterator<T | T <: int, int <: T> implements Iterator<T> { ! final OpenRange<T> range; int pos; ! hasNext() = pos+1 <= range.end.index || (range.end.isInfinite); next() = ++pos; ! remove() = throw new UnsupportedOperationException(); ! } ! ! public class RangeIterator<T | T <: int, int <: T> extends OpenRangeIterator ! implements ListIterator<T> { ! ! hasNext() = pos+1 <= range.end.index; ! hasPrevious() = pos-1 >= range.begin.index; previous() = --pos; ! nextIndex() = (pos-range.begin.index) + 1; ! previousIndex() = pos - range.begin.index; remove() = throw new UnsupportedOperationException(); *************** *** 61,66 **** } - public Range<int> `..`(int begin, int end) requires begin <= end - { - return new Range(begin: begin, end: end); - } --- 85,86 ---- --- NEW FILE: slice.nice --- /**************************************************************************** * N I C E * * A high-level object-oriented research language * * (c) Daniel Bonniot 2003 * * * * This package is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * Free Software Foundation; either version 2 of the License, or (at your * * option) any later version. * * * * As a special exception, the copyright holders of this library give you * * permission to link this library with independent modules to produce an * * executable, regardless of the license terms of these independent * * modules, and to copy and distribute the resulting executable under * * terms of your choice. * ****************************************************************************/ package nice.lang; public class Index { final boolean relativeToEnd; final int index = 0; <U> int normalize(List<U> list) { if (relativeToEnd) return (list.size() - 1) + index; else return index; } boolean isInfinite() = relativeToEnd && index == 0; } Index `@`() = new Index(index: 0, relativeToEnd: true); public Index `-`(Index index, int offset) requires index.relativeToEnd { return new Index(index: index.index - offset, relativeToEnd: true); } public class Slice<T | T <: int, int <: T> { private final Index begin; private final Index end; <U> (int,int) normalize(List<U> list) { let normalBegin = begin.normalize(list); let normalEnd = end.normalize(list); assert normalEnd >= normalBegin : "Beginning index cannot be greater than ending index"; return (normalBegin, normalEnd); } } public OpenRange<int> `..`(int begin, ?int end) requires end == null || end >= 0, begin >= 0 { let beginIndex = new Index(index: begin, relativeToEnd: false); let endIndex = end == null ? new Index(index: 0, relativeToEnd: true) :new Index(index: end, relativeToEnd: false); if (end == null) return new OpenRange(begin: beginIndex, end: endIndex); else return new Range(begin: beginIndex, end: endIndex); } public Slice<int> `..` (int begin, Index end) requires begin >= 0 { let beginIndex = new Index(index: begin, relativeToEnd: false); return new Slice(begin: beginIndex, end: end); } public Slice<int> `..` (Index begin, ?int end) { let endIndex = new Index(index: end == null ? 0 : end, relativeToEnd: end == null); return new Slice(begin: begin, end: endIndex); } public Slice<int> `..` (Index begin, Index end) { return new Slice(begin: begin, end: end); } Index: ForInIters.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/ForInIters.nice,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ForInIters.nice 17 Jan 2004 16:35:43 -0000 1.7 --- ForInIters.nice 13 Aug 2004 06:24:39 -0000 1.8 *************** *** 25,29 **** Iterator<char> forIterator(String s) = new StringForIterator(str: s); Iterator<char> forIterator(StringBuffer sb) = new StringBufferForIterator(strb: sb); ! Iterator<int> forIterator(Range<int> range) = range.iterator(); //The implementations of additional Iterators --- 25,31 ---- Iterator<char> forIterator(String s) = new StringForIterator(str: s); Iterator<char> forIterator(StringBuffer sb) = new StringBufferForIterator(strb: sb); ! ! <T | T <: int, int <: T> ! Iterator<T> forIterator(OpenRange<T> range) = range.openIterator(); //The implementations of additional Iterators |
From: Bryn K. <xo...@us...> - 2004-08-13 06:24:49
|
Update of /cvsroot/nice/Nice/stdlib/nice/functional In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24699/stdlib/nice/functional Modified Files: iterator.nice Added Files: list-operators.nice Log Message: Added new [] overloads for lists - slicing, relative-to-end indexing, filters, etc. Index: iterator.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/functional/iterator.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** iterator.nice 19 Apr 2004 11:10:14 -0000 1.3 --- iterator.nice 13 Aug 2004 06:24:39 -0000 1.4 *************** *** 25,28 **** --- 25,32 ---- */ + /** + * Allow iterators in for() statements + */ + <E> Iterator<E> forIterator(Iterator<E> iter) = iter; /** --- NEW FILE: list-operators.nice --- /**************************************************************************** * N I C E * * A high-level object-oriented research language * * (c) Daniel Bonniot 2003 * * * * This package is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * Free Software Foundation; either version 2 of the License, or (at your * * option) any later version. * * * * As a special exception, the copyright holders of this library give you * * permission to link this library with independent modules to produce an * * executable, regardless of the license terms of these independent * * modules, and to copy and distribute the resulting executable under * * terms of your choice. * ****************************************************************************/ /** * Overloaded [] operators for lists * * @author Bryn Keller <xo...@xo...> */ /** * Support negative indexes, by using the <code>@</code> operator, * which represents the last index in the list. So the next-to-last * element in the list can be addressed as <code>@-1</code>, for * instance. */ package nice.functional; <T> T get(List<T> list, Index index) = list[index.normalize(list)]; /** * Returns a sub-list of the original, starting from the index * specified in the first part of the slice, and continuing * up to (and including) the index specified in the second * part of the slice. */ <T> List<T> get(List<T> list, Slice<int> slice) { (int lbound, int ubound) = slice.normalize(list); let newList = list.similarEmptyCollection(); for(int i = lbound; i <= ubound; i++) newList.add(list[i]); return newList; } /** * Assigns a sub-list into a list, starting from the index * specified in the first part of the slice tuple, and continuing * up to (and including) the index specified in the second * part of the slice. * If null is supplied for the first part of the slice, it's the * same as supplying zero. If null is supplied for the last * part of the slice, it's the same as specifying list.size(). * To use negative indexes, use the <code>@</code> operator, * which means "the size of the current list -1", or perhaps * "negative zero", the position of the last element in the list. * . So for instance, <code>someList[(1..@-1)]</code> would give * all the elements of <code>someList</code> except the first and the * last. * * The items in <code>values</code> will replace those in <code>list</code> * according to the <code>slice</code> argument. */ <T> void set(List<T> list, Slice<int> slice, List<T> values) { (int lbound, int ubound) = slice.normalize(list); if (ubound - lbound >= values.size()) throw new IllegalArgumentException( "Not enough values for a slice this size"); int counter = lbound; for(item : values) list[counter++] = item; } <T> void removeAt(List<T> list, Slice<int> slice) { (int lbound, int ubound) = slice.normalize(list); for(int i = lbound; i <= ubound; i++) { list.removeAt(lbound); } } /** * Helper. */ private <T> T illegalArgument(String msg) = throw new IllegalArgumentException(msg); /** * Returns the sub-list of <code>list</code> for which <code>func</code> * returns true, i.e., <code>list.filter(func)</code>. */ <T> List<T> get(List<T> list, T->boolean func) = list.filter(func); // Too cryptic, skipped. // /** // * Returns the sub-list of <code>list</code> for which <code>func</code> // * returns non-null, i.e., <code>list.filter(func)</code>. Note that // * This is really a combination of map and filter. // */ // <List C, T,U> C<!U> get(C<T> source, T->?U converter) = source.filter( // converter: converter); /** * Returns a list of all the items of <code>list</code> at all the * given <code>indexes</code>. */ <T> List<T> get(List<T> list, List<int> indexes) { let newList = list.similarEmptyCollection(); for(i : indexes) { newList.add(list[i]); } return newList; } <T> Iterator<T> get(Iterator<T> iterator, T->boolean func) = iterator.filter(func); /** * Helper. */ private <T> void->T cycle(List<T> list) { var int counter = 0; return () => { let val = list[counter]; counter++; counter = counter % list.size(); return val; }; } /** * Sets multiple values. */ <T> void set(List<T> list, List<int> indexes, List<T> values) requires values.size() >= indexes.size() { let valueGen = values.generator(); for(i:indexes) list[i] = valueGen(); } /** * Replaces values of list with <code>value</code> wherever * <code>func</code> returns true for the original value. */ <T> void set(List<T> list, T->boolean func, T value) { let size = list.size(); for(int i = 0; i < size; i++) { if (func(list[i])) list[i] = value; } } /** * Replaces values of list with the next value of <code>gen</code> wherever * <code>func</code> returns true for the original value. */ <T> void set(List<T> list, T->boolean func, void->T gen) { let size = list.size(); for(int i = 0; i < size; i++) { if (func(list[i])) list[i] = gen(); } } /** * Helper. */ private <T> ArrayList<T> toArrayList(List<T> src) { let newList = new ArrayList(); newList.addAll(src); return newList; } //Uncomment after dev compiler supports slice expressions // private void _testCollectionFunctions() // { // let List<int> ints = [0, 1, 2, 3, 4, 5, 6].toArrayList(); // assert ints[@] == 6; // assert ints[@-2] ==4; // let evens = ints[int i => i % 2 == 0]; // println(evens); // assert evens[0] == 0; // assert evens[1] == 2; // assert evens[2] == 4; // assert evens[3] == 6; // assert evens.size == 4; // // let evenNames = ints[int i => i % 2 == 0 ? // // new java.math.BigInteger((i + 10).toString()).toString(16) // // : null]; // // assert evenNames[0].equals("a"); // // assert evenNames[1].equals("c"); // // assert evenNames.size == evens.size; // // println(evenNames); // var mutables = ints.toArrayList(); // mutables[int i => i % 2 == 0] = 27; // println(mutables); // assert mutables[0] == 27; // assert mutables[1] == 1; // assert mutables[2] == 27; // assert mutables[3] == 3; // assert mutables[4] == 27; // assert mutables[5] == 5; // assert mutables[6] == 27; // var counter = 0; // mutables[int i => i == 27] = ()=> counter++; // println(mutables); // assert mutables[0] == 0; // assert mutables[6] == 3; // mutables = ints.toArrayList(); // let sl1 = mutables[1..4]; // assert sl1.size == 4 : sl1.size.toString; // assert sl1[0] == 1; // assert sl1[3] == 4; // let sl2 = mutables[1..@-1]; // assert sl2.size == mutables.size - 2; // assert sl2[0] == 1; // assert sl2[sl2.size - 1] == mutables[mutables.size - 2]; // let sl3 = mutables[@-1..@-1]; // assert sl3.size == 1: "sl3 wrong size"; // assert sl3[0] == mutables[mutables.size - 2]: "sl3 wrong elem 0"; // let sl4 = mutables[..2]; // assert sl4.size == 3; // assert sl4[0] == 0; // assert sl4[2] == 2; // let sl5 = mutables[3..]; // assert sl5.size == mutables.size - 3; // assert sl5[0] == mutables[3]; // assert sl5[sl5.size - 1] == mutables[mutables.size - 1]; // let sl6 = mutables[@-1..]; // assert sl6.size == 2; // assert sl6[0] == mutables[mutables.size - 2]; // assert sl6[1] == mutables[mutables.size - 1]; // let len = mutables.size; // mutables[1..2] = [9,8]; // try // { // mutables[1..3] = [9,8]; // assert false : "Failed"; // } // catch (Exception e) // { // //Pass // } // assert mutables.size == len; // let sl7 = mutables[1..2]; // assert sl7[0] == 9; // assert sl7[1] == 8; // mutables = ints.toArrayList(); // mutables.removeAt(2..@-1); // assert mutables.size() == 3: mutables.size().toString(); // assert mutables[0] == 0; // assert mutables[1] == 1; // assert mutables[2] == 6; // mutables = ints.toArrayList(); // let sl8 = mutables[..]; // for(int i = 0; i < mutables.size(); i++) { // assert mutables[i] == sl8[i]; // } // } |
From: Bryn K. <xo...@us...> - 2004-08-13 06:24:48
|
Update of /cvsroot/nice/Nice In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24699 Modified Files: NEWS Log Message: Added new [] overloads for lists - slicing, relative-to-end indexing, filters, etc. Index: NEWS =================================================================== RCS file: /cvsroot/nice/Nice/NEWS,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** NEWS 12 Aug 2004 23:43:21 -0000 1.43 --- NEWS 13 Aug 2004 06:24:38 -0000 1.44 *************** *** 23,26 **** --- 23,45 ---- * Improved speed of coverage tests for some methods. * Removed the '--strict' compiler option. + * Lists now support a wide array of slicing and indexing + operations. There is a new bit of syntax, '@', which indicates + the index of the last item in a list, which can be used for working + with indexes relative to the end of the list, instead of the beginning. + + For instance, given a list of ints from 0 to 6 called + 'intList': + intList[@] is 6, + intList[@-1] is 5, + intList[1..2] is the list [1,2]. + intList[1..@-1] is a list of all but the first and last + elements of ints, i.e., [1,2,3,4,5] + intList[1..] is a list of all but the first element of intList + intList[..] is a complete copy of intList + intList[..@-1] is a list of all but the last element of intList + intList[int i => i % 2 == 0] is a list of all the even ints + in intList: [0,2,4,6] + Several more options are available, an update to the manual will + reflect this. -- |
From: Bryn K. <xo...@us...> - 2004-08-13 06:24:48
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24699/src/bossa/parser Modified Files: Parser.jj Log Message: Added new [] overloads for lists - slicing, relative-to-end indexing, filters, etc. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.257 retrieving revision 1.258 diff -C2 -d -r1.257 -r1.258 *** Parser.jj 12 Aug 2004 23:21:42 -0000 1.257 --- Parser.jj 13 Aug 2004 06:24:39 -0000 1.258 *************** *** 1366,1370 **** { Expression exp; } "=" ! ( ".." "." { return null; } // toplevel function in interface file | exp=Expression() ";" { code = bossa.syntax.dispatch.createReturnStmt(exp, /* fake */ true); } --- 1366,1370 ---- { Expression exp; } "=" ! ( "..." { return null; } // toplevel function in interface file | exp=Expression() ";" { code = bossa.syntax.dispatch.createReturnStmt(exp, /* fake */ true); } *************** *** 2106,2119 **** Expression RangeExpression() : ! { Expression e1,e2; Token t; } { ! e1=ShiftExpression() ! ( t=".." e2=ShiftExpression() ! { e1=bossa.syntax.dispatch.createCallExp(symb(t),e1,e2); } ! )* { return e1; } } - Expression ShiftExpression() : { Expression e1,e2; Token t,t1=null; boolean left=false; } --- 2106,2130 ---- Expression RangeExpression() : ! { 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 = NullExp.create(makeLocation(t)); ! e1=bossa.syntax.dispatch.createCallExp(symb(t),e1,e2); ! } ! } ! { return e1; } } Expression ShiftExpression() : { Expression e1,e2; Token t,t1=null; boolean left=false; } *************** *** 2245,2248 **** --- 2256,2260 ---- } + Expression PrimarySuffix(Expression start) : { *************** *** 2304,2311 **** --- 2316,2334 ---- )* | res=multiLineStringExp() + | res=atExpression() ) { return res; } } + Expression atExpression() : + { + Token t; + } + { + (t = <AT>) + { return bossa.syntax.dispatch.createCallExp(symb(t), Arguments.noArguments()); } + } + + ConstantExp patternLiteral() : //restricted literal for use in dispatch patterns |
From: Daniel B. <bo...@us...> - 2004-08-12 23:43:31
|
Update of /cvsroot/nice/Nice In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1474 Modified Files: NEWS Log Message: Spell-checked past items. Index: NEWS =================================================================== RCS file: /cvsroot/nice/Nice/NEWS,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** NEWS 12 Aug 2004 23:21:43 -0000 1.42 --- NEWS 12 Aug 2004 23:43:21 -0000 1.43 *************** *** 3,18 **** --- 3,24 ---- * Assertions about the type of variables are used by the typechecker, so that casts are not necessary. For instance: + Object o = ...; // We happen to know by design than the object must be a string assert o instanceof String; // Here o can be used as a string without cast + * java.lang.Class is now parameterized by the type it represents. In particular, newInstance is now declared in nice.lang with + <T> T newInstance(Class<T>); + This make it possible to write type-safe code that uses reflexion, in particular when using class literals. * Subclasses can have less type parameters than their parent by fixing the value of the others. For instance: + class BitField implements List<boolean> { ... } + * Improved speed of coverage tests for some methods. * Removed the '--strict' compiler option. *************** *** 47,51 **** nice (0.9.7) ! * Methods can be overriden using the override keyword: class A { A doSomething() { ... } --- 53,57 ---- nice (0.9.7) ! * Methods can be overridden using the override keyword: class A { A doSomething() { ... } *************** *** 56,60 **** An important aspect is that the return type can be more precise than the original type (covariance). ! Overriding without the override keyword (a la Java) is accepted but generates a warning. * When importing a java package, it is possible to specify that its methods --- 62,66 ---- An important aspect is that the return type can be more precise than the original type (covariance). ! Overriding without the override keyword (a la Java) is accepted but generates a warning. * When importing a java package, it is possible to specify that its methods *************** *** 64,68 **** * The 'Any' keyword is now deprecated. * Global constants and global variables are now initialized in a proper order ! when one depends on another, both directly and through the default implementation of a method. * The Eclipse plugin now works with Eclipse 3.0 M7 (although 2.1 is still the --- 70,74 ---- * The 'Any' keyword is now deprecated. * Global constants and global variables are now initialized in a proper order ! when one depends on another, both directly and through the default implementation of a method. * The Eclipse plugin now works with Eclipse 3.0 M7 (although 2.1 is still the *************** *** 76,91 **** class Point { double x; double y; } ! new Point(double angle, double distance) ! { this(x: distance * cos(angle), y: distance * sin(angle)); } ! It is then possible to create a Point with either new Point(x: ..., y: ...) or new Point(angle: ..., distance: ...). ! * Additional fields can be defined for enums and enums can implement interfaces, for instance: enum Coin(int value) implements Currency {penny(1), nickel(5), dime(10), quarter(25)} * Alternative syntax for calling methods that takes an anonymous function ! with no arguments. For example 'loop(5) { doSomeThing(); }' is a shorthand for 'loop(5, () => { doSomeThing(); });' * "using" statement, as in C#, defined in nice.lang using (!) the above --- 82,97 ---- class Point { double x; double y; } ! new Point(double angle, double distance) ! { this(x: distance * cos(angle), y: distance * sin(angle)); } ! It is then possible to create a Point with either new Point(x: ..., y: ...) or new Point(angle: ..., distance: ...). ! * Additional fields can be defined for enums and enums can implement interfaces, for instance: enum Coin(int value) implements Currency {penny(1), nickel(5), dime(10), quarter(25)} * Alternative syntax for calling methods that takes an anonymous function ! with no arguments. For example 'loop(5) { doSomeThing(); }' is a shorthand for 'loop(5, () => { doSomeThing(); });' * "using" statement, as in C#, defined in nice.lang using (!) the above *************** *** 99,110 **** * Stricter parsing of expressions used as statements. * Improved performance for arrays used as lists. ! * New methods (in package nice.functional) for working with iterators and generators. * Applications that stop because of an uncaught exception will now print a stack trace the include correct Nice source files and line numbers. Applications that need to print a stack trace can do so by using ! printStackTraceWithSourceInfo(e) (defined in nice.lang) instead of e.printStackTrace(), and similarly for versions that specify a stream ! or writer to print into. * A super call can have types to resolve ambiguities. Example of usage: foo(BarSub b, s) = super(Bar, String); --- 105,116 ---- * Stricter parsing of expressions used as statements. * Improved performance for arrays used as lists. ! * New methods (in package nice.functional) for working with iterators and generators. * Applications that stop because of an uncaught exception will now print a stack trace the include correct Nice source files and line numbers. Applications that need to print a stack trace can do so by using ! printStackTraceWithSourceInfo(e) (defined in nice.lang) instead of e.printStackTrace(), and similarly for versions that specify a stream ! or writer to print into. * A super call can have types to resolve ambiguities. Example of usage: foo(BarSub b, s) = super(Bar, String); *************** *** 112,116 **** registration of the emacs mode for the SuSE Linux distribution. * Bug fixes (checking of local variables in a call position, make it possible ! to use new Object() and dispatch on Object again, code generation of integer constants, overloading of function symbols, printing of string literals with escaped chars, implicit 'this' for functional fields, ... ) --- 118,122 ---- registration of the emacs mode for the SuSE Linux distribution. * Bug fixes (checking of local variables in a call position, make it possible ! to use new Object() and dispatch on Object again, code generation of integer constants, overloading of function symbols, printing of string literals with escaped chars, implicit 'this' for functional fields, ... ) *************** *** 128,132 **** } This syntax should be more consistent and familiar, and is now ! prefered to the old one, which will eventually be deprecated. * Object is now recognized as a super-type of every type. This allows easier use of Java libraries, creation of heterogeneous collections, --- 134,138 ---- } This syntax should be more consistent and familiar, and is now ! preferred to the old one, which will eventually be deprecated. * Object is now recognized as a super-type of every type. This allows easier use of Java libraries, creation of heterogeneous collections, *************** *** 149,154 **** * Unused local variables will give a warning. * Nested multi-line comments are allowed. ! * Empty statements (made of a single ';') have been removed. This avoids the ! risk of an accidental ';' changing the meaning of a statement. Empty statements are very rarely needed, and can easily be replaced by '{}'. * The Emacs mode is updated to work with recent versions of GNU and XEmacs. --- 155,160 ---- * Unused local variables will give a warning. * Nested multi-line comments are allowed. ! * Empty statements (made of a single ';') have been removed. This avoids the ! risk of an accidental ';' changing the meaning of a statement. Empty statements are very rarely needed, and can easily be replaced by '{}'. * The Emacs mode is updated to work with recent versions of GNU and XEmacs. *************** *** 158,164 **** only if they are actually used. This reduces memory usage and improves compilation speed. ! * Bug fixes (accessing static fields of an superclass or interface, ! compilation of polymorphic tuples, captured 'this' in initializer, ! duplication of constructors in bytecode, disappearing contracts during recompilation, ... ) --- 164,170 ---- only if they are actually used. This reduces memory usage and improves compilation speed. ! * Bug fixes (accessing static fields of an superclass or interface, ! compilation of polymorphic tuples, captured 'this' in initializer, ! duplication of constructors in bytecode, disappearing contracts during recompilation, ... ) *************** *** 167,176 **** nice (0.9.4) ! * The compiler now knows that the statement 'assert false' never terminates. ! Therefore that statement can be used in a branch that is known to be unused, without needing to return a dummy value when the method does not return void. * Added source-level debugging information for recent debuggers (jsr 45). ! * Constraints on class type parameters can be written as a prefix of class declarations: <Bound T> class MyClass<T> { ... } --- 173,182 ---- nice (0.9.4) ! * The compiler now knows that the statement 'assert false' never terminates. ! Therefore that statement can be used in a branch that is known to be unused, without needing to return a dummy value when the method does not return void. * Added source-level debugging information for recent debuggers (jsr 45). ! * Constraints on class type parameters can be written as a prefix of class declarations: <Bound T> class MyClass<T> { ... } *************** *** 193,197 **** * Existing interfaces can (like classes) implement abstract interfaces: interface packagename.SomeInterface implements AbstractInterface; ! * Bugfixes (various pretty printing issues, type hole in instanceof inference, calls to abstract methods, chained assignments with arrays like 'x = arr[y] = z;', error messages of integer dispatch, reachability of --- 199,203 ---- * Existing interfaces can (like classes) implement abstract interfaces: interface packagename.SomeInterface implements AbstractInterface; ! * Bugfixes (various pretty printing issues, type hole in instanceof inference, calls to abstract methods, chained assignments with arrays like 'x = arr[y] = z;', error messages of integer dispatch, reachability of *************** *** 205,209 **** flexible. The syntax that used to define a function is still valid: it now ! declares a method together with a default implementation. Exemple: class A { // Declares a method f, with a default implementation that returns 1. --- 211,215 ---- flexible. The syntax that used to define a function is still valid: it now ! declares a method together with a default implementation. Example: class A { // Declares a method f, with a default implementation that returns 1. *************** *** 217,230 **** } The same applies for methods outside classes. ! * More dynamic type inference implemented. The type of a local variable is ! made more precise after a succesful instanceof: A a = ...; if (a instanceof B) // Here a has type B ! * Classes that implement java.lang.Cloneable now automatically support the clone method. * The deprecated 'main(args) { ... }' syntax for the main function is not supported anymore. Please use instead: 'void main(String[] args) { ... }' ! * Floating point literals are now of type double by default, adding 'f' or 'F' at the end will make them of type float. * Method parameters that are not dispatched on simply get their declared --- 223,236 ---- } The same applies for methods outside classes. ! * More dynamic type inference implemented. The type of a local variable is ! made more precise after a successful instanceof: A a = ...; if (a instanceof B) // Here a has type B ! * Classes that implement java.lang.Cloneable now automatically support the clone method. * The deprecated 'main(args) { ... }' syntax for the main function is not supported anymore. Please use instead: 'void main(String[] args) { ... }' ! * Floating point literals are now of type double by default, adding 'f' or 'F' at the end will make them of type float. * Method parameters that are not dispatched on simply get their declared *************** *** 235,239 **** for (i : 1..10) println(i); * In local variable declarations like 'var x = exp', the inferred type ! for x is int when 'exp' is of type byte or short. This will avoid unexpected behaviour in some cases. * Bugfixes (incrementation of byte local variables, require a default value --- 241,245 ---- for (i : 1..10) println(i); * In local variable declarations like 'var x = exp', the inferred type ! for x is int when 'exp' is of type byte or short. This will avoid unexpected behaviour in some cases. * Bugfixes (incrementation of byte local variables, require a default value *************** *** 244,251 **** nice (0.9.1) ! * Final fields can be overriden in sub-classes with a more precise type ! and a different default value. In particular, this removes the need for a cast when reading the field's value from an instance of the sub-class. ! class A { final List<String> names; --- 250,257 ---- nice (0.9.1) ! * Final fields can be overridden in sub-classes with a more precise type ! and a different default value. In particular, this removes the need for a cast when reading the field's value from an instance of the sub-class. ! class A { final List<String> names; *************** *** 258,265 **** * A class can now have initializers, which are executed each time an instance is created. ! class A { // Initializer ! { // Initialization code goes here. } --- 264,271 ---- * A class can now have initializers, which are executed each time an instance is created. ! class A { // Initializer ! { // Initialization code goes here. } *************** *** 272,276 **** for (elem : array) println(elem); * The compiler now warns about non-existing sourcepath entries. ! * Bugfixes (parameter's default value refering to previous parameters, ...) -- Sat, 9 Aug 2003 23:19:41 +0200 --- 278,282 ---- for (elem : array) println(elem); * The compiler now warns about non-existing sourcepath entries. ! * Bugfixes (parameter's default value referring to previous parameters, ...) -- Sat, 9 Aug 2003 23:19:41 +0200 *************** *** 319,334 **** foo(number) { ... } //correct //foo(num) { ... } //not valid ! This is important, so that a typo in a global constant or enum name in a method implementation does not lead to a default implementation. * Added operator ** to calculate powers of longs, doubles and BigIntegers. ! * The 'char' type is no longer a subtype of int. The integer unicode representation of a character c can be obtained by int(c). * Interfaces can now implement (finally or not) abstract interfaces. * 'true' and 'false' are now keywords, and better code is generated for them. ! The termination properties of loops with literal boolean values are now recognized, as in Java. * Redefining of local variables in their scope is not allowed anymore. * Method bodies with a single statement can be written without brackets. ! example: void foo() = throw new Exception(); * It is possible to bind the values of tuple arguments to functions: String foo((String s, String t)) = s + t; --- 325,340 ---- foo(number) { ... } //correct //foo(num) { ... } //not valid ! This is important, so that a typo in a global constant or enum name in a method implementation does not lead to a default implementation. * Added operator ** to calculate powers of longs, doubles and BigIntegers. ! * The 'char' type is no longer a subtype of int. The integer unicode representation of a character c can be obtained by int(c). * Interfaces can now implement (finally or not) abstract interfaces. * 'true' and 'false' are now keywords, and better code is generated for them. ! The termination properties of loops with literal boolean values are now recognized, as in Java. * Redefining of local variables in their scope is not allowed anymore. * Method bodies with a single statement can be written without brackets. ! example: void foo() = throw new Exception(); * It is possible to bind the values of tuple arguments to functions: String foo((String s, String t)) = s + t; *************** *** 348,352 **** overloading resolution of method implementations with additional tc's, ...) * Improved some error messages. ! -- Fri, 18 Jul 2003 01:40:25 +0200 --- 354,358 ---- overloading resolution of method implementations with additional tc's, ...) * Improved some error messages. ! -- Fri, 18 Jul 2003 01:40:25 +0200 *************** *** 356,360 **** * Added operators to compute with java.math.BigInteger (+,-,*,/,%,...). * In functional types, '()' is always equivalent to 'void'. Ex: int->() ! * Anonymous functions that never return normally can be used with any return type. * Bugfixes (some cases of optional parameters, allowing arbitrarily nested --- 362,366 ---- * Added operators to compute with java.math.BigInteger (+,-,*,/,%,...). * In functional types, '()' is always equivalent to 'void'. Ex: int->() ! * Anonymous functions that never return normally can be used with any return type. * Bugfixes (some cases of optional parameters, allowing arbitrarily nested *************** *** 363,367 **** is declared inside a class, declaration of multiple local variables, nested type parameters in method declarations, improved some error messages, ! resolving overloading between fields and global variables, implemented nullness inference for local constants). --- 369,373 ---- is declared inside a class, declaration of multiple local variables, nested type parameters in method declarations, improved some error messages, ! resolving overloading between fields and global variables, implemented nullness inference for local constants). *************** *** 391,395 **** // Now we use the fact the res is a list. // Therefore, it would be impossible to declare its type as C<U>. ! res.add(res[0]); // By returning res, we need the fact that it is a subtype of C<U>, --- 397,401 ---- // Now we use the fact the res is a list. // Therefore, it would be impossible to declare its type as C<U>. ! res.add(res[0]); // By returning res, we need the fact that it is a subtype of C<U>, *************** *** 397,407 **** return res; } ! * Changed the syntax for local variables. The "final" keyword is deprecated ! now for local variables, use "let" instead. In addition to the standard "type name = ..." syntax two new forms are allowed: ! let [ type ] name [ = expression ] ; var [ type ] name [ = expression ] ; At least a type or a default value are required. ! The type can only be left away when the compiler is able to interfere the type which is not always possible. A non function example to show some aspects the new syntax: --- 403,413 ---- return res; } ! * Changed the syntax for local variables. The "final" keyword is deprecated ! now for local variables, use "let" instead. In addition to the standard "type name = ..." syntax two new forms are allowed: ! let [ type ] name [ = expression ] ; var [ type ] name [ = expression ] ; At least a type or a default value are required. ! The type can only be left away when the compiler is able to interfere the type which is not always possible. A non function example to show some aspects the new syntax: *************** *** 431,436 **** nice (0.7.8) ! * Some error messages are more usefull. ! * All operators are inlined and some operators (&&, ||, ! and comparisons) and if-statements generate better bytecode now. * Improved bytecode generation of pre/post-condition. --- 437,442 ---- nice (0.7.8) ! * Some error messages are more useful. ! * All operators are inlined and some operators (&&, ||, ! and comparisons) and if-statements generate better bytecode now. * Improved bytecode generation of pre/post-condition. *************** *** 450,454 **** * Allow nested tuples on the left side of a tuple assignment: (String a, (String b, String c)) = ("a", ("b", "c")); ! * Bugfixes (solved problems with case insentive filenames, ...). -- Tue, 8 Apr 2003 21:03:43 +0200 --- 456,460 ---- * Allow nested tuples on the left side of a tuple assignment: (String a, (String b, String c)) = ("a", ("b", "c")); ! * Bugfixes (solved problems with case-insensitive filenames, ...). -- Tue, 8 Apr 2003 21:03:43 +0200 *************** *** 474,485 **** * The 'fun' keyword for anonymous functions is deprecated. It can be omitted. * New policy for typing calls to Java methods. By default, the typing ! is more convenient, considering arguments as possibly null, and results as non-null. The '--strict' compiler option enforces a stricter heuristic. ! Additionally, arrays are always considered to have non-null component types. Final fields are considered non-null. * Static native methods are not (wrongly) imported in the global name space ! anymore. One can just use them as in Java, by prefixing with the class name: String s = Integer.toHexString(100); --- 480,491 ---- * The 'fun' keyword for anonymous functions is deprecated. It can be omitted. * New policy for typing calls to Java methods. By default, the typing ! is more convenient, considering arguments as possibly null, and results as non-null. The '--strict' compiler option enforces a stricter heuristic. ! Additionally, arrays are always considered to have non-null component types. Final fields are considered non-null. * Static native methods are not (wrongly) imported in the global name space ! anymore. One can just use them as in Java, by prefixing with the class name: String s = Integer.toHexString(100); *************** *** 490,494 **** * Added the 'concat' function on arrays, and sort function for lists. * Faster compilation for large projects with many classes. ! * Bugfixes (anonymous functions inside functionals with constracts, typechecking loop tests, other fixes to reduce the difference between what the parser accepts and the compiler can handle, ...). --- 496,500 ---- * Added the 'concat' function on arrays, and sort function for lists. * Faster compilation for large projects with many classes. ! * Bugfixes (anonymous functions inside functionals with contracts, typechecking loop tests, other fixes to reduce the difference between what the parser accepts and the compiler can handle, ...). *************** *** 498,502 **** nice (0.7.6) ! * Implemented optional parameters' default value refering to previous parameters, like 'to' in the following example: <T> T[] slice(T[] array, int from = 0, int to = array.length - 1); --- 504,508 ---- nice (0.7.6) ! * Implemented optional parameters' default value referring to previous parameters, like 'to' in the following example: <T> T[] slice(T[] array, int from = 0, int to = array.length - 1); *************** *** 504,508 **** if (0 < i < N) ... * Fixed several issues with generic collections. ! In particular, for List<int> there was an ambiguity between remove(int) and remove(T) (since T=int). Therefore we renamed remove(int) into removeAt(int). --- 510,514 ---- if (0 < i < N) ... * Fixed several issues with generic collections. ! In particular, for List<int> there was an ambiguity between remove(int) and remove(T) (since T=int). Therefore we renamed remove(int) into removeAt(int). *************** *** 516,526 **** declared externally to a class. * Parser support for public-read and private-write fields (experimental). ! * Performance improvement for anonymous functions and for polymorphic usage of arrays. * Improved references to source lines in the bytecode (stack traces). ! * Bugfixes (using anonymous functions while overriding native methods, ! automatic array conversions in polymorphic code, nested literal primitive ! arrays, mutually dependant packages, ...). ! * For convenience of command-line tools (shells) with automatic completion, we allow a directory name instead of the corresponding package name. That is, we replace '/' (which is illegal in package names) by '.'. --- 522,532 ---- declared externally to a class. * Parser support for public-read and private-write fields (experimental). ! * Performance improvement for anonymous functions and for polymorphic usage of arrays. * Improved references to source lines in the bytecode (stack traces). ! * Bugfixes (using anonymous functions while overriding native methods, ! automatic array conversions in polymorphic code, nested literal primitive ! arrays, mutually dependent packages, ...). ! * For convenience of command-line tools (shells) with automatic completion, we allow a directory name instead of the corresponding package name. That is, we replace '/' (which is illegal in package names) by '.'. *************** *** 537,541 **** * Addition of the || operator on optional values: e1 || e2 ! evalues e1 and returns its value if it is not null (without evaluating e2). If e1 evaluates to null it returns the value of e2. It is equivalent to e1 != null ? e1 : e2, except e1 is not evaluated twice. --- 543,547 ---- * Addition of the || operator on optional values: e1 || e2 ! evaluates e1 and returns its value without evaluating e2 if e1 is not null. If e1 evaluates to null it returns the value of e2. It is equivalent to e1 != null ? e1 : e2, except e1 is not evaluated twice. *************** *** 546,550 **** * Short anonymous functions made of one assignment now return void. Allows: [1,2,3].foreach(int j => i += j); ! instead of [1,2,3].foreach(int j => { i += j; }); * Arrays created with 0 elements have a non-option component type: --- 552,556 ---- * Short anonymous functions made of one assignment now return void. Allows: [1,2,3].foreach(int j => i += j); ! instead of [1,2,3].foreach(int j => { i += j; }); * Arrays created with 0 elements have a non-option component type: *************** *** 553,557 **** They can still be used with option component type: ?String[] s0 = new String[0]; ! * Changed suffix notation for multiple-dimension array types, to match initialization. Dimensions are listed in order, instead of reverse order. For instance, --- 559,563 ---- They can still be used with option component type: ?String[] s0 = new String[0]; ! * Changed suffix notation for multiple-dimension array types, to match initialization. Dimensions are listed in order, instead of reverse order. For instance, *************** *** 572,576 **** nice (0.7.4) ! * Added support for Generic Java types. This allows in particular to use java.util.* collections with parameterized types (e.g. List<String>). These replace the previous (very partial) collections from nice.lang. --- 578,582 ---- nice (0.7.4) ! * Added support for Generic Java types. This allows in particular to use java.util.* collections with parameterized types (e.g. List<String>). These replace the previous (very partial) collections from nice.lang. *************** *** 584,588 **** class, and when a class or interface (indirectly) implements itself. * Allow the <T> syntax to introduce type variables, in addition to ! <Any T> (that is, any is optional). This is consistent with GJ, and the syntax for class type parameters. * Improved overloading resolution when used on functions with optional --- 590,594 ---- class, and when a class or interface (indirectly) implements itself. * Allow the <T> syntax to introduce type variables, in addition to ! <Any T> (that is, any is optional). This is consistent with GJ, and the syntax for class type parameters. * Improved overloading resolution when used on functions with optional *************** *** 652,658 **** * Added the ".class" construct. * Completed the "instanceof" construct. ! * Calling new T[size] where T is a type variable now correctly returns an array with optional element type. It can be filled with non-null values ! using the 'fill' function, e.g. fill(new T[size], int i => f(x[i])) --- 658,664 ---- * Added the ".class" construct. * Completed the "instanceof" construct. ! * Calling new T[size] where T is a type variable now correctly returns an array with optional element type. It can be filled with non-null values ! using the 'fill' function, e.g. fill(new T[size], int i => f(x[i])) *************** *** 665,670 **** * The compiler is now reentrant. This should not make any difference when running from the command-line, but this is important to allow ! tools written in Java or Nice (like the Ant task, the testsuite, ! an IDE) to call the compiler repetively, without starting a new JVM. * Fixed several bugs (export of optional functional types, ...). --- 671,676 ---- * The compiler is now reentrant. This should not make any difference when running from the command-line, but this is important to allow ! tools written in Java or Nice (like the Ant task, the testsuite, ! an IDE) to call the compiler repetitively, without starting a new JVM. * Fixed several bugs (export of optional functional types, ...). *************** *** 676,688 **** int i => i+1 /* function of one argument */ (int i, int j) => i+j /* function of several arguments */ ! * Renamed `iter` to `foreach`. `iter` is still accepted, but will probably be removed sometime in the future. Together with the syntax change for anonymous functions, this gives a nice and user-friendly syntax for iterations: ! names.foreach(String name => println(name)); ! * Anonymous function cannot appear where a statement is expected ! (some expressions can). This is good since an anonymous function which is not called cannot have side-effects, and therefore this case was meaningless and probably buggy. --- 682,694 ---- int i => i+1 /* function of one argument */ (int i, int j) => i+j /* function of several arguments */ ! * Renamed `iter` to `foreach`. `iter` is still accepted, but will probably be removed sometime in the future. Together with the syntax change for anonymous functions, this gives a nice and user-friendly syntax for iterations: ! names.foreach(String name => println(name)); ! * Anonymous function cannot appear where a statement is expected ! (some expressions can). This is good since an anonymous function which is not called cannot have side-effects, and therefore this case was meaningless and probably buggy. *************** *** 694,705 **** nice (0.5.3) ! * Testing a variable against null in a while or for loop condition now allows to use it as non-null, until is it assigned a possibly null value. ! * Added many mathematical functions (sin, cos, round, max, min, ...). This makes it unnecessary to prefix them with (java.lang.)Math. ! * It is now possible to use "." (current directory) in ! the --classpath argument (this needed a workaround for a probable bug in Sun's URLClassLoader, at least in 1.3). ! * Other bugfixes (creating arrays of "exotic" types, using arrays in field initializers). --- 700,711 ---- nice (0.5.3) ! * Testing a variable against null in a while or for loop condition now allows to use it as non-null, until is it assigned a possibly null value. ! * Added many mathematical functions (sin, cos, round, max, min, ...). This makes it unnecessary to prefix them with (java.lang.)Math. ! * It is now possible to use "." (current directory) in ! the --classpath argument (this needed a workaround for a probable bug in Sun's URLClassLoader, at least in 1.3). ! * Other bugfixes (creating arrays of "exotic" types, using arrays in field initializers). *************** *** 723,729 **** * Constructors now take the initial values of the object's fields as named arguments. A field declaration (inside a class declaration) ! now accepts an optional value after "=" (like in Java). This value ! is used as the default if the field is not mentioned in a call to ! the constructor. A field with no default value must be mentioned in every call to the constructor. * Compile properly functions declared inside abstract interfaces. --- 729,735 ---- * Constructors now take the initial values of the object's fields as named arguments. A field declaration (inside a class declaration) ! now accepts an optional value after "=" (like in Java). This value ! is used as the default if the field is not mentioned in a call to ! the constructor. A field with no default value must be mentioned in every call to the constructor. * Compile properly functions declared inside abstract interfaces. *************** *** 740,750 **** * Assigning a possibly null value to a variable of non-null type now produces an error instead of a warning. ! * Fixes bug that considered that int a = 10, b; initializes both a and b to 10. * Fixed variable initialization analysis for do-while loops. * Make the compiler compatible with JDK 1.4 ! * Fixed bug on MS-Windows with archive creation because of the ! case-insensivity of the file system. * Fixed creation of archive from up-to-date packages stored in jar. * Accept anonymous functions that do nothing. --- 746,756 ---- * Assigning a possibly null value to a variable of non-null type now produces an error instead of a warning. ! * Fixes bug that considered that int a = 10, b; initializes both a and b to 10. * Fixed variable initialization analysis for do-while loops. * Make the compiler compatible with JDK 1.4 ! * Fixed bug on MS-Windows with archive creation because of the ! case-insensitivity of the file system. * Fixed creation of archive from up-to-date packages stored in jar. * Accept anonymous functions that do nothing. *************** *** 770,774 **** * Arrays of void values are forbidden. They most probably originate from a bug in the source program. ! * Better handling of inhomogenous tuples with native types (e.g. <int, long>) * Better wrapping/unwrapping code for arrays used as Collections. * Bugfixes for some polymorphic operations on arrays. --- 776,781 ---- * Arrays of void values are forbidden. They most probably originate from a bug in the source program. ! * Better handling of inhomogeneous tuples with native types ! (e.g. <int, long>). * Better wrapping/unwrapping code for arrays used as Collections. * Bugfixes for some polymorphic operations on arrays. *************** *** 779,786 **** nice (0.0.020226) ! * Fixed bug that prevented using "this" in overriden native methods. * Better error messages for method calls with wrong number of arguments. * Accept methods with no implementation when their domain is empty. ! * Abstract interfaces are fully qualified just like classes and correctly list their super-interfaces in the package interface. This really makes it possible to use them across packages. --- 786,793 ---- nice (0.0.020226) ! * Fixed bug that prevented using "this" in overridden native methods. * Better error messages for method calls with wrong number of arguments. * Accept methods with no implementation when their domain is empty. ! * Abstract interfaces are fully qualified just like classes and correctly list their super-interfaces in the package interface. This really makes it possible to use them across packages. *************** *** 797,803 **** * Added 'break' and 'continue' statements. * Implemented 'do' loops. ! * Allow overriding of native java methods. It is now possible to define a subclass of a java class or interface and override the methods. ! * Changed compilation scheme for method alternatives. This results in shorter class files and more intuitive stack traces. --- 804,810 ---- * Added 'break' and 'continue' statements. * Implemented 'do' loops. ! * Allow overriding of native java methods. It is now possible to define a subclass of a java class or interface and override the methods. ! * Changed compilation scheme for method alternatives. This results in shorter class files and more intuitive stack traces. *************** *** 817,822 **** * Added the 'instanceof' and '~' (bitwise complement) keywords. * Do not stop at the first syntax or type error in more situations. ! * Ehanced error messages. ! * Emacs mode: allow to interactively set the compiler's location (the string variable 'nice-program'). --- 824,829 ---- * Added the 'instanceof' and '~' (bitwise complement) keywords. * Do not stop at the first syntax or type error in more situations. ! * Enhanced error messages. ! * Emacs mode: allow to interactively set the compiler's location (the string variable 'nice-program'). |
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29266/src/bossa/syntax Modified Files: TypeIdent.java MonotypeConstructor.java MethodContainer.java EnumDefinition.java ClassDefinition.java AbstractInterface.java Log Message: Allow subclasses to have less type parameters than their parent, by instantiation of some of their type parameters. Index: TypeIdent.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/TypeIdent.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** TypeIdent.java 30 Jul 2004 19:08:45 -0000 1.29 --- TypeIdent.java 12 Aug 2004 23:21:41 -0000 1.30 *************** *** 91,94 **** --- 91,99 ---- } catch(mlsub.typing.BadSizeEx e){ + // See if this is a class with default type parameters + mlsub.typing.Monotype type = ClassDefinition.toType(tc); + if (type != null) + return type; + throw User.error(this, name + Util.has(e.expected, "type parameter", e.actual)); Index: ClassDefinition.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/ClassDefinition.java,v retrieving revision 1.107 retrieving revision 1.108 diff -C2 -d -r1.107 -r1.108 *** ClassDefinition.java 30 Jul 2004 19:08:45 -0000 1.107 --- ClassDefinition.java 12 Aug 2004 23:21:41 -0000 1.108 *************** *** 15,18 **** --- 15,19 ---- import bossa.util.*; import mlsub.typing.*; + import mlsub.typing.Monotype; import gnu.bytecode.*; *************** *** 49,52 **** --- 50,65 ---- this.extensions = extensions; + // Find out the real variance of the interface + int arity = getVariance(extensions); + if (arity == -1) + arity = getVariance(implementations); + if (arity == -1) + arity = getVariance(abstractions); + + if (arity == -1 || arity <= typeParametersVariances.size()) + this.variance = makeVariance(typeParametersVariances); + else + this.variance = Variance.make(new int[arity]); + this.createTC(); associatedInterface = new mlsub.typing.Interface(variance, tc); *************** *** 141,150 **** } ! public static ! Class makeClass(LocatedString name, ! boolean isFinal, boolean isAbstract, Constraint typeParameters, List typeParametersVariances, ! TypeIdent superClassIdent, List implementations, List abstractions ) --- 154,163 ---- } ! public static ! Class makeClass(LocatedString name, ! boolean isFinal, boolean isAbstract, Constraint typeParameters, List typeParametersVariances, ! MonotypeConstructor superClassIdent, List implementations, List abstractions ) *************** *** 157,165 **** public static class Class extends ClassDefinition { ! Class(LocatedString name, ! boolean isFinal, boolean isAbstract, Constraint typeParameters, List typeParametersVariances, ! TypeIdent superClassIdent, List implementations, List abstractions ) --- 170,178 ---- public static class Class extends ClassDefinition { ! Class(LocatedString name, ! boolean isFinal, boolean isAbstract, Constraint typeParameters, List typeParametersVariances, ! MonotypeConstructor superClassIdent, List implementations, List abstractions ) *************** *** 170,176 **** this.isFinal = isFinal; this.isAbstract = isAbstract; ! this.superClassIdent = superClassIdent; this.createTC(); if (isFinal) --- 183,201 ---- this.isFinal = isFinal; this.isAbstract = isAbstract; ! this.superClassIdent = superClassIdent; + // Find out the real variance of the interface + int arity = getVariance(superClassIdent); + if (arity == -1) + arity = getVariance(implementations); + if (arity == -1) + arity = getVariance(abstractions); + + if (arity == -1 || arity <= typeParametersVariances.size()) + this.variance = makeVariance(typeParametersVariances); + else + this.variance = Variance.make(new int[arity]); + this.createTC(); if (isFinal) *************** *** 238,244 **** void resolveClass() { if (superClassIdent != null) { ! superClass = superClassIdent.resolveToTC(typeScope); if (superClass.isMinimal()) --- 263,271 ---- void resolveClass() { + Monotype[] params = null; if (superClassIdent != null) { ! params = resolveParent(superClassIdent, getLocalScope()); ! superClass = superClassIdent.tc.resolveToTC(typeScope); if (superClass.isMinimal()) *************** *** 247,251 **** if (TypeConstructors.isInterface(superClass)) User.error(superClassIdent, ! superClass + " is an interface, so " + name + " may only implement it"); --- 274,278 ---- if (TypeConstructors.isInterface(superClass)) User.error(superClassIdent, ! superClass + " is an interface, so " + name + " may only implement it"); *************** *** 258,261 **** --- 285,290 ---- d.resolve(); + useParent(d, params); + if(d.getImplementation() instanceof PrimitiveType && ! (this.getImplementation() instanceof PrimitiveType)) *************** *** 301,305 **** } ! TypeIdent superClassIdent; TypeConstructor superClass; protected boolean isFinal; --- 330,334 ---- } ! MonotypeConstructor superClassIdent; TypeConstructor superClass; protected boolean isFinal; *************** *** 325,333 **** ) { ! super(name, Node.upper, typeParameters, typeParametersVariances); this.implementations = implementations; this.abstractions = abstractions; } ! protected List /* of Interface */ implementations, --- 354,362 ---- ) { ! super(name, Node.upper, typeParameters); this.implementations = implementations; this.abstractions = abstractions; } ! protected List /* of Interface */ implementations, *************** *** 426,435 **** private static Map tcToClassDef; public static void reset() { tcToClassDef = new HashMap(); } ! public static final ClassDefinition get(TypeConstructor tc) { return (ClassDefinition) tcToClassDef.get(tc); } ! /**************************************************************** * Selectors --- 455,469 ---- private static Map tcToClassDef; public static void reset() { tcToClassDef = new HashMap(); } ! public static final ClassDefinition get(TypeConstructor tc) { return (ClassDefinition) tcToClassDef.get(tc); } ! ! public static final ClassDefinition get(mlsub.typing.Interface itf) ! { ! return ClassDefinition.get(itf.associatedTC()); ! } ! /**************************************************************** * Selectors *************** *** 495,502 **** status = RESOLVING; ! try { - super.resolve(); resolveClass(); } finally --- 529,541 ---- status = RESOLVING; ! try { resolveClass(); + + super.resolve(); + + // This needs to be after super.resolve(), so that the constraint is + // resolved + implementation.resolveClass(); } finally *************** *** 509,514 **** { this.resolveInterfaces(implementations); ! abs = TypeIdent.resolveToItf(typeScope, abstractions); ! implementations = abstractions = null; --- 548,553 ---- { this.resolveInterfaces(implementations); ! abs = AbstractInterface.resolve(typeScope, abstractions); ! implementations = abstractions = null; *************** *** 523,527 **** createContext(); - implementation.resolveClass(); } --- 562,565 ---- *************** *** 538,546 **** for (Iterator i = names.iterator(); i.hasNext();) { ! TypeIdent name = (TypeIdent) i.next(); TypeSymbol s = name.resolvePreferablyToItf(typeScope); ! if (s instanceof mlsub.typing.Interface) ! interfaces.add(s); else { --- 576,593 ---- for (Iterator i = names.iterator(); i.hasNext();) { ! MonotypeConstructor parent = (MonotypeConstructor) i.next(); ! Monotype[] params = resolveParent(parent, getLocalScope()); ! ! TypeIdent name = parent.tc; TypeSymbol s = name.resolvePreferablyToItf(typeScope); ! if (s instanceof mlsub.typing.Interface) ! { ! interfaces.add(s); ! ! ClassDefinition def = ClassDefinition.get((mlsub.typing.Interface) s); ! if (def != null) ! useParent(def, params); ! } else { *************** *** 561,564 **** --- 608,619 ---- } + Monotype[] resolveParent(MonotypeConstructor parent, TypeScope typeScope) + { + if (parent.parameters == null) + return null; + + return bossa.syntax.Monotype.resolve(typeScope, parent.parameters.content); + } + void resolveBody() { *************** *** 637,640 **** --- 692,844 ---- } + /** + Returns a monotype based on this tc, provided that the class + requires no type parameter because it specializes its parent. + */ + static Monotype toType(TypeConstructor tc) + { + ClassDefinition def = ClassDefinition.get(tc); + if (def == null) + return null; + + if (def.parentParams == null) + return null; + + // Look for missing type parameters + int missing = 0; + for (int i = 0; i < def.parentParams.length; i++) + if (def.parentParams[i] == null) + missing++; + + if (missing == 0) + return new mlsub.typing.MonotypeConstructor(tc, def.parentParams); + + return null; + } + + /** + Returns a monotype based on this tc, provided that the class + requires exactly these type parameters because it specializes its parent. + */ + static Monotype toType(TypeConstructor tc, Monotype[] sourceParams) + { + ClassDefinition def = ClassDefinition.get(tc); + if (def == null) + return null; + + if (def.parentParams == null) + return null; + + Monotype[] fullParams = new Monotype[def.parentParams.length]; + + int used = 0; + for (int i = 0; i < fullParams.length; i++) + if (def.parentParams[i] == null) + { + fullParams[i] = sourceParams[def.parentTypeParameterMap[i]]; + used++; + } + else + fullParams[i] = def.parentParams[i]; + + if (used < sourceParams.length) + return null; + + return new mlsub.typing.MonotypeConstructor(tc, fullParams); + } + + private Monotype[] parentParams; + private int[] parentTypeParameterMap; + + MethodContainer.Constraint specialize(MethodContainer.Constraint our, + MethodContainer.Constraint parent, + Monotype[] params) + { + if (parent == null) + return null; + + if (params == null) + return our; + + this.parentParams = params; + this.parentTypeParameterMap = new int[params.length]; + + List binders = new ArrayList(); + List atoms = new ArrayList(); + Monotype[] typeParameters = new Monotype[params.length]; + + if (our != null) + { + binders.addAll(Arrays.asList(our.getBinderArray())); + atoms.addAll(our.getAtoms()); + } + + for (int i = 0; i < params.length; i++) + { + if (params[i] instanceof MonotypeVar) + { + typeParameters[i] = params[i]; + parentTypeParameterMap[i] = find(params[i], our.typeParameters); + parentParams[i] = null; + continue; + } + + MonotypeVar mvar = new MonotypeVar("D" + i); + binders.add(mvar); + typeParameters[i] = mvar; + + bossa.syntax.Monotype var = bossa.syntax.Monotype.create(mvar); + atoms.add(new MonotypeLeqCst(bossa.syntax.Monotype.create(params[i]), var)); + atoms.add(new MonotypeLeqCst(var, bossa.syntax.Monotype.create(params[i]))); + } + + return new MethodContainer.Constraint + ((TypeSymbol[]) binders.toArray(new TypeSymbol[binders.size()]), + atoms, + typeParameters, + this.location()); + } + + private int find(Object o, Object[] array) + { + for (int i = 0; ; i++) + if (array[i] == o) + return i; + } + + int getVariance(List parents) + { + if (parents == null) + return -1; + + int res; + + for (Iterator i = parents.iterator(); i.hasNext();) + { + res = getVariance((MonotypeConstructor) i.next()); + if (res != -1) + return res; + } + + return -1; + } + + int getVariance(MonotypeConstructor parent) + { + if (parent == null || parent.parameters.content == null) + return -1; + + // Assume non-variance + return parent.parameters.content.length; + } + + void useParent(MethodContainer parent, Monotype[] params) + { + if (parentParams == null) + classConstraint = + specialize(this.classConstraint, parent.classConstraint, params); + + } + /**************************************************************** * Class hierarchy Index: EnumDefinition.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/EnumDefinition.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** EnumDefinition.java 4 Aug 2004 18:36:08 -0000 1.12 --- EnumDefinition.java 12 Aug 2004 23:21:41 -0000 1.13 *************** *** 34,38 **** classDef = ClassDefinition.makeClass (name,true,false, null, new ArrayList(0), ! new TypeIdent(new LocatedString("nice.lang.Enum",name.location())), interfaces,null); NiceClass impl = new NiceClass(classDef); --- 34,38 ---- classDef = ClassDefinition.makeClass (name,true,false, null, new ArrayList(0), ! new MonotypeConstructor(new TypeIdent(new LocatedString("nice.lang.Enum",name.location())), null, this.location()), interfaces,null); NiceClass impl = new NiceClass(classDef); Index: MethodContainer.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MethodContainer.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** MethodContainer.java 16 Jul 2004 10:01:33 -0000 1.16 --- MethodContainer.java 12 Aug 2004 23:21:41 -0000 1.17 *************** *** 33,48 **** public abstract class MethodContainer extends Definition { ! MethodContainer (LocatedString name, int propagate, ! MethodContainer.Constraint classConstraint, ! List variance) { super(name, propagate); this.name.prepend(module.getName() + "."); - - this.variance = makeVariance(variance); this.classConstraint = classConstraint; } /** The name of this method container without package qualification. */ String getSimpleName() --- 33,53 ---- public abstract class MethodContainer extends Definition { ! MethodContainer (LocatedString name, int propagate, ! MethodContainer.Constraint classConstraint) { super(name, propagate); this.name.prepend(module.getName() + "."); this.classConstraint = classConstraint; } + MethodContainer (LocatedString name, int propagate, + MethodContainer.Constraint classConstraint, + List variance) + { + this(name, propagate, classConstraint); + this.variance = makeVariance(variance); + } + /** The name of this method container without package qualification. */ String getSimpleName() *************** *** 56,60 **** abstract mlsub.typing.TypeSymbol getTypeSymbol(); ! private static Variance makeVariance(java.util.List typeParametersVariances) { int[] variances = new int[typeParametersVariances.size()]; --- 61,65 ---- abstract mlsub.typing.TypeSymbol getTypeSymbol(); ! static Variance makeVariance(java.util.List typeParametersVariances) { int[] variances = new int[typeParametersVariances.size()]; *************** *** 119,124 **** } /** ! Replace those type parameters that have been introduced in the constraint by their definition. */ --- 124,137 ---- } + Constraint (TypeSymbol[] binders, List atoms, + mlsub.typing.Monotype[] typeParameters, + Location loc) + { + super(binders, atoms); + this.typeParameters = typeParameters; + } + /** ! Replace those type parameters that have been introduced in the constraint by their definition. */ *************** *** 156,160 **** } ! final Constraint classConstraint; mlsub.typing.AtomicConstraint[] resolvedConstraints; --- 169,173 ---- } ! Constraint classConstraint; mlsub.typing.AtomicConstraint[] resolvedConstraints; Index: MonotypeConstructor.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MonotypeConstructor.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** MonotypeConstructor.java 27 May 2003 07:41:37 -0000 1.33 --- MonotypeConstructor.java 12 Aug 2004 23:21:41 -0000 1.34 *************** *** 63,82 **** ****************************************************************/ ! mlsub.typing.Monotype rawResolve(TypeMap typeMap) { ! if(lowlevelTC==null) { TypeSymbol newTC = this.tc.resolveToTC(typeMap); ! if (!(newTC instanceof TypeConstructor)) User.error(this.tc, this.tc+" should be a type constructor"); lowlevelTC = (TypeConstructor) newTC; } ! try{ ! mlsub.typing.Monotype type = new mlsub.typing.MonotypeConstructor(lowlevelTC, parameters.resolve(typeMap)); ! return type; } catch(mlsub.typing.BadSizeEx e){ ! throw User.error(this, (tc!=null ? "Class "+tc : lowlevelTC.toString()) + Util.has(e.expected, "type parameter", e.actual)); } --- 63,88 ---- ****************************************************************/ ! mlsub.typing.Monotype rawResolve(TypeMap typeMap) { ! if (lowlevelTC == null) { TypeSymbol newTC = this.tc.resolveToTC(typeMap); ! if (! (newTC instanceof TypeConstructor)) User.error(this.tc, this.tc+" should be a type constructor"); lowlevelTC = (TypeConstructor) newTC; } ! ! mlsub.typing.Monotype[] resolvedParams = parameters.resolve(typeMap); ! try{ ! return new mlsub.typing.MonotypeConstructor(lowlevelTC, resolvedParams); } catch(mlsub.typing.BadSizeEx e){ ! // See if this is a class with default type parameters ! mlsub.typing.Monotype res = ClassDefinition.toType(lowlevelTC, resolvedParams); ! if (res != null) ! return res; ! ! throw User.error(this, (tc!=null ? "Class "+tc : lowlevelTC.toString()) + Util.has(e.expected, "type parameter", e.actual)); } Index: AbstractInterface.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/AbstractInterface.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** AbstractInterface.java 15 Dec 2003 14:04:13 -0000 1.18 --- AbstractInterface.java 12 Aug 2004 23:21:42 -0000 1.19 *************** *** 55,63 **** ****************************************************************/ void resolve() { super.resolve(); ! surinterfaces = TypeIdent.resolveToItf(typeScope, extensions); extensions = null; --- 55,79 ---- ****************************************************************/ + static Interface[] resolve(TypeMap scope, List types) + { + if (types == null || types.size() == 0) return null; + + Interface[] res = new Interface[types.size()]; + + int n = 0; + for (Iterator i = types.iterator(); i.hasNext(); n++) + { + MonotypeConstructor parent = (MonotypeConstructor) i.next(); + res[n++] = parent.tc.resolveToItf(scope); + } + + return res; + } + void resolve() { super.resolve(); ! superInterfaces = resolve(typeScope, extensions); extensions = null; *************** *** 82,91 **** private void createContext() { ! if (surinterfaces != null) try{ ! Typing.assertLeq(itf, surinterfaces); } catch(mlsub.typing.KindingEx e){ ! User.error(name, name + " cannot extends one of the surinterfaces " + " because they don't have the same number or kind of " + " type parameters"); --- 98,107 ---- private void createContext() { ! if (superInterfaces != null) try{ ! Typing.assertLeq(itf, superInterfaces); } catch(mlsub.typing.KindingEx e){ ! User.error(name, name + " cannot extends one of the interfaces " + " because they don't have the same number or kind of " + " type parameters"); *************** *** 103,107 **** + getSimpleName() + printTypeParameters() ! + Util.map(" extends ",", ","", surinterfaces) + "{}\n"); --- 119,123 ---- + getSimpleName() + printTypeParameters() ! + Util.map(" extends ",", ","", superInterfaces) + "{}\n"); *************** *** 142,147 **** /** ML-Sub interface. */ private Interface itf; ! ! private List /* of Interface */ extensions; // the surinterfaces ! private Interface[] surinterfaces; // resolved surinterfaces } --- 158,163 ---- /** ML-Sub interface. */ private Interface itf; ! ! private List /* of Interface */ extensions; // the super-interfaces ! private Interface[] superInterfaces; // resolved super-interfaces } |
From: Daniel B. <bo...@us...> - 2004-08-12 23:22:22
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29266/src/bossa/parser Modified Files: Parser.jj Log Message: Allow subclasses to have less type parameters than their parent, by instantiation of some of their type parameters. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.256 retrieving revision 1.257 diff -C2 -d -r1.256 -r1.257 *** Parser.jj 11 Aug 2004 14:13:02 -0000 1.256 --- Parser.jj 12 Aug 2004 23:21:42 -0000 1.257 *************** *** 935,946 **** } ! TypeIdent superClass(): ! { TypeIdent name; } { ! name=typeIdent() // ignore type parameters // they should be checked ! [ "<" ident() ( "," ident() )* ">" ] ! { return name; } } --- 935,946 ---- } ! MonotypeConstructor superClass(): ! { TypeIdent name; List params = null; } { ! name=typeIdent() // ignore type parameters // they should be checked ! [ "<" params = monotypes() ">" ] ! { return new MonotypeConstructor(name, params == null ? null : new TypeParameters(params), name.location()); } } *************** *** 948,952 **** { List res=new LinkedList(); ! TypeIdent name; } { --- 948,952 ---- { List res=new LinkedList(); ! MonotypeConstructor name; } { *************** *** 1050,1054 **** [ parameters=classTypeParameters(cst, typeParametersVariances) ] ! { TypeIdent sup = null; } [ "extends" sup = superClass() ] --- 1050,1054 ---- [ parameters=classTypeParameters(cst, typeParametersVariances) ] ! { MonotypeConstructor sup = null; } [ "extends" sup = superClass() ] |
From: Daniel B. <bo...@us...> - 2004-08-12 23:22:21
|
Update of /cvsroot/nice/Nice/testsuite/compiler/classes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29266/testsuite/compiler/classes Modified Files: typeParameters.testsuite Added Files: specialization.testsuite Log Message: Allow subclasses to have less type parameters than their parent, by instantiation of some of their type parameters. --- NEW FILE: specialization.testsuite --- /// PASS B b = new B(x: ""); String s = b.x; /// Toplevel class A<T> { T x; } class B extends A<String> {} /// PASS B b = new B(); String s = b.get(); /// Toplevel abstract class A<T> { T get(); } class B extends A<String> { get() = ""; } /// PASS B b = new B(); String s = b.get(); /// Toplevel interface A<T> { T get(); } class B implements A<String> { get() = ""; } /// FAIL B /*/// FAIL HERE */ b = new B(x: 0); /// Toplevel class A<T> { T x; } class B extends A<String> {} /// PASS B<int> b = new B(x: 0, y: ""); C<int> c = new C(x: "", y: 0); /// Toplevel class A<T,U> { T x; U y; } class B<V> extends A<V, String> {} class C<W> extends A<String, W> {} /// PASS B<int,boolean> b = new B(x: 0, y: "", z: false); C<int,boolean> c = new C(x: true, y: "", z: 0); /// Toplevel class A<T,U,V> { T x; U y; V z; } class B<T,V> extends A<T, String, V> {} class C<T,V> extends A<V, String, T> {} Index: typeParameters.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/classes/typeParameters.testsuite,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** typeParameters.testsuite 16 Jul 2004 10:01:32 -0000 1.18 --- typeParameters.testsuite 12 Aug 2004 23:21:41 -0000 1.19 *************** *** 367,368 **** --- 367,373 ---- get(i) = null; } + + /// FAIL + /// Toplevel + class A<T> {} + class B<T> extends A<U> {} |
From: Daniel B. <bo...@us...> - 2004-08-12 23:22:21
|
Update of /cvsroot/nice/Nice/testsuite/compiler/typing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29266/testsuite/compiler/typing Modified Files: inference.testsuite Log Message: Allow subclasses to have less type parameters than their parent, by instantiation of some of their type parameters. Index: inference.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/typing/inference.testsuite,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** inference.testsuite 22 Apr 2004 10:09:27 -0000 1.8 --- inference.testsuite 12 Aug 2004 23:21:40 -0000 1.9 *************** *** 4,8 **** void poly(FOO) {} } ! class B<BAR> extends A<FOO> {} /// PASS --- 4,8 ---- void poly(FOO) {} } ! class B<BAR> extends A<BAR> {} /// PASS |
From: Daniel B. <bo...@us...> - 2004-08-12 23:22:03
|
Update of /cvsroot/nice/Nice In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29266 Modified Files: NEWS Log Message: Allow subclasses to have less type parameters than their parent, by instantiation of some of their type parameters. Index: NEWS =================================================================== RCS file: /cvsroot/nice/Nice/NEWS,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** NEWS 11 Aug 2004 16:09:34 -0000 1.41 --- NEWS 12 Aug 2004 23:21:43 -0000 1.42 *************** *** 12,15 **** --- 12,18 ---- This make it possible to write type-safe code that uses reflexion, in particular when using class literals. + * Subclasses can have less type parameters than their parent by fixing + the value of the others. For instance: + class BitField implements List<boolean> { ... } * Improved speed of coverage tests for some methods. * Removed the '--strict' compiler option. |