nice-commit Mailing List for The Nice Programming Language (Page 34)
Brought to you by:
bonniot
You can subscribe to this list here.
2003 |
Jan
|
Feb
(60) |
Mar
(125) |
Apr
(183) |
May
(140) |
Jun
(227) |
Jul
(141) |
Aug
(181) |
Sep
(75) |
Oct
(89) |
Nov
(187) |
Dec
(162) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(69) |
Feb
(197) |
Mar
(98) |
Apr
(26) |
May
(10) |
Jun
(85) |
Jul
(88) |
Aug
(79) |
Sep
(80) |
Oct
(81) |
Nov
(53) |
Dec
(109) |
2005 |
Jan
(68) |
Feb
(77) |
Mar
(232) |
Apr
(79) |
May
(37) |
Jun
(37) |
Jul
(3) |
Aug
(18) |
Sep
|
Oct
|
Nov
|
Dec
|
2006 |
Jan
(10) |
Feb
|
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(1) |
Dec
(9) |
2007 |
Jan
(2) |
Feb
(8) |
Mar
(2) |
Apr
(5) |
May
|
Jun
|
Jul
|
Aug
(4) |
Sep
|
Oct
|
Nov
(17) |
Dec
(6) |
2008 |
Jan
|
Feb
(3) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Arjan B. <ar...@us...> - 2004-10-07 22:04:23
|
Update of /cvsroot/nice/Nice/src/nice/tools/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13177/F:/nice/src/nice/tools/doc Modified Files: htmlwriter.nice Log Message: Don't allow redefinition of parameters in local variables. Index: htmlwriter.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/doc/htmlwriter.nice,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** htmlwriter.nice 21 Sep 2004 14:44:08 -0000 1.23 --- htmlwriter.nice 7 Oct 2004 22:03:42 -0000 1.24 *************** *** 107,112 **** //Note: the comments is deliberately not htmlEncoded because I want people //to be able to put their own html in the comment. ! Comment c = new Comment(commentStr: comments); ! List<(?String, String)> tags = c.tags; //write the general comment (?String a, String b) = tags.removeAt(0); --- 107,112 ---- //Note: the comments is deliberately not htmlEncoded because I want people //to be able to put their own html in the comment. ! Comment comm = new Comment(commentStr: comments); ! List<(?String, String)> tags = comm.tags; //write the general comment (?String a, String b) = tags.removeAt(0); |
From: Arjan B. <ar...@us...> - 2004-10-07 22:04:22
|
Update of /cvsroot/nice/Nice/src/nice/tools/compiler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13177/F:/nice/src/nice/tools/compiler Modified Files: native.nice Log Message: Don't allow redefinition of parameters in local variables. Index: native.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/compiler/native.nice,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** native.nice 18 Jun 2004 13:16:30 -0000 1.7 --- native.nice 7 Oct 2004 22:03:41 -0000 1.8 *************** *** 43,48 **** "--main=" + pkg + ".fun", "-o", output, jar ]); ! let CharArrayWriter output = new CharArrayWriter(); ! let exitValue = waitFor(p, output); if (exitValue != 0) { --- 43,48 ---- "--main=" + pkg + ".fun", "-o", output, jar ]); ! let CharArrayWriter out = new CharArrayWriter(); ! let exitValue = waitFor(p, out); if (exitValue != 0) { *************** *** 50,54 **** // Print the output of the process ! let in = new BufferedReader(new CharArrayReader(output.toCharArray)); try { for (?String line = in.readLine(); line != null; --- 50,54 ---- // Print the output of the process ! let in = new BufferedReader(new CharArrayReader(out.toCharArray)); try { for (?String line = in.readLine(); line != null; |
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13177/F:/nice/src/bossa/syntax Modified Files: CustomConstructor.java MethodImplementation.java analyse.nice dispatch.java.bootstrap pattern.nice tools.nice typecheck.nice Log Message: Don't allow redefinition of parameters in local variables. Index: analyse.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/analyse.nice,v retrieving revision 1.111 retrieving revision 1.112 diff -C2 -d -r1.111 -r1.112 *** analyse.nice 2 Sep 2004 15:46:32 -0000 1.111 --- analyse.nice 7 Oct 2004 22:03:44 -0000 1.112 *************** *** 51,54 **** --- 51,70 ---- } + Statement analyseMethodBody(Statement s, VarScope varScope, TypeScope typeScope, + MonoSymbol[] params, boolean mustReturnAValue) + { + Info info = buildInfo(varScope, typeScope); + + info.addVars(params); + + analyse(s, info); + + if (mustReturnAValue && !info.getUnreachable()) + throw error(s, "Missing return statement"); + + return s; + } + + analyse(Expression e, varScope, typeScope) = analyse(e, buildInfo(varScope, typeScope)); *************** *** 840,845 **** { // if it isn't a loop it must be a block because of the parser ! Block b = cast(target.getStatement()); ! b.isBreakTarget = true; } --- 856,861 ---- { // if it isn't a loop it must be a block because of the parser ! Block block = cast(target.getStatement()); ! block.isBreakTarget = true; } Index: CustomConstructor.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/CustomConstructor.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** CustomConstructor.java 7 Oct 2004 16:25:06 -0000 1.20 --- CustomConstructor.java 7 Oct 2004 22:03:43 -0000 1.21 *************** *** 112,117 **** { bossa.syntax.dispatch.resolveCCThis(body, this, classe); ! body = bossa.syntax.dispatch.analyse ! (body, thisScope, thisTypeScope, false); } --- 112,117 ---- { bossa.syntax.dispatch.resolveCCThis(body, this, classe); ! body = bossa.syntax.dispatch.analyseMethodBody ! (body, thisScope, thisTypeScope, getSymbols(), false); } Index: pattern.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/pattern.nice,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pattern.nice 15 Sep 2004 12:58:57 -0000 1.4 --- pattern.nice 7 Oct 2004 22:03:44 -0000 1.5 *************** *** 100,103 **** --- 100,105 ---- { atAny() = true; + + getName() = notNull(name).toString().equals("_") ? null : name; } *************** *** 235,239 **** public class ReferencePattern extends ValuePattern { ! getName() = cast(null); } --- 237,241 ---- public class ReferencePattern extends ValuePattern { ! getName() = null; } Index: MethodImplementation.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MethodImplementation.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** MethodImplementation.java 14 Sep 2004 16:11:46 -0000 1.8 --- MethodImplementation.java 7 Oct 2004 22:03:44 -0000 1.9 *************** *** 91,95 **** } ! res[tn] = new MonoSymbol(p.getName(), type); } scope.addSymbols(res); --- 91,96 ---- } ! LocatedString argName = p.getName() != null ? p.getName() : new LocatedString("argument_"+tn, bossa.util.Location.nowhere()); ! res[tn] = new MonoSymbol(argName, type); } scope.addSymbols(res); *************** *** 116,121 **** try { ! body = bossa.syntax.dispatch.analyse ! (body, scope, typeScope, !Types.isVoid(declaration.getReturnType())); } finally { --- 117,122 ---- try { ! body = bossa.syntax.dispatch.analyseMethodBody ! (body, scope, typeScope, parameters, !Types.isVoid(declaration.getReturnType())); } finally { Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** tools.nice 16 Sep 2004 21:25:59 -0000 1.51 --- tools.nice 7 Oct 2004 22:03:44 -0000 1.52 *************** *** 212,215 **** --- 212,217 ---- ?mlsub.typing.TypeConstructor getRuntimeTC(Pattern) = native mlsub.typing.TypeConstructor Pattern.getRuntimeTC(); boolean matchesValue(Pattern, ConstantExp) = native boolean Pattern.matchesValue(ConstantExp); + public ?LocatedString getName(Pattern) = native LocatedString Pattern.getName(); + // Retypings needed since java types are not strict. Index: dispatch.java.bootstrap =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/dispatch.java.bootstrap,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** dispatch.java.bootstrap 2 Sep 2004 15:46:32 -0000 1.22 --- dispatch.java.bootstrap 7 Oct 2004 22:03:44 -0000 1.23 *************** *** 75,79 **** { return null; } ! static Statement analyse(Statement s, VarScope v, TypeScope t, boolean r) { return null; } --- 75,82 ---- { return null; } ! static Statement analyse(Statement s, VarScope v, TypeScope t, boolean r) ! { return null; } ! ! static Statement analyseMethodBody(Statement s, VarScope varScope, TypeScope typeScope, MonoSymbol[] params, boolean mustReturnAValue) { return null; } Index: typecheck.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typecheck.nice,v retrieving revision 1.115 retrieving revision 1.116 diff -C2 -d -r1.115 -r1.116 *** typecheck.nice 3 Sep 2004 18:07:27 -0000 1.115 --- typecheck.nice 7 Oct 2004 22:03:44 -0000 1.116 *************** *** 242,246 **** } } ! catch(TypingEx e){ } } --- 242,246 ---- } } ! catch(TypingEx te){ } } |
From: Arjan B. <ar...@us...> - 2004-10-07 22:03:57
|
Update of /cvsroot/nice/Nice/testsuite/compiler/statements/variables In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13177/F:/nice/testsuite/compiler/statements/variables Modified Files: scoping.testsuite Log Message: Don't allow redefinition of parameters in local variables. Index: scoping.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/statements/variables/scoping.testsuite,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** scoping.testsuite 16 Sep 2004 11:27:54 -0000 1.1 --- scoping.testsuite 7 Oct 2004 22:03:45 -0000 1.2 *************** *** 6,10 **** } ! /// FAIL bug /// Toplevel void foo(int x) { --- 6,10 ---- } ! /// FAIL /// Toplevel void foo(int x) { *************** *** 12,13 **** --- 12,21 ---- x++; } + + /// FAIL + /// Toplevel + class A {} + new A(int x) { + int /*/// FAIL HERE */ x = 2; + this(); + } |
From: Arjan B. <ar...@us...> - 2004-10-07 22:03:57
|
Update of /cvsroot/nice/Nice/testsuite/compiler/methods In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13177/F:/nice/testsuite/compiler/methods Modified Files: super.testsuite Log Message: Don't allow redefinition of parameters in local variables. Index: super.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/methods/super.testsuite,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** super.testsuite 5 Feb 2004 23:00:04 -0000 1.13 --- super.testsuite 7 Oct 2004 22:03:44 -0000 1.14 *************** *** 48,55 **** /// Toplevel void m(A, A); ! m(a, a) {} ! m(a@A, b@B) {} ! m(b@B, a@A) {} ! m(b@B, b@B) { /*/// FAIL HERE */ super; } /// PASS --- 48,55 ---- /// Toplevel void m(A, A); ! m(x, y) {} ! m(x@A, y@B) {} ! m(x@B, y@A) {} ! m(x@B, y@B) { /*/// FAIL HERE */ super; } /// PASS |
From: Daniel B. <bo...@us...> - 2004-10-07 20:03:07
|
Update of /cvsroot/nice/eclipse In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12421 Modified Files: nice_plugin_build.properties build.xml Log Message: Updated for Nice 0.9.9 Index: nice_plugin_build.properties =================================================================== RCS file: /cvsroot/nice/eclipse/nice_plugin_build.properties,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** nice_plugin_build.properties 11 Nov 2003 14:17:06 -0000 1.3 --- nice_plugin_build.properties 7 Oct 2004 20:02:55 -0000 1.4 *************** *** 1,3 **** ! nice.runtime = /home/alex/project/nice/nice.jar ! eclipse.home = /opt/eclipse --- 1,5 ---- ! nice.runtime = /home/daniel/projets/Nice-CVS/share/java/nice.jar ! eclipse.home = /usr/share/eclipse ! ! plugin.version = 0.9.9 Index: build.xml =================================================================== RCS file: /cvsroot/nice/eclipse/build.xml,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** build.xml 24 Jun 2004 12:14:47 -0000 1.13 --- build.xml 7 Oct 2004 20:02:56 -0000 1.14 *************** *** 19,25 **** <project default="dist" basedir="."> - <property name="plugin.version" value="0.9.8"/> - - <property name="build.properties" value="nice_plugin_build.properties"/> <property file="${build.properties}"/> --- 19,22 ---- |
From: Daniel B. <bo...@us...> - 2004-10-07 20:03:06
|
Update of /cvsroot/nice/eclipse/src/nice/eclipse/core/builder In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12421/src/nice/eclipse/core/builder Modified Files: NiceBuilder.nice Log Message: Updated for Nice 0.9.9 Index: NiceBuilder.nice =================================================================== RCS file: /cvsroot/nice/eclipse/src/nice/eclipse/core/builder/NiceBuilder.nice,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** NiceBuilder.nice 8 Mar 2004 16:00:12 -0000 1.5 --- NiceBuilder.nice 7 Oct 2004 20:02:54 -0000 1.6 *************** *** 47,52 **** NICE_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE); ! Compilation compilation = ! new bossa.modules.Compilation(listener: embedded); File projectFolder = currentProject.getLocation().toFile(); --- 47,53 ---- NICE_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE); ! Compilation compilation = ! new bossa.modules.Compilation(listener: embedded, ! parser: new bossa.parser.JavaccParser()); File projectFolder = currentProject.getLocation().toFile(); |
From: Daniel B. <bo...@us...> - 2004-10-07 19:34:13
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5942/src/bossa/syntax Modified Files: Constructor.java Log Message: Clearer error message when a required field is missing. Index: Constructor.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Constructor.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Constructor.java 7 Oct 2004 15:29:29 -0000 1.12 --- Constructor.java 7 Oct 2004 19:34:00 -0000 1.13 *************** *** 108,127 **** res = new StringBuffer(); List missing = arguments.missingArgs(parameters); ! Iterator missingFields = null; ! if (arguments.size() == 0 || missing.size() > 0) { ! res.append("Fields of class ").append(name).append(" require initial values.\n"); ! if (arguments.size() == 0) ! { ! res.append(syntaxExample()) ! .append("Class ").append(name).append(" has the following fields:\n"); ! missingFields = parameters.iterator(); ! } ! else ! { ! res.append("These fields are missing:\n"); ! missingFields = missing.iterator(); ! } } else --- 108,125 ---- res = new StringBuffer(); List missing = arguments.missingArgs(parameters); ! Iterator fieldsToList; ! if (arguments.size() == 0) { ! res.append("Fields of class ").append(name) ! .append(" require initial values.\n"); ! res.append(syntaxExample()) ! .append("Class ").append(name).append(" has the following fields:\n"); ! fieldsToList = parameters.iterator(); ! } ! else if (missing.size() > 0) ! { ! res.append("The following fields require initial values:\n"); ! fieldsToList = missing.iterator(); } else *************** *** 131,140 **** .append(".\n") .append("The constructor accepts the following arguments:\n" ); ! missingFields = parameters.iterator(); } ! while(missingFields.hasNext()) { res.append(" ") ! .append(missingFields.next()) .append("\n"); } --- 129,138 ---- .append(".\n") .append("The constructor accepts the following arguments:\n" ); ! fieldsToList = parameters.iterator(); } ! while (fieldsToList.hasNext()) { res.append(" ") ! .append(fieldsToList.next()) .append("\n"); } |
From: Daniel B. <bo...@us...> - 2004-10-07 16:25:20
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23128/src/bossa/syntax Modified Files: CustomConstructor.java Log Message: Simplification of CustomConstructor, now that it only concerns source constructors. Index: CustomConstructor.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/CustomConstructor.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** CustomConstructor.java 7 Oct 2004 15:29:29 -0000 1.19 --- CustomConstructor.java 7 Oct 2004 16:25:06 -0000 1.20 *************** *** 25,66 **** /** ! A user defined constructor. */ ! public abstract class CustomConstructor extends UserOperator { public static CustomConstructor make ! (LocatedString className, Constraint cst, FormalParameters params, Statement body) { ! return new SourceCustomConstructor(className, cst, params, body); } ! CustomConstructor(LocatedString className, Constraint cst, ! FormalParameters params) { ! super(new LocatedString("<init>", className.location()), cst, returnType(className, cst), params, Contract.noContract); - } ! void addConstructorCallSymbol() ! { ! mlsub.typing.Polytype type = new mlsub.typing.Polytype ! (getType().getConstraint(), ! new mlsub.typing.FunType(getArgTypes(), PrimitiveType.voidType)); ! classe.addConstructorCallSymbol ! (new MethodDeclaration.Symbol(name, type) { ! gnu.expr.Expression compileInCallPosition() ! { ! return getInitializationCode(true); ! } ! }); } private static Monotype returnType(LocatedString className, Constraint cst) { TypeIdent classe = new TypeIdent(className); classe.nullness = Monotype.sure; ! if (cst == Constraint.True) return classe; --- 25,57 ---- /** ! A user defined constructor, in a source program. */ ! public class CustomConstructor extends UserOperator { public static CustomConstructor make ! (LocatedString className, Constraint cst, FormalParameters params, Statement body) { ! return new CustomConstructor(className, cst, params, body); } ! CustomConstructor(LocatedString className, Constraint cst, ! FormalParameters params, Statement body) { ! super(new LocatedString("<init>", className.location()), cst, returnType(className, cst), params, Contract.noContract); ! this.className = className; ! this.body = body; } + NiceClass classe; + private static Monotype returnType(LocatedString className, Constraint cst) { TypeIdent classe = new TypeIdent(className); classe.nullness = Monotype.sure; ! if (cst == Constraint.True) return classe; *************** *** 82,205 **** } ! public void printInterface(java.io.PrintWriter s) { ! // Constructors are not printed, they are loaded from the bytecode. } ! public void compile() { ! // Make sure the constructor is generated. ! getCode(); ! } ! ! abstract gnu.expr.Expression getInitializationCode(boolean implicitThis); ! ! NiceClass classe; ! /**************************************************************** ! * A custom constructor defined in a source program. ! ****************************************************************/ ! static class SourceCustomConstructor extends CustomConstructor ! { ! SourceCustomConstructor(LocatedString className, Constraint cst, ! FormalParameters params, Statement body) ! { ! super(className, cst, params); ! this.className = className; ! this.body = body; ! } ! void resolve() ! { ! super.resolve(); ! TypeConstructor tc = Node.getGlobalTypeScope().globalLookup(className); ! TypeConstructors.addConstructor(tc, this); ! classe = NiceClass.get(tc); ! if (classe == null) ! User.error(this, ! "It is impossible to add a constructor to class " + tc); ! addConstructorCallSymbol(); ! // Save the scopes, since we need them later, but they get null'ed. ! thisScope = scope; ! thisTypeScope = typeScope; ! } ! private VarScope thisScope; ! private TypeScope thisTypeScope; ! void resolveBody() ! { ! bossa.syntax.dispatch.resolveCCThis(body, this, classe); ! body = bossa.syntax.dispatch.analyse ! (body, thisScope, thisTypeScope, false); ! } ! void innerTypecheck() throws TypingEx ! { ! super.innerTypecheck(); ! bossa.syntax.dispatch.typecheck(body); ! } ! private Map map(TypeSymbol[] source, mlsub.typing.Monotype[] destination) ! { ! Map res = new HashMap(source.length); ! for (int i = 0; i < source.length; i++) ! res.put(source[i].toString(), Monotype.create(destination[i])); ! return res; ! } ! protected gnu.expr.Expression computeCode() ! { ! ConstructorExp lambda = Gen.createCustomConstructor ! ((ClassType) javaReturnType(), javaArgTypes(), getSymbols()); ! Gen.setMethodBody(lambda, body.generateCode()); ! classe.getClassExp().addMethod(lambda); ! ! // In the bytecode, we want to use the same type parameter names ! // as the class definition, even if the source of this custom constructor ! // renamed them locally. ! mlsub.typing.Constraint cst = getType().getConstraint(); ! if (mlsub.typing.Constraint.hasBinders(cst)) ! parameters.substitute ! (map(cst.binders(), classe.definition.getTypeParameters())); ! lambda.addBytecodeAttribute(parameters.asBytecodeAttribute()); ! initializationCode = ! new QuoteExp(new InitializeProc(lambda)); ! initializationCodeImplicitThis = ! new QuoteExp(new InitializeProc(lambda, true)); ! return new QuoteExp(new InstantiateProc(lambda)); ! } ! gnu.expr.Expression getConstructorInvocation(boolean omitDefaults) ! { ! getCode(); return initializationCode; - } - - gnu.expr.Expression getInitializationCode(boolean implicitThis) - { - getCode(); - if (implicitThis) - return initializationCodeImplicitThis; - else - return initializationCode; - } - - LocatedString className; - Statement body; - gnu.expr.Expression initializationCode; - gnu.expr.Expression initializationCodeImplicitThis; } } --- 73,190 ---- } ! void addConstructorCallSymbol() { ! mlsub.typing.Polytype type = new mlsub.typing.Polytype ! (getType().getConstraint(), ! new mlsub.typing.FunType(getArgTypes(), PrimitiveType.voidType)); ! classe.addConstructorCallSymbol ! (new MethodDeclaration.Symbol(name, type) { ! gnu.expr.Expression compileInCallPosition() ! { ! return getInitializationCode(true); ! } ! }); } ! void resolve() { ! super.resolve(); ! TypeConstructor tc = Node.getGlobalTypeScope().globalLookup(className); ! TypeConstructors.addConstructor(tc, this); ! classe = NiceClass.get(tc); ! if (classe == null) ! User.error(this, ! "It is impossible to add a constructor to class " + tc); ! addConstructorCallSymbol(); ! // Save the scopes, since we need them later, but they get null'ed. ! thisScope = scope; ! thisTypeScope = typeScope; ! } ! private VarScope thisScope; ! private TypeScope thisTypeScope; ! void resolveBody() ! { ! bossa.syntax.dispatch.resolveCCThis(body, this, classe); ! body = bossa.syntax.dispatch.analyse ! (body, thisScope, thisTypeScope, false); ! } ! void innerTypecheck() throws TypingEx ! { ! super.innerTypecheck(); ! bossa.syntax.dispatch.typecheck(body); ! } ! public void printInterface(java.io.PrintWriter s) ! { ! // Constructors are not printed, they are loaded from the bytecode. ! } ! public void compile() ! { ! // Make sure the constructor is generated. ! getCode(); ! } ! private Map map(TypeSymbol[] source, mlsub.typing.Monotype[] destination) ! { ! Map res = new HashMap(source.length); ! for (int i = 0; i < source.length; i++) ! res.put(source[i].toString(), Monotype.create(destination[i])); ! return res; ! } ! protected gnu.expr.Expression computeCode() ! { ! ConstructorExp lambda = Gen.createCustomConstructor ! ((ClassType) javaReturnType(), javaArgTypes(), getSymbols()); ! Gen.setMethodBody(lambda, body.generateCode()); ! classe.getClassExp().addMethod(lambda); ! // In the bytecode, we want to use the same type parameter names ! // as the class definition, even if the source of this custom constructor ! // renamed them locally. ! mlsub.typing.Constraint cst = getType().getConstraint(); ! if (mlsub.typing.Constraint.hasBinders(cst)) ! parameters.substitute ! (map(cst.binders(), classe.definition.getTypeParameters())); ! lambda.addBytecodeAttribute(parameters.asBytecodeAttribute()); ! initializationCode = ! new QuoteExp(new InitializeProc(lambda)); ! initializationCodeImplicitThis = ! new QuoteExp(new InitializeProc(lambda, true)); ! return new QuoteExp(new InstantiateProc(lambda)); ! } ! gnu.expr.Expression getConstructorInvocation(boolean omitDefaults) ! { ! getCode(); ! return initializationCode; ! } ! gnu.expr.Expression getInitializationCode(boolean implicitThis) ! { ! getCode(); ! if (implicitThis) ! return initializationCodeImplicitThis; ! else return initializationCode; } + + LocatedString className; + Statement body; + gnu.expr.Expression initializationCode; + gnu.expr.Expression initializationCodeImplicitThis; } |
From: Daniel B. <bo...@us...> - 2004-10-07 15:30:22
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9115/src/bossa/syntax Modified Files: NiceClass.java CustomConstructor.java Constructor.java Added Files: ImportedConstructor.java DefaultConstructor.java Log Message: Reworked the hierarchy of classes representing constructors. bossa.syntax.Constructor is now a super-class for DefaultConstructor (default constructor in source packages) and ImportedConstructor (constructor imported from a compiled package, default or not). This allows to factor handling of default constructors, and in particular to provide the specialized error messages for imported default constructors. Index: CustomConstructor.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/CustomConstructor.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** CustomConstructor.java 8 Aug 2004 21:51:54 -0000 1.18 --- CustomConstructor.java 7 Oct 2004 15:29:29 -0000 1.19 *************** *** 44,57 **** } - CustomConstructor(NiceClass def, FormalParameters parameters) - { - super(new LocatedString("<init>", def.definition.location()), - def.definition.classConstraint == null ? - null : def.definition.classConstraint.shallowClone(), - returnType(def.definition), parameters, - Contract.noContract); - classe = def; - } - void addConstructorCallSymbol() { --- 44,47 ---- *************** *** 92,102 **** } - private static Monotype returnType(ClassDefinition def) - { - mlsub.typing.Monotype res = Monotype.sure - (new mlsub.typing.MonotypeConstructor(def.tc, def.getTypeParameters())); - return Monotype.create(res); - } - public void printInterface(java.io.PrintWriter s) { --- 82,85 ---- *************** *** 220,300 **** gnu.expr.Expression initializationCodeImplicitThis; } - - /**************************************************************** - * Loading compiled custom constructors. - ****************************************************************/ - - public static CustomConstructor load(NiceClass def, Method method) - { - if (! method.isConstructor()) - return null; - - MiscAttr attr = (MiscAttr) Attribute.get(method, "parameters"); - if (attr == null) - return null; - - return new ImportedCustomConstructor(def, method, attr); - } - - static class ImportedCustomConstructor extends CustomConstructor - { - ImportedCustomConstructor(NiceClass def, Method method, MiscAttr attr) - { - super(def, FormalParameters.readBytecodeAttribute - (attr, JavaClasses.compilation.parser)); - this.method = method; - TypeConstructors.addConstructor(classe.definition.tc, this); - } - - void resolve() - { - super.resolve(); - addConstructorCallSymbol(); - } - - protected gnu.expr.Expression computeCode() - { - int dummyArgs = method.arg_types.length - arity; - return new QuoteExp(new InstantiateProc(method, dummyArgs)); - } - - gnu.expr.Expression getConstructorInvocation(boolean omitDefaults) - { - int dummyArgs = method.arg_types.length - arity; - Method calledMethod = omitDefaults ? getMethodUsingDefaults() : method; - return new QuoteExp(new InitializeProc(calledMethod, false, dummyArgs)); - } - - gnu.expr.Expression getInitializationCode(boolean implicitThis) - { - int dummyArgs = method.arg_types.length - arity; - return new QuoteExp(new InitializeProc(method, implicitThis, dummyArgs)); - } - - private Method method; - - /** - Return the Method for this constructor with the optional parameters - left out. - */ - private Method getMethodUsingDefaults() - { - Type[] fullArgTypes = method.arg_types; - List argTypes = new LinkedList(); - - for (int i = 0; i < parameters.size; i++) - { - if (parameters.hasDefaultValue(i)) - continue; - - argTypes.add(fullArgTypes[i]); - } - - Type[] argTypesArray = (Type[]) argTypes.toArray - (new Type[argTypes.size()]); - - return method.getDeclaringClass().getDeclaredMethod - ("<init>", argTypesArray); - } - } } --- 203,205 ---- Index: Constructor.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Constructor.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Constructor.java 22 Dec 2003 01:30:59 -0000 1.11 --- Constructor.java 7 Oct 2004 15:29:29 -0000 1.12 *************** *** 16,212 **** import bossa.util.*; import bossa.util.Location; - import nice.tools.code.Gen; - - import mlsub.typing.*; import mlsub.typing.Constraint; import mlsub.typing.Monotype; - import gnu.bytecode.*; - import gnu.expr.*; - import gnu.expr.Expression; - /** An object constructor. - @version $Date$ @author Daniel Bonniot (bo...@us...) */ ! class Constructor extends MethodDeclaration { ! Constructor(NiceClass classe, NiceClass.Field[] fields, ! MethodDeclaration parent, ! Location location, ! FormalParameters formals, ! Constraint cst, ! Monotype[] parameters, ! Monotype returnType) { ! super(new LocatedString("<init>", location), formals, cst, parameters, returnType); this.classe = classe; ! this.fields = fields; ! this.parent = parent; ! ! mlsub.typing.Polytype type = new mlsub.typing.Polytype ! (getType().getConstraint(), ! new mlsub.typing.FunType(getArgTypes(), PrimitiveType.voidType)); ! classe.addConstructorCallSymbol ! (new MethodDeclaration.Symbol(name, type) { ! gnu.expr.Expression compileInCallPosition() ! { ! getCode(); ! return initializeFromConstructor; ! } ! }); ! } ! ! private NiceClass classe; ! private NiceClass.Field[] fields; ! private MethodDeclaration parent; ! ! Expression getConstructorInvocation(boolean omitDefaults) ! { ! getCode(); ! return ! // lambdaOmitDefaults is null if the two versions are identical ! omitDefaults && initializeOmitDefaults != null ! ? initializeOmitDefaults : initialize; ! } ! ! /** Call the constructor, with all the arguments. */ ! private Expression initialize; ! ! /** Call the constructor, with all the arguments, with an implicit this argument. */ ! private Expression initializeFromConstructor; ! ! /** Call the constructor, with only non-default arguments. */ ! private Expression initializeOmitDefaults; ! ! /** Instantiate the class, calling the constructor with all the arguments. */ ! private Expression instantiate; ! ! protected Expression computeCode() ! { ! createBytecode(true); ! createBytecode(false); ! return instantiate; } ! /** ! @param omitDefaults if true, do not take the value of fields with ! default values as parameters, but use that default instead. ! */ ! private void createBytecode(boolean omitDefaults) { ! ClassType thisType = (ClassType) javaReturnType(); ! Declaration thisDecl = new Declaration("this"); ! thisDecl.setType(thisType); ! Expression thisExp = new ThisExp(thisDecl); ! ! MonoSymbol[] fullArgs = parameters.getMonoSymbols(); ! Type[] fullArgTypes = javaArgTypes(); ! ! List args = new LinkedList(); ! List argTypes = new LinkedList(); ! ! for (int i = 0; i < parameters.size; i++) ! { ! if (omitDefaults && parameters.hasDefaultValue(i)) ! continue; ! ! args.add(fullArgs[i]); ! argTypes.add(fullArgTypes[i]); ! } ! ! // Do not create a second constructor omiting defaults if there is ! // no default to omit! ! if (omitDefaults && args.size() == fullArgs.length) ! return; ! ! Type[] argTypesArray = (Type[]) argTypes.toArray(new Type[argTypes.size()]); ! MonoSymbol[] argsArray = (MonoSymbol[]) args.toArray(new MonoSymbol[args.size()]); ! ! if (classe.definition.inInterfaceFile()) ! throw new Error("Constructors are loaded from the compiled package"); ! ! ConstructorExp lambda = Gen.createConstructor ! (thisDecl, argTypesArray, argsArray); ! lambda.setSuperCall(callSuper(thisExp, fullArgs, omitDefaults)); ! ! Gen.setMethodBody(lambda, body(thisExp, fullArgs, omitDefaults)); ! classe.getClassExp().addMethod(lambda); ! if (! omitDefaults) ! lambda.addBytecodeAttribute(parameters.asBytecodeAttribute()); ! if (omitDefaults) ! { ! initializeOmitDefaults = new QuoteExp(new InitializeProc(lambda)); ! } ! else ! { ! initialize = new QuoteExp(new InitializeProc(lambda)); ! initializeFromConstructor = new QuoteExp(new InitializeProc(lambda, true)); ! instantiate = new QuoteExp(new InstantiateProc(lambda)); ! } } ! private static gnu.expr.Expression objectConstructor = ! new gnu.expr.QuoteExp ! (new gnu.expr.InitializeProc ! (gnu.bytecode.Type.pointer_type.getDeclaredMethod("<init>", 0))); ! ! private Expression callSuper(Expression thisExp, MonoSymbol[] args, ! boolean omitDefaults) ! { ! int len = args.length - fields.length; ! List/*Expression*/ superArgs = new LinkedList(); ! superArgs.add(thisExp); ! for (int i = 0; i < len; i++) ! { ! if (! (omitDefaults && parameters.hasDefaultValue(i))) ! superArgs.add(args[i].compile()); ! } ! // A null parent means no parent class: call the Object constructor. ! Expression superExp = parent == null ? ! objectConstructor : parent.getConstructorInvocation(omitDefaults); ! return new ApplyExp(superExp, (Expression[]) ! superArgs.toArray(new Expression[superArgs.size()])); ! } ! private Expression body(Expression thisExp, ! MonoSymbol[] fullArgs, boolean omitDefaults) { ! int len = fields.length + classe.nbInitializers(); ! ! if (len == 0) ! return QuoteExp.voidExp; ! ! Expression[] body = new Expression[len]; ! ! final int superArgs = fullArgs.length - fields.length; ! ! for (int i = 0; i < fields.length; i++) ! { ! bossa.syntax.Expression value = fields[i].value; ! ! Expression fieldValue; ! if (!omitDefaults || value == null) ! // Use the provided parameter. ! fieldValue = fullArgs[superArgs + i].compile(); ! else ! // Use the default value. ! fieldValue = value.compile(); ! ! body[i] = fields[i].method.compileAssign(thisExp, fieldValue); ! } ! ! classe.setThisExp(thisExp); ! for (int i = 0; i < classe.nbInitializers(); i++) ! body[fields.length + i] = classe.compileInitializer(i); ! ! return new BeginExp(body); } --- 16,75 ---- import bossa.util.*; import bossa.util.Location; import mlsub.typing.Constraint; import mlsub.typing.Monotype; /** An object constructor. @author Daniel Bonniot (bo...@us...) */ ! abstract class Constructor extends MethodDeclaration { ! Constructor(NiceClass classe, ! boolean isDefault, ! Location location, ! FormalParameters formals, ! Constraint cst, ! Monotype[] parameters, ! Monotype returnType) { ! super(new LocatedString("<init>", location), formals, cst, parameters, returnType); this.classe = classe; ! this.isDefault = isDefault; } ! Constructor(NiceClass classe, ! boolean isDefault, ! Location location, ! FormalParameters formals, ! bossa.syntax.Constraint cst, ! bossa.syntax.Monotype returnType) { ! super(new LocatedString("<init>", location), cst, returnType, formals); ! this.classe = classe; ! this.isDefault = isDefault; } ! protected NiceClass classe; ! final protected boolean isDefault; ! abstract gnu.expr.Expression getInitializationCode(boolean implicitThis); ! void addConstructorCallSymbol() { ! mlsub.typing.Polytype type = new mlsub.typing.Polytype ! (getType().getConstraint(), ! new mlsub.typing.FunType(getArgTypes(), PrimitiveType.voidType)); ! classe.addConstructorCallSymbol ! (new MethodDeclaration.Symbol(name, type) { ! gnu.expr.Expression compileInCallPosition() ! { ! return getInitializationCode(true); ! } ! }); } *************** *** 216,221 **** String explainWhyMatchFails(Arguments arguments) { String name = classe.getName(); ! StringBuffer res = new StringBuffer(); res.append("Class ").append(name); --- 79,87 ---- String explainWhyMatchFails(Arguments arguments) { + if (! isDefault) + return super.explainWhyMatchFails(arguments); + String name = classe.getName(); ! StringBuffer res = new StringBuffer(); res.append("Class ").append(name); *************** *** 246,250 **** if (arguments.size() == 0 || missing.size() > 0) { ! res.append("Fields of class ").append(name).append(" require initial values.\n"); if (arguments.size() == 0) { --- 112,116 ---- if (arguments.size() == 0 || missing.size() > 0) { ! res.append("Fields of class ").append(name).append(" require initial values.\n"); if (arguments.size() == 0) { *************** *** 253,257 **** missingFields = parameters.iterator(); } ! else { res.append("These fields are missing:\n"); --- 119,123 ---- missingFields = parameters.iterator(); } ! else { res.append("These fields are missing:\n"); *************** *** 266,270 **** .append("The constructor accepts the following arguments:\n" ); missingFields = parameters.iterator(); ! } while(missingFields.hasNext()) { --- 132,136 ---- .append("The constructor accepts the following arguments:\n" ); missingFields = parameters.iterator(); ! } while(missingFields.hasNext()) { *************** *** 283,287 **** res.append("Use the following syntax:\n") .append(" new ").append(name).append("("); ! Iterator params = parameters.getRequiredParameters().iterator(); int paramCount = 0; --- 149,153 ---- res.append("Use the following syntax:\n") .append(" new ").append(name).append("("); ! Iterator params = parameters.getRequiredParameters().iterator(); int paramCount = 0; *************** *** 289,295 **** while(params.hasNext()) { ! FormalParameters.Parameter param = (FormalParameters.Parameter)params.next(); ! if (paramCount != 0) res.append(", "); if (paramCount == 3 && params.hasNext()) --- 155,161 ---- while(params.hasNext()) { ! FormalParameters.Parameter param = (FormalParameters.Parameter)params.next(); ! if (paramCount != 0) res.append(", "); if (paramCount == 3 && params.hasNext()) Index: NiceClass.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/NiceClass.java,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -d -r1.85 -r1.86 *** NiceClass.java 20 Sep 2004 10:24:41 -0000 1.85 --- NiceClass.java 7 Oct 2004 15:29:28 -0000 1.86 *************** *** 873,877 **** FormalParameters values = new FormalParameters(args); ! constructorMethod[i] = new Constructor (this, fields, parent, definition.location(), values, --- 873,877 ---- FormalParameters values = new FormalParameters(args); ! constructorMethod[i] = new DefaultConstructor (this, fields, parent, definition.location(), values, --- NEW FILE: ImportedConstructor.java --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package bossa.syntax; import gnu.expr.*; import gnu.bytecode.Type; import gnu.bytecode.ClassType; import gnu.bytecode.Method; import gnu.bytecode.Attribute; import gnu.bytecode.MiscAttr; import java.util.*; import bossa.util.User; /** A constructor imported from a compiled package. @author Daniel Bonniot (bo...@us...) */ public class ImportedConstructor extends Constructor { public static ImportedConstructor load(NiceClass def, Method method) { if (! method.isConstructor()) return null; MiscAttr attr = (MiscAttr) Attribute.get(method, "parameters"); if (attr == null) return null; return new ImportedConstructor(def, method, attr); } ImportedConstructor(NiceClass def, Method method, MiscAttr attr) { super(def, Attribute.get(method, "default") != null, def.definition.location(), FormalParameters.readBytecodeAttribute (attr, JavaClasses.compilation.parser), def.definition.classConstraint == null ? null : def.definition.classConstraint.shallowClone(), returnType(def.definition)); this.method = method; TypeConstructors.addConstructor(classe.definition.tc, this); } private static Monotype returnType(ClassDefinition def) { mlsub.typing.Monotype res = Monotype.sure (new mlsub.typing.MonotypeConstructor(def.tc, def.getTypeParameters())); return Monotype.create(res); } void doResolve() { // Make sure the type is computed first removeChild(getSymbol()); getSymbol().doResolve(); super.doResolve(); addConstructorCallSymbol(); } void resolve() { super.resolve(); // Adding the constraint in the type scope. It can be useful for // the default values of the formal parameters // (e.g. an anonymous function refering to a type parameter). mlsub.typing.Constraint cst = getType().getConstraint(); if (mlsub.typing.Constraint.hasBinders(cst)) try { typeScope.addSymbols(cst.binders()); } catch (TypeScope.DuplicateName ex) { User.error(this, "Double declaration of the same type parameter"); } } protected gnu.expr.Expression computeCode() { int dummyArgs = method.arg_types.length - arity; return new QuoteExp(new InstantiateProc(method, dummyArgs)); } gnu.expr.Expression getConstructorInvocation(boolean omitDefaults) { int dummyArgs = method.arg_types.length - arity; Method calledMethod = omitDefaults ? getMethodUsingDefaults() : method; return new QuoteExp(new InitializeProc(calledMethod, false, dummyArgs)); } gnu.expr.Expression getInitializationCode(boolean implicitThis) { int dummyArgs = method.arg_types.length - arity; return new QuoteExp(new InitializeProc(method, implicitThis, dummyArgs)); } private Method method; /** Return the Method for this constructor with the optional parameters left out. */ private Method getMethodUsingDefaults() { Type[] fullArgTypes = method.arg_types; List argTypes = new LinkedList(); for (int i = 0; i < parameters.size; i++) { if (parameters.hasDefaultValue(i)) continue; argTypes.add(fullArgTypes[i]); } Type[] argTypesArray = (Type[]) argTypes.toArray (new Type[argTypes.size()]); return method.getDeclaringClass().getDeclaredMethod ("<init>", argTypesArray); } } --- NEW FILE: DefaultConstructor.java --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package bossa.syntax; import java.util.*; import bossa.util.*; import bossa.util.Location; import nice.tools.code.Gen; import mlsub.typing.*; import mlsub.typing.Constraint; import mlsub.typing.Monotype; import gnu.bytecode.*; import gnu.expr.*; import gnu.expr.Expression; /** A constructor automatically generated from the list of field of the class whose instances it constructs. @author Daniel Bonniot (bo...@us...) */ class DefaultConstructor extends Constructor { DefaultConstructor(NiceClass classe, NiceClass.Field[] fields, MethodDeclaration parent, Location location, FormalParameters formals, Constraint cst, Monotype[] parameters, Monotype returnType) { super(classe, true, location, formals, cst, parameters, returnType); this.fields = fields; this.parent = parent; addConstructorCallSymbol(); } private NiceClass.Field[] fields; private MethodDeclaration parent; gnu.expr.Expression getInitializationCode(boolean implicitThis) { getCode(); return initializeFromConstructor; } Expression getConstructorInvocation(boolean omitDefaults) { getCode(); return // lambdaOmitDefaults is null if the two versions are identical omitDefaults && initializeOmitDefaults != null ? initializeOmitDefaults : initialize; } /** Call the constructor, with all the arguments. */ private Expression initialize; /** Call the constructor, with all the arguments, with an implicit this argument. */ private Expression initializeFromConstructor; /** Call the constructor, with only non-default arguments. */ private Expression initializeOmitDefaults; /** Instantiate the class, calling the constructor with all the arguments. */ private Expression instantiate; protected Expression computeCode() { createBytecode(true); createBytecode(false); return instantiate; } /** @param omitDefaults if true, do not take the value of fields with default values as parameters, but use that default instead. */ private void createBytecode(boolean omitDefaults) { ClassType thisType = (ClassType) javaReturnType(); Declaration thisDecl = new Declaration("this"); thisDecl.setType(thisType); Expression thisExp = new ThisExp(thisDecl); MonoSymbol[] fullArgs = parameters.getMonoSymbols(); Type[] fullArgTypes = javaArgTypes(); List args = new LinkedList(); List argTypes = new LinkedList(); for (int i = 0; i < parameters.size; i++) { if (omitDefaults && parameters.hasDefaultValue(i)) continue; args.add(fullArgs[i]); argTypes.add(fullArgTypes[i]); } // Do not create a second constructor omiting defaults if there is // no default to omit! if (omitDefaults && args.size() == fullArgs.length) return; Type[] argTypesArray = (Type[]) argTypes.toArray(new Type[argTypes.size()]); MonoSymbol[] argsArray = (MonoSymbol[]) args.toArray(new MonoSymbol[args.size()]); if (classe.definition.inInterfaceFile()) throw new Error("Constructors are loaded from the compiled package"); ConstructorExp lambda = Gen.createConstructor (thisDecl, argTypesArray, argsArray); lambda.setSuperCall(callSuper(thisExp, fullArgs, omitDefaults)); Gen.setMethodBody(lambda, body(thisExp, fullArgs, omitDefaults)); classe.getClassExp().addMethod(lambda); // Add attributes useful for the nice compiler. These are not needed // for the version omitting defaults, since that one is only there for // Java users' sake. if (! omitDefaults) { lambda.addBytecodeAttribute(parameters.asBytecodeAttribute()); lambda.addBytecodeAttribute(new MiscAttr("default")); } if (omitDefaults) { initializeOmitDefaults = new QuoteExp(new InitializeProc(lambda)); } else { initialize = new QuoteExp(new InitializeProc(lambda)); initializeFromConstructor = new QuoteExp(new InitializeProc(lambda, true)); instantiate = new QuoteExp(new InstantiateProc(lambda)); } } private static gnu.expr.Expression objectConstructor = new gnu.expr.QuoteExp (new gnu.expr.InitializeProc (gnu.bytecode.Type.pointer_type.getDeclaredMethod("<init>", 0))); private Expression callSuper(Expression thisExp, MonoSymbol[] args, boolean omitDefaults) { int len = args.length - fields.length; List/*Expression*/ superArgs = new LinkedList(); superArgs.add(thisExp); for (int i = 0; i < len; i++) { if (! (omitDefaults && parameters.hasDefaultValue(i))) superArgs.add(args[i].compile()); } // A null parent means no parent class: call the Object constructor. Expression superExp = parent == null ? objectConstructor : parent.getConstructorInvocation(omitDefaults); return new ApplyExp(superExp, (Expression[]) superArgs.toArray(new Expression[superArgs.size()])); } private Expression body(Expression thisExp, MonoSymbol[] fullArgs, boolean omitDefaults) { int len = fields.length + classe.nbInitializers(); if (len == 0) return QuoteExp.voidExp; Expression[] body = new Expression[len]; final int superArgs = fullArgs.length - fields.length; for (int i = 0; i < fields.length; i++) { bossa.syntax.Expression value = fields[i].value; Expression fieldValue; if (!omitDefaults || value == null) // Use the provided parameter. fieldValue = fullArgs[superArgs + i].compile(); else // Use the default value. fieldValue = value.compile(); body[i] = fields[i].method.compileAssign(thisExp, fieldValue); } classe.setThisExp(thisExp); for (int i = 0; i < classe.nbInitializers(); i++) body[fields.length + i] = classe.compileInitializer(i); return new BeginExp(body); } } |
From: Daniel B. <bo...@us...> - 2004-10-07 15:30:08
|
Update of /cvsroot/nice/Nice/src/bossa/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9115/src/bossa/modules Modified Files: Package.java Log Message: Reworked the hierarchy of classes representing constructors. bossa.syntax.Constructor is now a super-class for DefaultConstructor (default constructor in source packages) and ImportedConstructor (constructor imported from a compiled package, default or not). This allows to factor handling of default constructors, and in particular to provide the specialized error messages for imported default constructors. Index: Package.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/Package.java,v retrieving revision 1.120 retrieving revision 1.121 diff -C2 -d -r1.120 -r1.121 *** Package.java 10 Aug 2004 17:22:19 -0000 1.120 --- Package.java 7 Oct 2004 15:29:31 -0000 1.121 *************** *** 630,634 **** method = method.getNext()) { ! Definition d = CustomConstructor.load(def, method); if (d != null) definitions.add(d); --- 630,634 ---- method = method.getNext()) { ! Definition d = ImportedConstructor.load(def, method); if (d != null) definitions.add(d); |
From: Daniel B. <bo...@us...> - 2004-10-07 14:55:32
|
Update of /cvsroot/nice/Nice/src/gnu/bytecode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1901/src/gnu/bytecode Modified Files: MiscAttr.java Log Message: Easier creation of attributes with no value. Index: MiscAttr.java =================================================================== RCS file: /cvsroot/nice/Nice/src/gnu/bytecode/MiscAttr.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MiscAttr.java 3 Nov 2003 15:42:53 -0000 1.2 --- MiscAttr.java 7 Oct 2004 14:54:34 -0000 1.3 *************** *** 22,38 **** this.length = length; } ! public MiscAttr(String name, byte[] data) { this(name, data, 0, data.length); } ! ! public static Attribute synthetic() { ! return new MiscAttr("Synthetic", nobytes); } private static final byte[] nobytes = new byte[0]; public int getLength() { return length; } --- 22,43 ---- this.length = length; } ! public MiscAttr(String name, byte[] data) { this(name, data, 0, data.length); } ! ! public MiscAttr(String name) { ! this(name, nobytes, 0, 0); } private static final byte[] nobytes = new byte[0]; + public static Attribute synthetic() + { + return new MiscAttr("Synthetic"); + } + public int getLength() { return length; } |
From: Daniel B. <bo...@us...> - 2004-10-07 09:42:13
|
Update of /cvsroot/nice/Nice In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30203 Modified Files: Makefile Log Message: Updated the location of ant.jar, and simplified the ant classpath finding code. Index: Makefile =================================================================== RCS file: /cvsroot/nice/Nice/Makefile,v retrieving revision 1.153 retrieving revision 1.154 diff -C2 -d -r1.153 -r1.154 *** Makefile 20 Sep 2004 11:07:48 -0000 1.153 --- Makefile 7 Oct 2004 09:41:51 -0000 1.154 *************** *** 13,24 **** # ANT classpath; we will use NICE_ANTJAR or ANT_HOME (in that order) # if present, otherwise try good default ! ANT_CLASSPATH= ${shell if [ "z${NICE_ANTJAR}" != "z" ] ; \ ! then echo "${NICE_ANTJAR}"; \ ! elif [ "z${ANT_HOME}" != "z" ] ; \ ! then echo "${ANT_HOME}/lib/ant.jar"; \ ! else if [ "z${CLASSPATH}" != "z" ]; \ ! then echo "/usr/share/java/ant.jar:./external/ant.jar:${CLASSPATH}"; \ ! else echo "/usr/share/java/ant.jar:./external/ant.jar:"; \ ! fi \ fi } --- 13,22 ---- # ANT classpath; we will use NICE_ANTJAR or ANT_HOME (in that order) # if present, otherwise try good default ! ANT_CLASSPATH= ${shell if [ -n "${NICE_ANTJAR}" ] ; \ ! then echo "${NICE_ANTJAR}"; \ ! elif [ -n "${ANT_HOME}" ] ; \ ! then echo "${ANT_HOME}/lib/ant.jar"; \ ! else \ ! echo "/usr/share/ant/lib/ant.jar:./external/ant.jar:${CLASSPATH}"; \ fi } |
From: Daniel B. <bo...@us...> - 2004-10-07 02:18:42
|
Update of /cvsroot/nice/Nice/regtest/coreJava In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30462/regtest/coreJava Modified Files: coreJava.code Log Message: Reenable '0f' syntax for single precision zero floating point number. Index: coreJava.code =================================================================== RCS file: /cvsroot/nice/Nice/regtest/coreJava/coreJava.code,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** coreJava.code 24 Nov 2003 13:20:44 -0000 1.29 --- coreJava.code 6 Oct 2004 16:14:02 -0000 1.30 *************** *** 89,95 **** // floats float x = 0.1f; double y = 3.4; p("0.1 - 3.4 = " + (x-y)); ! p("" + (i+(j-y)*x)); --- 89,96 ---- // floats float x = 0.1f; + x += 0f; double y = 3.4; p("0.1 - 3.4 = " + (x-y)); ! p("" + (i+(j-y)*x)); |
From: Daniel B. <bo...@us...> - 2004-10-06 13:25:56
|
Update of /cvsroot/nice/Nice In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20620 Modified Files: NEWS Log Message: Opened 0.9.10 Index: NEWS =================================================================== RCS file: /cvsroot/nice/Nice/NEWS,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** NEWS 21 Sep 2004 23:59:03 -0000 1.50 --- NEWS 6 Oct 2004 13:23:58 -0000 1.51 *************** *** 1,2 **** --- 1,8 ---- + nice (0.9.10) + + * + + -- + nice (0.9.9) |
From: Daniel B. <bo...@us...> - 2004-10-06 10:59:58
|
Update of /cvsroot/nice/Nice/web/images In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19406/images Added Files: eclipse.png Log Message: Added eclipse logo in CVS --- NEW FILE: eclipse.png --- (This appears to be a binary file; contents omitted.) |
From: Daniel B. <bo...@us...> - 2004-10-06 10:53:34
|
Update of /cvsroot/nice/Nice/web In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18561/web Modified Files: irc.xml Log Message: Do not rely on an external logo for freenode, and properly set the image size. Index: irc.xml =================================================================== RCS file: /cvsroot/nice/Nice/web/irc.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** irc.xml 12 Nov 2003 17:52:00 -0000 1.4 --- irc.xml 6 Oct 2004 10:53:24 -0000 1.5 *************** *** 44,49 **** This service is provided by <ulink url="http://www.freenode.net"> <inlinemediaobject><imageobject> ! <imagedata fileref="http://irc.wearlab.de/images/freenode_logo.jpg" ! width="237px" depth="68px" align="center" /> </imageobject></inlinemediaobject> </ulink> --- 44,49 ---- This service is provided by <ulink url="http://www.freenode.net"> <inlinemediaobject><imageobject> ! <imagedata fileref="images/freenode.png" ! contentwidth="117px" contentdepth="32px" align="center" /> </imageobject></inlinemediaobject> </ulink> |
From: Daniel B. <bo...@us...> - 2004-10-06 10:53:33
|
Update of /cvsroot/nice/Nice/web/images In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18561/web/images Added Files: freenode.png Log Message: Do not rely on an external logo for freenode, and properly set the image size. --- NEW FILE: freenode.png --- (This appears to be a binary file; contents omitted.) |
From: Daniel B. <bo...@us...> - 2004-10-06 09:38:22
|
Update of /cvsroot/nice/Nice/src/nice/tools/repository In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2837/src/nice/tools/repository Modified Files: main.nice Log Message: Do not fail when the URL does not contain a repository part. Index: main.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/repository/main.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** main.nice 14 Sep 2004 16:00:31 -0000 1.2 --- main.nice 6 Oct 2004 09:38:00 -0000 1.3 *************** *** 67,71 **** openConnection(URL url) { ! (URL repo, String resource, ?String ver) = parseRepoURL(url); let pkg = getPackage(resource); --- 67,74 ---- openConnection(URL url) { ! (?URL repo, String resource, ?String ver) = parseRepoURL(url); ! if (repo == null) ! return null; ! let pkg = getPackage(resource); *************** *** 89,96 **** } ! (URL,String,?String) parseRepoURL(URL url) { String s = url.toString(); int sep = s.indexOf('!'); URL repo = new URL(s.substring(0, sep)); int pver = s.indexOf('#', sep); --- 92,103 ---- } ! (?URL,String,?String) parseRepoURL(URL url) { String s = url.toString(); int sep = s.indexOf('!'); + if (sep == -1) + // This is not a valid URL inside a repository + return (null, "", null); + URL repo = new URL(s.substring(0, sep)); int pver = s.indexOf('#', sep); |
From: Daniel B. <bo...@us...> - 2004-10-06 08:23:42
|
Update of /cvsroot/nice/Nice/testsuite/compiler/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19915/testsuite/compiler/syntax Modified Files: expressions.testsuite Log Message: Testcase for parsing bug fixed by Bryn on 22 Sep 2004 21:10:48 -0000 (Parser.jj rev 1.266) Index: expressions.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/syntax/expressions.testsuite,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** expressions.testsuite 2 Sep 2004 18:23:27 -0000 1.8 --- expressions.testsuite 6 Oct 2004 08:23:28 -0000 1.9 *************** *** 28,29 **** --- 28,35 ---- assert 0.000_012 == 0.000012; assert 1_000.000_1d == 1000.0001d; + + /// PASS + let a = new A(_b: 0); + let x = a._b; + /// Toplevel + class A { int _b; } |
From: Bryn K. <xo...@us...> - 2004-09-22 21:10:59
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4907/src/bossa/parser Modified Files: Parser.jj Log Message: Allowing underscores in floating point numbers broke tokenizing of dotted identifiers with leading underscores in the trailing parts, such as "foo._bar". Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.265 retrieving revision 1.266 diff -C2 -d -r1.265 -r1.266 *** Parser.jj 17 Sep 2004 10:57:56 -0000 1.265 --- Parser.jj 22 Sep 2004 21:10:48 -0000 1.266 *************** *** 18,21 **** --- 18,23 ---- JAVA_UNICODE_ESCAPE = true; DEBUG_LOOKAHEAD = false; + DEBUG_PARSER = false; + DEBUG_TOKEN_MANAGER = false; STATIC = false; } *************** *** 275,279 **** < FLOATING_POINT_LITERAL: ["0"-"9"] (["0"-"9", "_"])* "." (["0"-"9", "_"])+ (<EXPONENT>)? (["f","F","d","D"])? ! | "." (["0"-"9", "_"])+ (<EXPONENT>)? (["f","F","d","D"])? | ["1"-"9"] (["0"-"9", "_"])* <EXPONENT> (["f","F","d","D"])? | ["1"-"9"] (["0"-"9", "_"])* (<EXPONENT>)? ["f","F","d","D"] --- 277,281 ---- < FLOATING_POINT_LITERAL: ["0"-"9"] (["0"-"9", "_"])* "." (["0"-"9", "_"])+ (<EXPONENT>)? (["f","F","d","D"])? ! | "." ["0"-"9"] (["0"-"9", "_"])* (<EXPONENT>)? (["f","F","d","D"])? | ["1"-"9"] (["0"-"9", "_"])* <EXPONENT> (["f","F","d","D"])? | ["1"-"9"] (["0"-"9", "_"])* (<EXPONENT>)? ["f","F","d","D"] |
From: Daniel B. <bo...@us...> - 2004-09-22 09:46:08
|
Update of /cvsroot/nice/Nice/web In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14976 Modified Files: .htaccess Log Message: Released 0.9.9 Index: .htaccess =================================================================== RCS file: /cvsroot/nice/Nice/web/.htaccess,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** .htaccess 30 Jun 2004 11:58:30 -0000 1.19 --- .htaccess 22 Sep 2004 09:45:58 -0000 1.20 *************** *** 1,6 **** Redirect /Wiki http://nice.sourceforge.net/cgi-bin/twiki/view ! Redirect /Nice.tar http://prdownloads.sourceforge.net/nice/Nice-0.9.8-unix.tar.gz ! Redirect /Nice-source.tar.gz http://prdownloads.sourceforge.net/nice/Nice-0.9.8-source.tar.gz ! Redirect /Nice.zip http://prdownloads.sourceforge.net/nice/Nice-0.9.8-windows.zip ! Redirect /nice.deb http://prdownloads.sourceforge.net/nice/nice_0.9.8-1_all.deb ! Redirect /nice.rpm http://prdownloads.sourceforge.net/nice/Nice-0.9.8-1.noarch.rpm --- 1,6 ---- Redirect /Wiki http://nice.sourceforge.net/cgi-bin/twiki/view ! Redirect /Nice.tar http://prdownloads.sourceforge.net/nice/Nice-0.9.9-unix.tar.gz ! Redirect /Nice-source.tar.gz http://prdownloads.sourceforge.net/nice/Nice-0.9.9-source.tar.gz ! Redirect /Nice.zip http://prdownloads.sourceforge.net/nice/Nice-0.9.9-windows.zip ! Redirect /nice.deb http://prdownloads.sourceforge.net/nice/nice_0.9.9-1_all.deb ! Redirect /nice.rpm http://prdownloads.sourceforge.net/nice/Nice-0.9.9-1.noarch.rpm |
From: Daniel B. <bo...@us...> - 2004-09-22 09:42:03
|
Update of /cvsroot/nice/Nice/web In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14135 Modified Files: install.xml Log Message: Update info for Unix: use .tar.gz instead of .tar Index: install.xml =================================================================== RCS file: /cvsroot/nice/Nice/web/install.xml,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** install.xml 9 Mar 2004 10:40:35 -0000 1.13 --- install.xml 22 Sep 2004 09:41:53 -0000 1.14 *************** *** 124,129 **** <section id="unix"><title>Unix</title> <para> ! Download the <ulink url="Nice.tar">Nice.tar</ulink> file and ! save it as <literal>/tmp/Nice.tar</literal>. </para> --- 124,129 ---- <section id="unix"><title>Unix</title> <para> ! Download the <ulink url="Nice.tar">Nice.tar.gz</ulink> file and ! save it as <literal>/tmp/Nice.tar.gz</literal>. </para> *************** *** 135,139 **** <programlisting> cd /usr/local ! tar xf /tmp/Nice.tar </programlisting> </para> --- 135,139 ---- <programlisting> cd /usr/local ! tar zxf /tmp/Nice.tar.gz </programlisting> </para> *************** *** 147,151 **** <programlisting> cd ! tar xf /tmp/Nice.tar </programlisting> The &nice; tools are placed in the <literal>bin</literal> subdirectory. --- 147,151 ---- <programlisting> cd ! tar zxf /tmp/Nice.tar.gz </programlisting> The &nice; tools are placed in the <literal>bin</literal> subdirectory. |
From: Daniel B. <bo...@us...> - 2004-09-21 23:59:18
|
Update of /cvsroot/nice/Nice In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28134 Modified Files: NEWS Log Message: Mentioned improvements in nicedoc. Index: NEWS =================================================================== RCS file: /cvsroot/nice/Nice/NEWS,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** NEWS 13 Sep 2004 22:09:24 -0000 1.49 --- NEWS 21 Sep 2004 23:59:03 -0000 1.50 *************** *** 23,26 **** --- 23,27 ---- * Improved speed of coverage tests for some methods. + * Much improved nicedoc tool. * Removed the '--strict' compiler option. * Underscores are allowed and ignored in literal numbers. example: *************** *** 48,52 **** reflect this. ! -- Sat, 4 Sep 2004 21:10:36 +0200 nice (0.9.8) --- 49,53 ---- reflect this. ! -- Wed, 22 Sep 2004 01:53:29 +0200 nice (0.9.8) |
From: Francis B. <fb...@us...> - 2004-09-21 14:44:17
|
Update of /cvsroot/nice/Nice/src/nice/tools/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5358/src/nice/tools/doc Modified Files: htmlwriter.nice Log Message: Added <h1> headings to the package index pages. Index: htmlwriter.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/doc/htmlwriter.nice,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** htmlwriter.nice 21 Sep 2004 14:11:27 -0000 1.22 --- htmlwriter.nice 21 Sep 2004 14:44:08 -0000 1.23 *************** *** 234,237 **** --- 234,240 ---- writer.write(getHeader("Package " + p.getName(), javascript + css)); + + //write a heading + writer.write("<h1>Package " htmlEncode(p.getName()) "</h1>\n"); //create a list of source files in the package *************** *** 298,301 **** --- 301,307 ---- (new FileWriter(new File(dir, "package-index.html"))); writer.write(getHeader("Package " + p.getName())); + + //write a heading + writer.write("<h1>Package " htmlEncode(p.getName()) "</h1>\n"); //we need to separate class, methods, and global variables |