nice-commit Mailing List for The Nice Programming Language (Page 24)
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: Daniel B. <bo...@us...> - 2005-01-12 17:12:57
|
Update of /cvsroot/nice/Nice/testsuite/compiler/native In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10593/testsuite/compiler/native Added Files: visibility.nice Log Message: Catch VerificationError (fixes #1100900). --- NEW FILE: visibility.nice --- /// FAIL java.net.Inet4Address ip = new java.net.Inet4Address(); |
From: Daniel B. <bo...@us...> - 2005-01-12 17:12:57
|
Update of /cvsroot/nice/Nice/src/gnu/expr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10593/src/gnu/expr Modified Files: ApplyExp.java Log Message: Catch VerificationError (fixes #1100900). Index: ApplyExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/gnu/expr/ApplyExp.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ApplyExp.java 9 Oct 2004 09:28:41 -0000 1.11 --- ApplyExp.java 12 Jan 2005 17:12:45 -0000 1.12 *************** *** 108,112 **** public void compile (Compilation comp, Target target) { ! compile(this, comp, target, true); } --- 108,118 ---- public void compile (Compilation comp, Target target) { ! try { ! compile(this, comp, target, true); ! } ! catch (VerificationError e) { ! throw bossa.util.User.error(bossa.util.Location.make(this), ! e.getMessage()); ! } } |
From: Daniel B. <bo...@us...> - 2005-01-12 16:07:07
|
Update of /cvsroot/nice/Nice/src/nice/tools/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28174/src/nice/tools/doc Modified Files: htmlwriter.nice Log Message: Use String.valueOf instead of toString on now non-null value. Index: htmlwriter.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/doc/htmlwriter.nice,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** htmlwriter.nice 26 Nov 2004 14:54:56 -0000 1.27 --- htmlwriter.nice 12 Jan 2005 16:06:55 -0000 1.28 *************** *** 331,335 **** for(MethodDeclaration m : methods) { writer.write("<li><a href='" escapeFilename(getMethodFilename(m)) ".html'>" htmlEncode(m.getName()) "</a>" + ! ": " htmlEncode(m.getType().toString()) "</li>\n"); } writer.write("</ul>\n"); --- 331,335 ---- for(MethodDeclaration m : methods) { writer.write("<li><a href='" escapeFilename(getMethodFilename(m)) ".html'>" htmlEncode(m.getName()) "</a>" + ! ": " htmlEncode(String.valueOf(m.getType())) "</li>\n"); } writer.write("</ul>\n"); *************** *** 429,433 **** */ String getMethodFilename(MethodDeclaration md) { ! return md.getName().toString() + md.getType().toString().hashCode(); } --- 429,433 ---- */ String getMethodFilename(MethodDeclaration md) { ! return md.getName().toString() + String.valueOf(md.getType()).hashCode(); } *************** *** 503,507 **** for(MethodDeclaration m : methods) { buffer.append(" <li><a href='" escapeFilename(getMethodFilename(m)) ".html'>" htmlEncode(m.getName()) "</a>" + ! ": " htmlEncode(m.getType().toString()) "</li>\n"); } buffer.append(" </ul>\n"); --- 503,507 ---- for(MethodDeclaration m : methods) { buffer.append(" <li><a href='" escapeFilename(getMethodFilename(m)) ".html'>" htmlEncode(m.getName()) "</a>" + ! ": " htmlEncode(String.valueOf(m.getType())) "</li>\n"); } buffer.append(" </ul>\n"); |
From: Arjan B. <ar...@us...> - 2005-01-11 21:46:14
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9083/F:/nice/src/bossa/syntax Modified Files: contract.nice customConstructor.nice enum.nice formalParameters.nice funexp.nice globalvar.nice locals.nice methodImplementation.nice methodbody.nice niceMethod.nice niceclass.nice symbol.nice tools.nice try.nice typecheck.nice Removed Files: MonoSymbol.java Log Message: Converted MonoSymbol. Index: customConstructor.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/customConstructor.nice,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** customConstructor.nice 10 Jan 2005 23:58:04 -0000 1.11 --- customConstructor.nice 11 Jan 2005 21:45:46 -0000 1.12 *************** *** 100,104 **** let lambda = nice.tools.code.Gen.createCustomConstructor ! (cast(this.javaReturnType()), this.javaArgTypes(), this.getSymbols()); nice.tools.code.Gen.setMethodBody(lambda, body.generateCode()); --- 100,104 ---- let lambda = nice.tools.code.Gen.createCustomConstructor ! (cast(this.javaReturnType()), this.javaArgTypes(), cast(this.getSymbols())); nice.tools.code.Gen.setMethodBody(lambda, body.generateCode()); Index: methodbody.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/methodbody.nice,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** methodbody.nice 3 Jan 2005 01:24:28 -0000 1.9 --- methodbody.nice 11 Jan 2005 21:45:46 -0000 1.10 *************** *** 364,368 **** // Introduce the types of the arguments ! mlsub.typing.Monotype[] monotypes = MonoSymbol.getMonotype(parameters); for (int n = 0; n < formals.length; n++) --- 364,369 ---- // Introduce the types of the arguments ! mlsub.typing.Monotype[] monotypes = notNull(parameters).mapToArray( ! MonoSymbol sym => notNull(sym.getMonotype())); for (int n = 0; n < formals.length; n++) --- MonoSymbol.java DELETED --- Index: funexp.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/funexp.nice,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** funexp.nice 30 Dec 2004 20:58:37 -0000 1.4 --- funexp.nice 11 Jan 2005 21:45:46 -0000 1.5 *************** *** 97,101 **** throw User.error(this, "Missing return statement"); ! mlsub.typing.Monotype t = new mlsub.typing.FunType(MonoSymbol.getMonotype(formals), notNull(_inferredReturnType).getMonotype()); type = new mlsub.typing.Polytype --- 97,101 ---- throw User.error(this, "Missing return statement"); ! mlsub.typing.Monotype t = new mlsub.typing.FunType(getMonotypes(formals), notNull(_inferredReturnType).getMonotype()); type = new mlsub.typing.Polytype *************** *** 118,124 **** gnu.expr.LambdaExp res = nice.tools.code.Gen.createMethod (null, ! nice.tools.code.Types.javaType(MonoSymbol.getMonotype(formals)), nice.tools.code.Types.javaType(this.inferredReturnType()), ! formals, false); nice.tools.code.Gen.setMethodBody(res, body.generateCode()); return res; --- 118,124 ---- gnu.expr.LambdaExp res = nice.tools.code.Gen.createMethod (null, ! nice.tools.code.Types.javaType(getMonotypes(formals)), nice.tools.code.Types.javaType(this.inferredReturnType()), ! cast(formals), false); nice.tools.code.Gen.setMethodBody(res, body.generateCode()); return res; Index: enum.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/enum.nice,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** enum.nice 31 Dec 2004 18:40:45 -0000 1.10 --- enum.nice 11 Jan 2005 21:45:46 -0000 1.11 *************** *** 183,187 **** args.add(new Arguments.Argument(argExps[i], fields[i].getName())); ! return new EnumSymbol(name, type, definition: def, value: createNewExp(new TypeIdent(name: enumName), new Arguments(args))); } --- 183,187 ---- args.add(new Arguments.Argument(argExps[i], fields[i].getName())); ! return new EnumSymbol(name, syntacticType: type, definition: def, value: createNewExp(new TypeIdent(name: enumName), new Arguments(args))); } Index: contract.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/contract.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** contract.nice 1 Jan 2005 14:38:03 -0000 1.1 --- contract.nice 11 Jan 2005 21:45:46 -0000 1.2 *************** *** 69,73 **** if (! nice.tools.typing.Types.isVoid(resultType)) result = new ResultMonoSymbol(new LocatedString("result", location), ! resultType); try { --- 69,73 ---- if (! nice.tools.typing.Types.isVoid(resultType)) result = new ResultMonoSymbol(new LocatedString("result", location), ! type: resultType); try { Index: niceclass.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/niceclass.nice,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** niceclass.nice 5 Jan 2005 02:02:44 -0000 1.14 --- niceclass.nice 11 Jan 2005 21:45:46 -0000 1.15 *************** *** 237,241 **** Monotype.sure(new mlsub.typing.MonotypeConstructor(definition.getTC(), definition.getTypeParameters())); ! thisSymbol = new ThisSymbol(thisName, thisType, declaringClass: this); Node.thisExp = createSymbolExp(notNull(thisSymbol), definition.location()); --- 237,241 ---- Monotype.sure(new mlsub.typing.MonotypeConstructor(definition.getTC(), definition.getTypeParameters())); ! thisSymbol = new ThisSymbol(thisName, type: thisType, declaringClass: this); Node.thisExp = createSymbolExp(notNull(thisSymbol), definition.location()); Index: locals.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/locals.nice,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** locals.nice 10 Jan 2005 23:58:04 -0000 1.5 --- locals.nice 11 Jan 2005 21:45:46 -0000 1.6 *************** *** 151,155 **** public new LocalVariable(LocatedString name, ?Monotype type, boolean constant, ?Expression value) { ! this(value: value, left:new LocalVariableSymbol(name, type, constant: constant)); } --- 151,155 ---- public new LocalVariable(LocatedString name, ?Monotype type, boolean constant, ?Expression value) { ! this(value: value, left:new LocalVariableSymbol(name, syntacticType: type, constant: constant)); } *************** *** 182,186 **** { ?Monotype t = null; ! this(value: value, left: new LocalConstantSymbol(name,t)); } --- 182,186 ---- { ?Monotype t = null; ! this(value: value, left: new LocalConstantSymbol(name, syntacticType: t)); } Index: typecheck.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typecheck.nice,v retrieving revision 1.120 retrieving revision 1.121 diff -C2 -d -r1.120 -r1.121 *** typecheck.nice 1 Jan 2005 16:36:31 -0000 1.120 --- typecheck.nice 11 Jan 2005 21:45:46 -0000 1.121 *************** *** 488,492 **** { (MonoSymbol variable, mlsub.typing.Monotype type) = conditionalTypes[i]; ! replaced.add((variable, variable.type)); variable.type = type; } --- 488,492 ---- { (MonoSymbol variable, mlsub.typing.Monotype type) = conditionalTypes[i]; ! replaced.add((variable, notNull(variable.type))); variable.type = type; } *************** *** 713,717 **** reportNullAssignmentError(decl, t, value: value, target.name.toString(), ! target.getMonotype()); throw assignmentError(target, target.name.toString(), String.valueOf(target.getMonotype), --- 713,717 ---- reportNullAssignmentError(decl, t, value: value, target.name.toString(), ! notNull(target.getMonotype())); throw assignmentError(target, target.name.toString(), String.valueOf(target.getMonotype), *************** *** 789,793 **** reportNullAssignmentError(decl, t, value: value, target.name.toString(), ! target.getMonotype()); throw assignmentError(target, target.name.toString(), String.valueOf(target.getMonotype), --- 789,793 ---- reportNullAssignmentError(decl, t, value: value, target.name.toString(), ! notNull(target.getMonotype())); throw assignmentError(target, target.name.toString(), String.valueOf(target.getMonotype), *************** *** 852,857 **** variables.foreach (MonoSymbol variable => setVarType(variable, ! now: makeSure(variable.type), ! out: variable.type)); ?List<(MonoSymbol, mlsub.typing.Monotype)> instanceofIfTrue = --- 852,857 ---- variables.foreach (MonoSymbol variable => setVarType(variable, ! now: makeSure(notNull(variable.type)), ! out: notNull(variable.type))); ?List<(MonoSymbol, mlsub.typing.Monotype)> instanceofIfTrue = Index: niceMethod.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/niceMethod.nice,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** niceMethod.nice 10 Jan 2005 23:58:04 -0000 1.10 --- niceMethod.nice 11 Jan 2005 21:45:46 -0000 1.11 *************** *** 373,377 **** res = nice.tools.code.Gen.createMethod ! (name, argTypes, retType, def.getSymbols(), true, receiver != null); res.parameterCopies = cast(notNull(def.formalParameters()).getParameterCopies()); --- 373,377 ---- res = nice.tools.code.Gen.createMethod ! (name, argTypes, retType, cast(def.getSymbols()), true, receiver != null); res.parameterCopies = cast(notNull(def.formalParameters()).getParameterCopies()); Index: methodImplementation.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/methodImplementation.nice,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** methodImplementation.nice 4 Jan 2005 21:20:39 -0000 1.7 --- methodImplementation.nice 11 Jan 2005 21:45:46 -0000 1.8 *************** *** 83,87 **** LocatedString argName = p.getName() != null ? notNull(p.getName()) : new LocatedString("argument_"+tn, bossa.util.Location.nowhere()); ! res[tn] = new MonoSymbol(argName, type); } notNull(scope).addSymbols(res); --- 83,87 ---- LocatedString argName = p.getName() != null ? notNull(p.getName()) : new LocatedString("argument_"+tn, bossa.util.Location.nowhere()); ! res[tn] = new MonoSymbol(argName, type: type); } notNull(scope).addSymbols(res); *************** *** 170,174 **** this.javaArgTypes(), notNull(declaration).javaReturnType(), ! parameters, true, false); --- 170,174 ---- this.javaArgTypes(), notNull(declaration).javaReturnType(), ! cast(parameters), true, false); Index: formalParameters.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/formalParameters.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** formalParameters.nice 3 Jan 2005 01:24:28 -0000 1.1 --- formalParameters.nice 11 Jan 2005 21:45:46 -0000 1.2 *************** *** 353,357 **** ParameterSymbol getSymbol() { ! symbol = new ParameterSymbol(this.getName(), type); return notNull(symbol); } --- 353,357 ---- ParameterSymbol getSymbol() { ! symbol = new ParameterSymbol(this.getName(), syntacticType: type); return notNull(symbol); } Index: symbol.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/symbol.nice,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** symbol.nice 10 Jan 2005 20:04:43 -0000 1.6 --- symbol.nice 11 Jan 2005 21:45:46 -0000 1.7 *************** *** 13,16 **** --- 13,127 ---- package bossa.syntax; + + /** + A variable symbol which has a monotype (eg a function parameter) + + @see PolySymbol + */ + public class MonoSymbol extends VarSymbol + { + ?Monotype syntacticType = null; + ?mlsub.typing.Monotype type = null; + + boolean captured = false; + + /** The depth of nested block at which this variable is defined. */ + int depth = 0; + + boolean used = false; + + /* public MonoSymbol(LocatedString name, Monotype type) + { + super(name); + this.syntacticType=type; + } + + public MonoSymbol(LocatedString name, mlsub.typing.Monotype type) + { + super(name); + this.type = type; + } + */ + getType() = new mlsub.typing.Polytype(type); + + public ?mlsub.typing.Monotype getMonotype() + { + return type; + } + + resolve() + { + type = notNull(syntacticType).resolve(typeScope); + syntacticType = null; + + if (nice.tools.typing.Types.isVoid(type)) + throw User.error(name, "A variable cannot have a void type"); + } + + /** + @return + 0 : doesn't match + 1 : wasn't even a function + 2 : matches + */ + match(arguments) + { + let k = nice.tools.typing.Types.rawType(type).getKind(); + if (k instanceof FunTypeKind) + if (!notNull(arguments).plainApplication(k.domainArity, this)) + return 0; + else + return 2; + else + return 1; + } + + explainWhyMatchFails(arguments) + { + let k = nice.tools.typing.Types.rawType(type).getKind(); + if (k instanceof FunTypeKind) + { + int arity = k.domainArity; + if (notNull(arguments).size() != arity) + return name + Util.has(arity, "parameter", notNull(arguments).size()); + else + // If the number of arguments is correct, it must be that + // some arguments are named. + return name + " does not have named parameters"; + } + else + return name + " is not a function"; + } + + // explained in OverloadedSymbolExp + makeClonedType() {} + releaseClonedType() {} + getClonedType() = this.getType(); + + toString() + { + if (type == null) + return notNull(syntacticType) + " " + name; + + return notNull(type) + " " + name; + } + } + + public MonoSymbol createMonoSymbol(LocatedString name, Monotype type) + { + return new MonoSymbol(name, syntacticType: type); + } + + /** + Maps getMonotype over an array of MonoSymbols. + */ + mlsub.typing.Monotype[?] getMonotypes(MonoSymbol[?] symbols) + { + if (symbols == null) + return null; + + return symbols.mapToArray(MonoSymbol sym => notNull(sym.getMonotype())); + } + /** A variable symbol which has a polytype (eg a method symbol) Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.93 retrieving revision 1.94 diff -C2 -d -r1.93 -r1.94 *** tools.nice 10 Jan 2005 23:58:04 -0000 1.93 --- tools.nice 11 Jan 2005 21:45:46 -0000 1.94 *************** *** 203,207 **** mlsub.typing.Polytype getType(Expression) = native mlsub.typing.Polytype Expression.getType(); - mlsub.typing.Monotype type(MonoSymbol) = native MonoSymbol.type; GlobalTypeScope getGlobalTypeScope() = native GlobalTypeScope Node.getGlobalTypeScope(); ?gnu.bytecode.ClassType staticClass(Arguments) = native gnu.bytecode.ClassType Arguments.staticClass(); --- 203,206 ---- Index: globalvar.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/globalvar.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** globalvar.nice 26 Nov 2004 20:26:02 -0000 1.2 --- globalvar.nice 11 Jan 2005 21:45:46 -0000 1.3 *************** *** 97,101 **** let res = new GlobalVarDeclaration(name, Node.global, left: cast(null), value: value, constant: constant); ! res.left = new GlobalVarSymbol(name, type, definition: res); res.addChild(res.left); return res; --- 97,101 ---- let res = new GlobalVarDeclaration(name, Node.global, left: cast(null), value: value, constant: constant); ! res.left = new GlobalVarSymbol(name, syntacticType: type, definition: res); res.addChild(res.left); return res; Index: try.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/try.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** try.nice 16 Dec 2004 16:21:07 -0000 1.3 --- try.nice 11 Jan 2005 21:45:46 -0000 1.4 *************** *** 104,108 **** type.nullness = Monotype.sure; ! this(exnVar: new MonoSymbol(varName, type), tc: tc, typeLocation: tc.location, varName: varName, body: body); } \ No newline at end of file --- 104,108 ---- type.nullness = Monotype.sure; ! this(exnVar: new MonoSymbol(varName, syntacticType: type), tc: tc, typeLocation: tc.location, varName: varName, body: body); } \ No newline at end of file |
From: Arjan B. <ar...@us...> - 2005-01-11 21:45:57
|
Update of /cvsroot/nice/Nice/src/nice/tools/code In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9083/F:/nice/src/nice/tools/code Modified Files: Gen.java Log Message: Converted MonoSymbol. Index: Gen.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/code/Gen.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Gen.java 9 Oct 2004 09:28:40 -0000 1.21 --- Gen.java 11 Jan 2005 21:45:46 -0000 1.22 *************** *** 15,19 **** import gnu.bytecode.*; import gnu.expr.*; ! import bossa.syntax.MonoSymbol; /** --- 15,20 ---- import gnu.bytecode.*; import gnu.expr.*; ! //import bossa.syntax.MonoSymbol; ! import bossa.syntax.VarSymbol; /** *************** *** 97,101 **** Type[] argTypes, Type retType, ! MonoSymbol[] args) { return createMethod(bytecodeName, argTypes, retType, args, true, false); --- 98,102 ---- Type[] argTypes, Type retType, ! /*MonoSymbol*/VarSymbol[] args) { return createMethod(bytecodeName, argTypes, retType, args, true, false); *************** *** 110,114 **** Type[] argTypes, Type retType, ! MonoSymbol[] args, boolean toplevel) { --- 111,115 ---- Type[] argTypes, Type retType, ! /*MonoSymbol*/VarSymbol[] args, boolean toplevel) { *************** *** 129,133 **** Type[] argTypes, Type retType, ! MonoSymbol[] args, boolean toplevel, boolean member) --- 130,134 ---- Type[] argTypes, Type retType, ! /*MonoSymbol*/VarSymbol[] args, boolean toplevel, boolean member) *************** *** 139,143 **** public static ConstructorExp createConstructor ! (Declaration thisDecl, Type[] argTypes, MonoSymbol[] args) { ConstructorExp res = new ConstructorExp(thisDecl); --- 140,144 ---- public static ConstructorExp createConstructor ! (Declaration thisDecl, Type[] argTypes, /*MonoSymbol*/VarSymbol[] args) { ConstructorExp res = new ConstructorExp(thisDecl); *************** *** 148,152 **** public static ConstructorExp createCustomConstructor ! (ClassType classType, Type[] argTypes, MonoSymbol[] args) { ConstructorExp res = new ConstructorExp(classType); --- 149,153 ---- public static ConstructorExp createCustomConstructor ! (ClassType classType, Type[] argTypes, /*MonoSymbol*/VarSymbol[] args) { ConstructorExp res = new ConstructorExp(classType); *************** *** 171,175 **** Type[] argTypes, Type retType, ! MonoSymbol[] args, boolean toplevel, boolean member, --- 172,176 ---- Type[] argTypes, Type retType, ! /*MonoSymbol*/VarSymbol[] args, boolean toplevel, boolean member, |
From: Arjan B. <ar...@us...> - 2005-01-11 21:45:55
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9083/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Converted MonoSymbol. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.299 retrieving revision 1.300 diff -C2 -d -r1.299 -r1.300 *** Parser.jj 10 Jan 2005 23:58:02 -0000 1.299 --- Parser.jj 11 Jan 2005 21:45:45 -0000 1.300 *************** *** 566,570 **** type=monotype() name=ident() ! { return new MonoSymbol(name,type); } } --- 566,570 ---- type=monotype() name=ident() ! { return bossa.syntax.dispatch.createMonoSymbol(name,type); } } *************** *** 1728,1732 **** LOOKAHEAD( monotype() ) type=monotype() name=ident() ! { return new MonoSymbol(name,type); } | { Token first,last; --- 1728,1732 ---- LOOKAHEAD( monotype() ) type=monotype() name=ident() ! { return bossa.syntax.dispatch.createMonoSymbol(name,type); } | { Token first,last; *************** *** 1751,1755 **** type = new TupleType(types, makeLocation(first, last)); type.nullness = Monotype.absent; ! return new MonoSymbol(name, type); } ) --- 1751,1755 ---- type = new TupleType(types, makeLocation(first, last)); type.nullness = Monotype.absent; ! return bossa.syntax.dispatch.createMonoSymbol(name, type); } ) |
From: Arjan B. <ar...@us...> - 2005-01-10 23:58:20
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30060/F:/nice/src/bossa/syntax Modified Files: Node.java analyse.nice call.nice constraint.nice customConstructor.nice importedconstructor.nice locals.nice methodContainer.nice niceMethod.nice nicefieldaccess.nice polytype.nice tools.nice typedef.nice Removed Files: AtomicConstraint.java Constraint.java Log Message: Converted AtomicConstraint and Constraint. Index: analyse.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/analyse.nice,v retrieving revision 1.122 retrieving revision 1.123 diff -C2 -d -r1.122 -r1.123 *** analyse.nice 3 Jan 2005 01:24:12 -0000 1.122 --- analyse.nice 10 Jan 2005 23:58:04 -0000 1.123 *************** *** 454,458 **** info.anonFunDepth = info.depth; ! if (e.constraint != Constraint.True && e.constraint != null) { e.cst = notNull(e.constraint).resolveToLowlevel(); --- 454,458 ---- info.anonFunDepth = info.depth; ! if (e.constraint != trueConstraint && e.constraint != null) { e.cst = notNull(e.constraint).resolveToLowlevel(); Index: customConstructor.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/customConstructor.nice,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** customConstructor.nice 4 Jan 2005 21:20:39 -0000 1.10 --- customConstructor.nice 10 Jan 2005 23:58:04 -0000 1.11 *************** *** 167,177 **** classe.nullness = Monotype.sure; ! if (cst == Constraint.True) return classe; ! TypeSymbol[] syms = cst.getBinderArray(); ! Monotype[] params = cast(new Monotype[syms.length]); ! for (int i = 0; i < syms.length; i++) { if (! (syms[i] instanceof mlsub.typing.MonotypeVar)) --- 167,177 ---- classe.nullness = Monotype.sure; ! if (cst == trueConstraint) return classe; ! List<TypeSymbol> syms = cst.getBinders(); ! Monotype[] params = cast(new Monotype[syms.size()]); ! for (int i = 0; i < syms.size(); i++) { if (! (syms[i] instanceof mlsub.typing.MonotypeVar)) Index: Node.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Node.java,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** Node.java 30 Dec 2004 20:58:37 -0000 1.65 --- Node.java 10 Jan 2005 23:58:04 -0000 1.66 *************** *** 102,116 **** addTypeMap(s.toString(), s); } ! ! void addTypeSymbols(Collection c) ! { ! if(c!=null) ! for(Iterator i=c.iterator(); i.hasNext();) ! { ! TypeSymbol s = (TypeSymbol) i.next(); ! addTypeMap(s.toString(), s); ! } ! } ! void addTypeMap(String name, TypeSymbol symbol) { --- 102,106 ---- addTypeMap(s.toString(), s); } ! void addTypeMap(String name, TypeSymbol symbol) { Index: polytype.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/polytype.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** polytype.nice 10 Jan 2005 20:04:43 -0000 1.1 --- polytype.nice 10 Jan 2005 23:58:04 -0000 1.2 *************** *** 21,25 **** public class Polytype extends Node { ! private Constraint constraint = Constraint.True; private Monotype monotype; --- 21,25 ---- public class Polytype extends Node { ! private Constraint constraint = trueConstraint; private Monotype monotype; Index: constraint.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/constraint.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** constraint.nice 8 Dec 2004 23:03:37 -0000 1.1 --- constraint.nice 10 Jan 2005 23:58:04 -0000 1.2 *************** *** 16,19 **** --- 16,283 ---- /** + A list of binders + atomic constraints. + + @see AtomicConstraint + + */ + public class Constraint extends Node + { + private List<TypeSymbol> binders; + private List<AtomicConstraint> atomics; + + /** + * Returns a new constraint. + * The lists are new, but the list elements are the same. + */ + Constraint shallowClone() + { + return createConstraint(new ArrayList(binders), new ArrayList(atomics)); + } + + mlsub.typing.Constraint resolveToLowlevel() + { + return mlsub.typing.Constraint.create( + binders.isEmpty() ? null : binders.toArray(), + atomics.isEmpty() ? null : atomics.mapToArray( + AtomicConstraint ac => ac.resolve(notNull(typeScope)))); + } + + toString() + { + if (atomics.isEmpty()) + return Util.map("<",", ","> ",binders); + + if (binders.isEmpty()) + return Util.map("<",", ","> ",atomics); + + // Put in a parsable format. + StringBuffer res = new StringBuffer("<"); + boolean first = true; + + Constraint c = this.shallowClone(); + + let i = c.binders.iterator(); + while (i.hasNext()) + { + TypeSymbol s = i.next(); + if (!(s instanceof TypeConstructor)) + // Handle the ! constraint + { + MonotypeVar mv = cast(s); + let j = c.atomics.iterator(); + while (j.hasNext()) + { + AtomicConstraint atom = j.next(); + if (atom.isSureConstraintFor(mv)) + { + if (first) + first = false; + else + res.append(','); + res.append('!').append(s); + j.remove(); + i.remove(); + break; + } + } + + continue; + } + + TypeConstructor tc = s; + boolean ok = false; + let j = c.atomics.iterator(); + while (j.hasNext()) + { + AtomicConstraint atom = j.next(); + let parent = atom.getParentFor(tc); + if (parent!=null) + { + if (first) + first = false; + else + res.append(','); + res.append(parent).append(' ').append(tc); + j.remove(); + i.remove(); + ok = true; + break; + } + } + if (!ok) + Internal.error("Unable to print the constraint in a parsable form because of "+tc); + } + + res.append(Util.map((res.length()>1 ? ", " : ""),", ","", c.binders)); + res.append(Util.map(" | ",", ","",c.atomics)).append("> "); + return res.toString(); + } + + /** + Add the binder to the front of the list of binders. + */ + void addFirstBinder(TypeSymbol s) + { + binders.add(0, s); + this.addTypeSymbol(s); + } + + /** + Add the binder if it is not already there. + */ + void addBinder(TypeSymbol s) + { + if (!binders.contains(s)) + { + binders.add(s); + this.addTypeSymbol(s); + } + } + + /** + * Adds binders that are not already present + * + * @param b a collection of TypeSymbol + */ + void addBinders(TypeSymbol[?] bs) + { + if (bs==null) + return; + + for (int i = 0; i<bs.length; i++) + this.addBinder(bs[i]); + } + + void addAtom(AtomicConstraint atom) + { + atomics.add(atom); + } + + void addAtoms(List<AtomicConstraint> l) + { + atomics.addAll(l); + } + + public boolean isTrivial() = binders.isEmpty() && atomics.isEmpty(); + + List<TypeSymbol> getBinders() = binders; + List<AtomicConstraint> getAtoms() = atomics; + } + + /** + * Creates the constraint \forall binders . atomics + * + * @param binders a collection of TypeSymbols + * @param atomics a collection of AtomicConstraints + */ + public Constraint createConstraint(?List<TypeSymbol> binders, ?List<AtomicConstraint> atomics) + { + if (binders == null && atomics == null) + return trueConstraint; + + let res = new Constraint(Node.upper, binders: binders || new ArrayList(), + atomics: atomics || new ArrayList()); + if (binders != null) + for (b : binders) + res.addTypeSymbol(b); + + return res; + } + + /** + * The trivial constraint. + * + * This field is final, so pointer equality can be used + * to test whether a constraint is True. + * + * @return a constraint with no binders, always true + */ + let Constraint trueConstraint = new Constraint(Node.upper, binders: new ArrayList(0), atomics: new ArrayList(0)); + + /** + An abstract constraint atom. See children. + + @see Constraint + */ + public abstract class AtomicConstraint + { + + mlsub.typing.AtomicConstraint resolve(TypeScope scope); + + /** + * Returns a string that represents a constraint element + * another element was introduced in comparison of. + * + * For instance, in <Num N | ... > + * getParentFor(N) should be "Num". + * Used to reproduce a parsable form of the constraint. + * + * @param tc a constraint element + * @return the representation of its "parent", or <code>null</code> + */ + ?String getParentFor(mlsub.typing.TypeConstructor tc) + { + return null; + } + + boolean isSureConstraintFor(mlsub.typing.MonotypeVar mv) + { + return false; + } + } + + public AtomicConstraint createSureTypeVar(mlsub.typing.MonotypeVar tv) + { + return new AtomicConstraintWrapper + (atom: new mlsub.typing.MonotypeLeqTcCst(tv, nice.tools.typing.PrimitiveType.sureTC)); + } + + /** + Wrapper for lowlevel AtomicConstraint + */ + final class AtomicConstraintWrapper extends AtomicConstraint + { + private final mlsub.typing.AtomicConstraint atom; + + resolve(scope) = atom; + + getParentFor(tc) + { + if (atom instanceof mlsub.typing.TypeConstructorLeqCst) + { + mlsub.typing.TypeConstructorLeqCst leq = cast(atom); + if (leq.t1()==tc) + return leq.t2().toString(); + else + return null; + } + + if (atom instanceof mlsub.typing.ImplementsCst) + { + mlsub.typing.ImplementsCst leq = cast(atom); + if (leq.tc()==tc) + return leq.itf().toString(); + else + return null; + } + + return null; + } + + isSureConstraintFor(mv) + { + if (atom instanceof mlsub.typing.MonotypeLeqTcCst) + { + let mlsub.typing.MonotypeLeqTcCst a = cast(atom); + return a.m == mv; + } + + return false; + } + + toString() = atom.toString(); + } + + /** Syntactic inequality between monotypes. *************** *** 24,28 **** Monotype m2; ! resolve(ts) { return new mlsub.typing.MonotypeLeqCst --- 288,292 ---- Monotype m2; ! resolve(TypeScope ts) { return new mlsub.typing.MonotypeLeqCst *************** *** 37,46 **** */ ! public class TypeConstructorLeqCst extends AtomicConstraint { mlsub.typing.TypeConstructor t1; TypeIdent t2; ! resolve(ts) { // If t2 resolve to an interface definition, --- 301,310 ---- */ ! public class TypeConstructorLeqCst extends bossa.syntax.AtomicConstraint { mlsub.typing.TypeConstructor t1; TypeIdent t2; ! resolve(TypeScope ts) { // If t2 resolve to an interface definition, Index: locals.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/locals.nice,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** locals.nice 10 Jan 2005 20:04:43 -0000 1.4 --- locals.nice 10 Jan 2005 23:58:04 -0000 1.5 *************** *** 208,213 **** public Statement createLocalFunction(LocatedString name, Monotype returnType, FormalParameters parameters, Statement body) { ! let value = createFunExp(Constraint.True, parameters.getMonoSymbols() || new MonoSymbol[0], body); ! let symbol = new FunSymbol(name, Constraint.True, parameters, returnType); notNull(symbol.syntacticType).monotype.nullness = Monotype.sure; return new LocalFunction(left: symbol, value: value, parameters: parameters); --- 208,213 ---- public Statement createLocalFunction(LocatedString name, Monotype returnType, FormalParameters parameters, Statement body) { ! let value = createFunExp(trueConstraint, parameters.getMonoSymbols() || new MonoSymbol[0], body); ! let symbol = new FunSymbol(name, trueConstraint, parameters, returnType); notNull(symbol.syntacticType).monotype.nullness = Monotype.sure; return new LocalFunction(left: symbol, value: value, parameters: parameters); --- Constraint.java DELETED --- --- AtomicConstraint.java DELETED --- Index: niceMethod.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/niceMethod.nice,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** niceMethod.nice 4 Jan 2005 21:20:39 -0000 1.9 --- niceMethod.nice 10 Jan 2005 23:58:04 -0000 1.10 *************** *** 248,253 **** mlsub.typing.TypeSymbol[?] thisBinders = c.getBinders(); - int thisBindersLen = (thisBinders == null ? 0 : thisBinders.length); - mlsub.typing.TypeSymbol container = c.getTypeSymbol(); // contains the interface if container is one --- 248,251 ---- *************** *** 266,275 **** // we must create a new one, otherwise we would // modify other methods! ! if (constraint == Constraint.True) ! constraint = new Constraint ! (new ArrayList(thisBindersLen + (hasAlike ? 1 : 0)), ! new ArrayList((hasAlike ? 1 : 0) + ! (thisConstraint == null ? 0 : ! thisConstraint.getAtoms().size()))); constraint.addBinders(thisBinders); --- 264,269 ---- // we must create a new one, otherwise we would // modify other methods! ! if (constraint == trueConstraint) ! constraint = createConstraint(new ArrayList(), new ArrayList()); constraint.addBinders(thisBinders); *************** *** 296,300 **** else atom = new mlsub.typing.TypeConstructorLeqCst(alikeTC, tc); ! constraint.addAtom(AtomicConstraint.create(atom)); thisType = Monotype.create --- 290,294 ---- else atom = new mlsub.typing.TypeConstructorLeqCst(alikeTC, tc); ! constraint.addAtom(new AtomicConstraintWrapper(atom: atom)); thisType = Monotype.create Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.92 retrieving revision 1.93 diff -C2 -d -r1.92 -r1.93 *** tools.nice 5 Jan 2005 02:02:45 -0000 1.92 --- tools.nice 10 Jan 2005 23:58:04 -0000 1.93 *************** *** 230,234 **** ?gnu.expr.Declaration getDeclaration(VarSymbol) = native gnu.expr.Declaration VarSymbol.getDeclaration(); void printInterface(ClassImplementation, java.io.PrintWriter) = native void ClassImplementation.printInterface(java.io.PrintWriter); - List<AtomicConstraint> getAtoms(Constraint) = native List Constraint.getAtoms(); mlsub.typing.Monotype[?] resolve(TypeMap, Monotype[?]) = native mlsub.typing.Monotype[] Monotype.resolve(TypeMap, Monotype[]); ?gnu.bytecode.Type TypeImport_lookup(LocatedString) = native gnu.bytecode.Type nice.tools.code.TypeImport.lookup(LocatedString); --- 230,233 ---- *************** *** 238,243 **** gnu.expr.CopyArgument CopyArgument(Stack<gnu.bytecode.Variable>) = native new gnu.expr.CopyArgument(Stack); AST AST(List<Definition>, int) = native new AST(List, int); - ?String getParentFor(AtomicConstraint, mlsub.typing.TypeConstructor) = native String AtomicConstraint.getParentFor(mlsub.typing.TypeConstructor); - mlsub.typing.AtomicConstraint resolve(AtomicConstraint, TypeScope) = native mlsub.typing.AtomicConstraint AtomicConstraint.resolve(TypeScope); bossa.syntax.Monotype substitute(bossa.syntax.Monotype,Map<String,bossa.syntax.Monotype>) = native bossa.syntax.Monotype bossa.syntax.Monotype.substitute(Map); List<bossa.syntax.Monotype> substitute(Map<String,bossa.syntax.Monotype>,Collection<bossa.syntax.Monotype>) = native List bossa.syntax.Monotype.substitute(Map,Collection); --- 237,240 ---- *************** *** 251,259 **** List<VarSymbol> lookup(VarScope, LocatedString) = native List VarScope.lookup(LocatedString); Map<gnu.bytecode.Type,mlsub.typing.TypeConstructor> javaTypeConstructors(bossa.modules.Compilation ) = native bossa.modules.Compilation.javaTypeConstructors; - bossa.syntax.Constraint newConstraint(List<TypeSymbol>, List<AtomicConstraint>) = native new Constraint(List, List); - void addAtoms(Constraint, List<AtomicConstraint>) = native void Constraint.addAtoms(List); Map<VarSymbol, int[]> usedArguments(Arguments) = native Arguments.usedArguments; Map<VarSymbol, Expression[]> applicationExpressions(Arguments) = native Arguments.applicationExpressions; - Constraint _Constraint(mlsub.typing.TypeSymbol[], List<AtomicConstraint>) = native new Constraint(mlsub.typing.TypeSymbol[], List); // Retypings needed since java types are not strict. --- 248,253 ---- Index: typedef.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typedef.nice,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** typedef.nice 5 Jan 2005 02:02:46 -0000 1.10 --- typedef.nice 10 Jan 2005 23:58:04 -0000 1.11 *************** *** 388,392 **** if (our != null) { ! binders.addAll(Arrays.asList(our.getBinderArray())); atoms.addAll(our.getAtoms()); } --- 388,392 ---- if (our != null) { ! binders.addAll(our.getBinders()); atoms.addAll(our.getAtoms()); } *************** *** 411,416 **** } ! return new ClassConstraint(binders, atoms, typeParameters: cast(typeParameters)); } --- 411,421 ---- } ! let res = new ClassConstraint(Node.upper, binders: binders, atomics: atoms, typeParameters: cast(typeParameters)); + + for (b : binders) + res.addTypeSymbol(b); + + return res; } Index: methodContainer.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/methodContainer.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** methodContainer.nice 5 Jan 2005 02:02:43 -0000 1.1 --- methodContainer.nice 10 Jan 2005 23:58:04 -0000 1.2 *************** *** 50,55 **** } catch(TypeScope.DuplicateName ex) {} ! resolvedConstraints = ! AtomicConstraint.resolve(scope, notNull(classConstraint).getAtoms()); } } --- 50,55 ---- } catch(TypeScope.DuplicateName ex) {} ! resolvedConstraints = notNull(classConstraint).getAtoms().mapToArray( ! AtomicConstraint ac => ac.resolve(scope)); } } *************** *** 61,69 **** return null; else ! return notNull(classConstraint).getBinderArray(); } /** The type parameters of the class. */ ! public mlsub.typing.Monotype[?] getTypeParameters () { if (classConstraint == null) --- 61,69 ---- return null; else ! return notNull(classConstraint).getBinders().toArray(); } /** The type parameters of the class. */ ! public mlsub.typing.Monotype[?] getTypeParameters() { if (classConstraint == null) *************** *** 79,83 **** else return new mlsub.typing.Constraint ! (notNull(classConstraint).getBinderArray(), resolvedConstraints); } --- 79,83 ---- else return new mlsub.typing.Constraint ! (notNull(classConstraint).getBinders().toArray, resolvedConstraints); } *************** *** 150,154 **** boolean resolve; ! if (cst == bossa.syntax.Constraint.True || cst == null) { binders = cast(typeParameters); --- 150,154 ---- boolean resolve; ! if (cst == trueConstraint || cst == null) { binders = cast(typeParameters); *************** *** 159,163 **** { constraints = cst.getAtoms(); ! binders = cst.getBinderArray(); resolve = true; } --- 159,163 ---- { constraints = cst.getAtoms(); ! binders = cst.getBinders().toArray(); resolve = true; } *************** *** 198,201 **** nice.tools.typing.Types.makeMarkedType(tp); ! return new ClassConstraint(binders, atoms, typeParameters: tps); } \ No newline at end of file --- 198,207 ---- nice.tools.typing.Types.makeMarkedType(tp); ! let res = new ClassConstraint(Node.upper, binders: new ArrayList(binders), ! atomics: atoms, typeParameters: tps); ! ! for (b : binders) ! res.addTypeSymbol(b); ! ! return res; } \ No newline at end of file Index: nicefieldaccess.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/nicefieldaccess.nice,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** nicefieldaccess.nice 5 Jan 2005 02:02:44 -0000 1.6 --- nicefieldaccess.nice 10 Jan 2005 23:58:04 -0000 1.7 *************** *** 47,51 **** let params = createFormalParameters([new Parameter(type: Monotype.create(argType))]); ! let constr = bossa.syntax.Constraint.create(classDef.getBinders()); let res = new NiceFieldAccess(field.getName(), Node.down, parameters: params, --- 47,51 ---- let params = createFormalParameters([new Parameter(type: Monotype.create(argType))]); ! let constr = createConstraint(classDef.getBinders(), null); let res = new NiceFieldAccess(field.getName(), Node.down, parameters: params, Index: importedconstructor.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/importedconstructor.nice,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** importedconstructor.nice 4 Jan 2005 21:20:39 -0000 1.8 --- importedconstructor.nice 10 Jan 2005 23:58:04 -0000 1.9 *************** *** 100,104 **** let constraint = classDef.classConstraint == null ? ! bossa.syntax.Constraint.True : notNull(classDef.classConstraint).shallowClone(); let name = new LocatedString("<init>",def.getDefinition().location()); --- 100,104 ---- let constraint = classDef.classConstraint == null ? ! trueConstraint : notNull(classDef.classConstraint).shallowClone(); let name = new LocatedString("<init>",def.getDefinition().location()); Index: call.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/call.nice,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** call.nice 1 Jan 2005 16:36:31 -0000 1.7 --- call.nice 10 Jan 2005 23:58:04 -0000 1.8 *************** *** 276,280 **** { let CallExp exp = cast(callexp); ! exp.arguments.add(createFunExp(bossa.syntax.Constraint.True, [], block), name); } --- 276,280 ---- { let CallExp exp = cast(callexp); ! exp.arguments.add(createFunExp(trueConstraint, [], block), name); } |
From: Arjan B. <ar...@us...> - 2005-01-10 23:58:14
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30060/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Converted AtomicConstraint and Constraint. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.298 retrieving revision 1.299 diff -C2 -d -r1.298 -r1.299 *** Parser.jj 5 Jan 2005 02:02:27 -0000 1.298 --- Parser.jj 10 Jan 2005 23:58:02 -0000 1.299 *************** *** 593,597 **** { if (sure) ! atomics.add(AtomicConstraint.sureTypeVar(id)); return id; } --- 593,597 ---- { if (sure) ! atomics.add(bossa.syntax.dispatch.createSureTypeVar(id)); return id; } *************** *** 639,645 **** [ { List b=null, atoms=new ArrayList(); } "<" b=binders(atoms) [ "|" atomics(atoms) ] ">" ! { return new Constraint(b,atoms); } ] ! { return Constraint.True; } } --- 639,645 ---- [ { List b=null, atoms=new ArrayList(); } "<" b=binders(atoms) [ "|" atomics(atoms) ] ">" ! { return bossa.syntax.dispatch.createConstraint(b,atoms); } ] ! { return bossa.syntax.dispatch.createConstraint(null,null); } } *************** *** 1178,1182 **** // For the moment, disallow constraints to come from both the prefix // and the type parameters. ! if (prefix != Constraint.True && atoms.size() > 0) throw bossa.util.User.error (loc, "Constraints on type parameters should all be specified in the prefix constraint"); --- 1178,1182 ---- // For the moment, disallow constraints to come from both the prefix // and the type parameters. ! if ((! prefix.isTrivial()) && atoms.size() > 0) throw bossa.util.User.error (loc, "Constraints on type parameters should all be specified in the prefix constraint"); *************** *** 1212,1216 **** } ! if (sure) atoms.add(AtomicConstraint.sureTypeVar(mv)); return mv; --- 1212,1216 ---- } ! if (sure) atoms.add(bossa.syntax.dispatch.createSureTypeVar(mv)); return mv; *************** *** 1759,1763 **** { List formals = new LinkedList(); ! Constraint cst = Constraint.True; MonoSymbol sym; Statement body; --- 1759,1763 ---- { List formals = new LinkedList(); ! Constraint cst = bossa.syntax.dispatch.createConstraint(null, null); MonoSymbol sym; Statement body; *************** *** 1784,1788 **** ) { statements.add(body); ! return bossa.syntax.dispatch.createFunExp(cst, formals, bossa.syntax.dispatch.createBlock(statements)); } } --- 1784,1788 ---- ) { statements.add(body); ! return cst.createFunExp(formals, bossa.syntax.dispatch.createBlock(statements)); } } |
From: Arjan B. <ar...@us...> - 2005-01-10 20:04:56
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8578/F:/nice/src/bossa/syntax Modified Files: locals.nice symbol.nice Added Files: polytype.nice Removed Files: Polytype.java Log Message: Converted Polytype. Index: locals.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/locals.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** locals.nice 14 Oct 2004 09:37:27 -0000 1.3 --- locals.nice 10 Jan 2005 20:04:43 -0000 1.4 *************** *** 210,214 **** let value = createFunExp(Constraint.True, parameters.getMonoSymbols() || new MonoSymbol[0], body); let symbol = new FunSymbol(name, Constraint.True, parameters, returnType); ! notNull(notNull(symbol.syntacticType).getMonotype()).nullness = Monotype.sure; return new LocalFunction(left: symbol, value: value, parameters: parameters); } --- 210,214 ---- let value = createFunExp(Constraint.True, parameters.getMonoSymbols() || new MonoSymbol[0], body); let symbol = new FunSymbol(name, Constraint.True, parameters, returnType); ! notNull(symbol.syntacticType).monotype.nullness = Monotype.sure; return new LocalFunction(left: symbol, value: value, parameters: parameters); } --- NEW FILE: polytype.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package bossa.syntax; import bossa.util.*; /** A constrained monotype. */ public class Polytype extends Node { private Constraint constraint = Constraint.True; private Monotype monotype; { this.addChild(constraint); } mlsub.typing.Polytype resolveToLowlevel() { return new mlsub.typing.Polytype(constraint.resolveToLowlevel(), monotype.resolve(typeScope)); } mlsub.typing.Polytype resolve(TypeMap s) { // this does probably not work if constraint is non-trivial return new mlsub.typing.Polytype(constraint.resolveToLowlevel(), monotype.resolve(s)); } toString() = constraint + " " + monotype.toStringExtern(); } Index: symbol.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/symbol.nice,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** symbol.nice 3 Jan 2005 01:24:28 -0000 1.5 --- symbol.nice 10 Jan 2005 20:04:43 -0000 1.6 *************** *** 62,68 **** } ! new PolySymbol( MonoSymbol sym ) { ! this(sym.name, syntacticType : new Polytype(sym.syntacticType)); } --- 62,68 ---- } ! new PolySymbol(MonoSymbol sym) { ! this(sym.name, syntacticType : new Polytype(Node.down, monotype: notNull(sym.syntacticType))); } *************** *** 138,142 **** { this(name, parameters: parameters, arity: parameters.size, syntacticType: ! new Polytype(constraint, createFunType(parameters.types(), returnType))); } --- 138,142 ---- { this(name, parameters: parameters, arity: parameters.size, syntacticType: ! new Polytype(Node.down, constraint: constraint, monotype: createFunType(parameters.types(), returnType))); } *************** *** 200,204 **** FormalParameters parameters = notNull(declaration.formalParameters()); this(name, declaration: declaration, parameters: parameters, arity: parameters.size, ! syntacticType: new Polytype(constraint, createFunType(parameters.types(), returnType))); } --- 200,204 ---- FormalParameters parameters = notNull(declaration.formalParameters()); this(name, declaration: declaration, parameters: parameters, arity: parameters.size, ! syntacticType: new Polytype(Node.down, constraint: constraint, monotype: createFunType(parameters.types(), returnType))); } --- Polytype.java DELETED --- |
From: Arjan B. <ar...@us...> - 2005-01-08 14:46:53
|
Update of /cvsroot/nice/Nice/testsuite/compiler/classes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26311/F:/nice/testsuite/compiler/classes Modified Files: specialization.testsuite Log Message: Testcases for bug #1097571. Index: specialization.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/classes/specialization.testsuite,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** specialization.testsuite 28 Dec 2004 16:05:26 -0000 1.8 --- specialization.testsuite 8 Jan 2005 14:46:42 -0000 1.9 *************** *** 81,82 **** --- 81,96 ---- Env env = new Env(new HashMap()); } + + /// PASS bug + // bug #1097571 + /// Toplevel + class A<T> {} + class B extends A<boolean> {} + class C extends B {} + + /// PASS bug + // bug #1097571 + /// Toplevel + interface A<T> {} + interface B extends A<boolean> {} + class C implements B {} |
From: Arjan B. <ar...@us...> - 2005-01-05 02:03:28
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9476/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Converted MethodContainer. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.297 retrieving revision 1.298 diff -C2 -d -r1.297 -r1.298 *** Parser.jj 4 Jan 2005 21:20:00 -0000 1.297 --- Parser.jj 5 Jan 2005 02:02:27 -0000 1.298 *************** *** 923,927 **** ( ";" | body = code() {statements.add(body);} ) ! { return bossa.syntax.dispatch.createMemberMethod(c, name, cst, returnType, parameters, body != null ? bossa.syntax.dispatch.createBlock(statements) : null, contract, isOverride); } --- 923,927 ---- ( ";" | body = code() {statements.add(body);} ) ! { return c.createMemberMethod(name, cst, returnType, parameters, body != null ? bossa.syntax.dispatch.createBlock(statements) : null, contract, isOverride); } *************** *** 1011,1015 **** TypeDefinition res; LocatedString name; ! MethodContainer.Constraint parameters = null; List l; List typeParametersVariances = new ArrayList(0); --- 1011,1015 ---- TypeDefinition res; LocatedString name; ! ClassConstraint parameters = null; List l; List typeParametersVariances = new ArrayList(0); *************** *** 1121,1125 **** { LocatedString name; ! MethodContainer.Constraint parameters = null; List extensions=null; List typeParametersVariances = new ArrayList(0); --- 1121,1125 ---- { LocatedString name; ! ClassConstraint parameters = null; List extensions=null; List typeParametersVariances = new ArrayList(0); *************** *** 1161,1165 **** ! MethodContainer.Constraint classTypeParameters(Constraint prefix, List tags): { List binders = new ArrayList(3); --- 1161,1165 ---- ! ClassConstraint classTypeParameters(Constraint prefix, List tags): { List binders = new ArrayList(3); *************** *** 1183,1187 **** MonotypeVar[] b = (MonotypeVar[]) binders.toArray(new MonotypeVar[binders.size()]); ! return MethodContainer.Constraint.make(prefix, b, atoms, loc); } } --- 1183,1187 ---- MonotypeVar[] b = (MonotypeVar[]) binders.toArray(new MonotypeVar[binders.size()]); ! return bossa.syntax.dispatch.createClassConstraint(prefix, b, atoms, loc); } } |
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9476/F:/nice/src/bossa/syntax Modified Files: ai.nice niceclass.nice nicefieldaccess.nice tools.nice typedef.nice Added Files: methodContainer.nice Removed Files: MethodContainer.java Log Message: Converted MethodContainer. Index: nicefieldaccess.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/nicefieldaccess.nice,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** nicefieldaccess.nice 3 Jan 2005 01:24:28 -0000 1.5 --- nicefieldaccess.nice 5 Jan 2005 02:02:44 -0000 1.6 *************** *** 47,51 **** let params = createFormalParameters([new Parameter(type: Monotype.create(argType))]); ! let constr = Constraint.create(classDef.getBinders()); let res = new NiceFieldAccess(field.getName(), Node.down, parameters: params, --- 47,51 ---- let params = createFormalParameters([new Parameter(type: Monotype.create(argType))]); ! let constr = bossa.syntax.Constraint.create(classDef.getBinders()); let res = new NiceFieldAccess(field.getName(), Node.down, parameters: params, Index: typedef.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typedef.nice,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** typedef.nice 4 Jan 2005 21:20:51 -0000 1.9 --- typedef.nice 5 Jan 2005 02:02:46 -0000 1.10 *************** *** 36,40 **** ?ClassImplementation implementation = null; ?gnu.bytecode.Type javaType = null; ! ?List<int> typeParametersVariances = null; // Interfaces --- 36,40 ---- ?ClassImplementation implementation = null; ?gnu.bytecode.Type javaType = null; ! ?List<?boolean> typeParametersVariances = null; // Interfaces *************** *** 371,375 **** } ! MethodContainer.Constraint specialize(?MethodContainer.Constraint our, mlsub.typing.Monotype[?] params) { --- 371,375 ---- } ! ClassConstraint specialize(?ClassConstraint our, mlsub.typing.Monotype[?] params) { *************** *** 411,419 **** } ! return new MethodContainer.Constraint( ! binders.toArray(), ! atoms, ! typeParameters, ! this.location()); } --- 411,416 ---- } ! return new ClassConstraint(binders, atoms, ! typeParameters: cast(typeParameters)); } *************** *** 720,724 **** //used in mlsub.typing.Enumeration ! public mlsub.typing.Monotype[] getTypeDefTypeParameters(mlsub.typing.TypeConstructor tc) { return notNull(getTypeDefinition(tc)).getTypeParameters(); --- 717,721 ---- //used in mlsub.typing.Enumeration ! public mlsub.typing.Monotype[?] getTypeDefTypeParameters(mlsub.typing.TypeConstructor tc) { return notNull(getTypeDefinition(tc)).getTypeParameters(); *************** *** 758,762 **** requires exactly these type parameters because it specializes its parent. */ ! ?mlsub.typing.Monotype getTypeWithTC(TypeConstructor tc, mlsub.typing.Monotype[] sourceParams ) { ?TypeDefinition def = cast(getTypeDefinition(tc)); --- 755,759 ---- requires exactly these type parameters because it specializes its parent. */ ! ?mlsub.typing.Monotype getTypeWithTC(TypeConstructor tc, mlsub.typing.Monotype[?] sourceParams ) { ?TypeDefinition def = cast(getTypeDefinition(tc)); *************** *** 777,781 **** if (params[i] == null) { ! fullParams[i] = sourceParams[paramMap[i]]; used++; } --- 774,778 ---- if (params[i] == null) { ! fullParams[i] = notNull(sourceParams)[paramMap[i]]; used++; } *************** *** 854,859 **** ClassDefinition makeClass(LocatedString name, boolean isFinal, boolean isAbstract, ! ?MethodContainer.Constraint typeParameters, ! List<int> typeParametersVariances, MonotypeConstructor superClassIdent, ?List<MonotypeConstructor> implementations, --- 851,856 ---- ClassDefinition makeClass(LocatedString name, boolean isFinal, boolean isAbstract, ! ?ClassConstraint typeParameters, ! List<?boolean> typeParametersVariances, MonotypeConstructor superClassIdent, ?List<MonotypeConstructor> implementations, *************** *** 865,869 **** return new ClassDefinition( ! name, Node.upper, typeParameters, modifiers : mod, typeParametersVariances : typeParametersVariances, --- 862,866 ---- return new ClassDefinition( ! name, Node.upper, classConstraint: typeParameters, modifiers : mod, typeParametersVariances : typeParametersVariances, *************** *** 874,879 **** InterfaceDefinition makeInterface(LocatedString name, ! ?MethodContainer.Constraint typeParameters, ! List<int> typeParametersVariances, ?List<MonotypeConstructor> extensions, ?List<MonotypeConstructor> implementations, --- 871,876 ---- InterfaceDefinition makeInterface(LocatedString name, ! ?ClassConstraint typeParameters, ! List<?boolean> typeParametersVariances, ?List<MonotypeConstructor> extensions, ?List<MonotypeConstructor> implementations, *************** *** 881,885 **** { return new InterfaceDefinition( ! name, Node.upper, typeParameters, typeParametersVariances : typeParametersVariances, extensions : extensions, --- 878,882 ---- { return new InterfaceDefinition( ! name, Node.upper, classConstraint: typeParameters, typeParametersVariances : typeParametersVariances, extensions : extensions, --- MethodContainer.java DELETED --- --- NEW FILE: methodContainer.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package bossa.syntax; import bossa.util.*; /** An entity in which methods can be declared. It can have type parameters, that are implicitely added to the englobed methods. */ public abstract class MethodContainer extends Definition { ?mlsub.typing.Variance variance = null; ?ClassConstraint classConstraint = null; mlsub.typing.AtomicConstraint[?] resolvedConstraints = null; { this.name.prepend(module.getName() + "."); } /** The name of this method container without package qualification. */ String getSimpleName() { String name = this.getName().toString(); return name.substring(name.lastIndexOf('.') + 1); } mlsub.typing.TypeSymbol getTypeSymbol(); resolve() { if (classConstraint != null) { TypeScope scope = new TypeScope(this.typeScope); try { scope.addSymbols(notNull(classConstraint).getBinders()); } catch(TypeScope.DuplicateName ex) {} resolvedConstraints = AtomicConstraint.resolve(scope, notNull(classConstraint).getAtoms()); } } /** The binders of the constraint. */ public mlsub.typing.TypeSymbol[?] getBinders() { if (classConstraint == null) return null; else return notNull(classConstraint).getBinderArray(); } /** The type parameters of the class. */ public mlsub.typing.Monotype[?] getTypeParameters () { if (classConstraint == null) return null; else return notNull(classConstraint).typeParameters; } public mlsub.typing.Constraint getResolvedConstraint() { if (classConstraint == null) return mlsub.typing.Constraint.True; else return new mlsub.typing.Constraint (notNull(classConstraint).getBinderArray(), resolvedConstraints); } /** Children should call this implementation (super) then print their specific information. */ printInterface(s) { // Always print the constraint as a prefix constraint. if (classConstraint == null) return; s.print(classConstraint); } String printTypeParameters() { if (classConstraint == null) return ""; mlsub.typing.Monotype[] typeParameters = notNull(classConstraint).typeParameters; StringBuffer res = new StringBuffer("<"); for (int n = 0; n < typeParameters.length; n++) { let vari = notNull(variance).getVariance(n); if (vari == mlsub.typing.Variance.CONTRAVARIANT) res.append("-"); else if (vari == mlsub.typing.Variance.COVARIANT) res.append("+"); res.append(typeParameters[n].toString()); if (n + 1 < typeParameters.length) res.append(", "); } return res.append(">").toString(); } } ?mlsub.typing.Variance makeVariance(List<?boolean> typeParametersVariances) { int[] variances = new int[typeParametersVariances.size()]; for (int i = typeParametersVariances.size(); --i >= 0;) if (typeParametersVariances.get(i) != null) if (typeParametersVariances.get(i) == true) variances[i] = mlsub.typing.Variance.COVARIANT; else variances[i] = mlsub.typing.Variance.CONTRAVARIANT; return mlsub.typing.Variance.make(variances); } public class ClassConstraint extends bossa.syntax.Constraint { /** The type parameters of the class. */ mlsub.typing.Monotype[] typeParameters; } /** @param cst an additional constraint for the type parameters of this class. */ public ClassConstraint createClassConstraint(?bossa.syntax.Constraint cst, mlsub.typing.MonotypeVar[] typeParameters, List<AtomicConstraint> atoms, Location loc) { mlsub.typing.TypeSymbol[] binders; List<AtomicConstraint> constraints; boolean resolve; if (cst == bossa.syntax.Constraint.True || cst == null) { binders = cast(typeParameters); constraints = atoms; resolve = false; } else { constraints = cst.getAtoms(); binders = cst.getBinderArray(); resolve = true; } return createClassConstraint(binders, constraints, typeParameters, resolve, loc); } ClassConstraint createClassConstraint(mlsub.typing.TypeSymbol[] binders, List<AtomicConstraint> atoms, mlsub.typing.MonotypeVar[] typeParameters, boolean resolve, Location loc) { mlsub.typing.Monotype[] tps; if (resolve) /** Replace those type parameters that have been introduced in the constraint by their definition. */ tps = cast(typeParameters.mapToArray(mlsub.typing.MonotypeVar binder => { for (s : binders) if (s.toString().equals(binder.getName())) { if (s instanceof mlsub.typing.MonotypeVar) return s; else // The type parameter must be in fact a type constructor // of variance zero. return new mlsub.typing.MonotypeConstructor(cast(s), null); } throw User.error(loc, binder + " is not declared in the constraint"); })); else tps = cast(typeParameters); // The type parameters have nullness markers. for (tp : typeParameters) nice.tools.typing.Types.makeMarkedType(tp); return new ClassConstraint(binders, atoms, typeParameters: tps); } Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.91 retrieving revision 1.92 diff -C2 -d -r1.91 -r1.92 *** tools.nice 4 Jan 2005 21:20:40 -0000 1.91 --- tools.nice 5 Jan 2005 02:02:45 -0000 1.92 *************** *** 226,240 **** ?Definition importMethod(NiceClass, gnu.bytecode.Method) = native Definition NiceClass.importMethod(gnu.bytecode.Method); boolean equals(LocatedString, LocatedString) = native boolean LocatedString.equals(LocatedString); - mlsub.typing.AtomicConstraint[?] resolvedConstraints(MethodContainer) = native MethodContainer.resolvedConstraints; - mlsub.typing.TypeSymbol[?] getBinders(MethodContainer) = native mlsub.typing.TypeSymbol[] MethodContainer.getBinders(); ?gnu.bytecode.Attribute get(gnu.bytecode.AttrContainer, String) = native gnu.bytecode.Attribute gnu.bytecode.Attribute.get(gnu.bytecode.AttrContainer, String); void printInterface(Definition, java.io.PrintWriter) = native void Definition.printInterface(java.io.PrintWriter); ?gnu.expr.Declaration getDeclaration(VarSymbol) = native gnu.expr.Declaration VarSymbol.getDeclaration(); void printInterface(ClassImplementation, java.io.PrintWriter) = native void ClassImplementation.printInterface(java.io.PrintWriter); - ?Variance makeVariance(List<int>) = native Variance MethodContainer.makeVariance(List); List<AtomicConstraint> getAtoms(Constraint) = native List Constraint.getAtoms(); mlsub.typing.Monotype[?] resolve(TypeMap, Monotype[?]) = native mlsub.typing.Monotype[] Monotype.resolve(TypeMap, Monotype[]); - MethodContainer.Constraint MethodContainer$Constraint(TypeSymbol[], List<AtomicConstraint>, ?mlsub.typing.Monotype[], Location) - = native new MethodContainer.Constraint(TypeSymbol[], List, mlsub.typing.Monotype[], Location); ?gnu.bytecode.Type TypeImport_lookup(LocatedString) = native gnu.bytecode.Type nice.tools.code.TypeImport.lookup(LocatedString); List<Node> children(Node) = native Node.children; --- 226,235 ---- *************** *** 242,246 **** void addMappingsLS(TypeScope, Collection<LocatedString>, TypeSymbol[]) = native void TypeScope.addMappingsLS(Collection, TypeSymbol[]); gnu.expr.CopyArgument CopyArgument(Stack<gnu.bytecode.Variable>) = native new gnu.expr.CopyArgument(Stack); - MethodContainer MethodContainer(LocatedString, int, MethodContainer.Constraint, List<?boolean>) = native new MethodContainer(LocatedString, int, MethodContainer.Constraint, List); AST AST(List<Definition>, int) = native new AST(List, int); ?String getParentFor(AtomicConstraint, mlsub.typing.TypeConstructor) = native String AtomicConstraint.getParentFor(mlsub.typing.TypeConstructor); --- 237,240 ---- *************** *** 261,264 **** --- 255,259 ---- Map<VarSymbol, int[]> usedArguments(Arguments) = native Arguments.usedArguments; Map<VarSymbol, Expression[]> applicationExpressions(Arguments) = native Arguments.applicationExpressions; + Constraint _Constraint(mlsub.typing.TypeSymbol[], List<AtomicConstraint>) = native new Constraint(mlsub.typing.TypeSymbol[], List); // Retypings needed since java types are not strict. Index: ai.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/ai.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ai.nice 20 Dec 2004 16:05:18 -0000 1.3 --- ai.nice 5 Jan 2005 02:02:43 -0000 1.4 *************** *** 70,80 **** public AbstractInterface createAbstractInterface(LocatedString name, ! MethodContainer.Constraint typeParameters, List<?boolean> typeParametersVariances, List<MonotypeConstructor> extensions ) { ! let res = new AbstractInterface(name, Node.global, typeParameters, ! typeParametersVariances, extensions: extensions); res.itf = new Interface(res.variance, name.toString()); --- 70,80 ---- public AbstractInterface createAbstractInterface(LocatedString name, ! ClassConstraint typeParameters, List<?boolean> typeParametersVariances, List<MonotypeConstructor> extensions ) { ! let res = new AbstractInterface(name, Node.global, classConstraint: typeParameters, ! variance: makeVariance(typeParametersVariances), extensions: extensions); res.itf = new Interface(res.variance, name.toString()); Index: niceclass.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/niceclass.nice,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** niceclass.nice 4 Jan 2005 21:20:39 -0000 1.13 --- niceclass.nice 5 Jan 2005 02:02:44 -0000 1.14 *************** *** 61,65 **** TypeDefinition getDefinition() = definition; ! public mlsub.typing.Monotype[] getTypeParameters() = definition.getTypeParameters(); public void addField(MonoSymbol sym, ?Expression value, boolean isFinal, --- 61,65 ---- TypeDefinition getDefinition() = definition; ! public mlsub.typing.Monotype[] getTypeParameters() = notNull(definition.getTypeParameters()); public void addField(MonoSymbol sym, ?Expression value, boolean isFinal, *************** *** 429,433 **** scope = new TypeScope(scope); map = new HashMap(); ! let ourTypeParameters = definition.getTypeParameters(); for (int i = 0; i < ourTypeParameters.length; i++) try { --- 429,433 ---- scope = new TypeScope(scope); map = new HashMap(); ! let ourTypeParameters = notNull(definition.getTypeParameters()); for (int i = 0; i < ourTypeParameters.length; i++) try { *************** *** 460,464 **** private List<(?MethodDeclaration, List<Parameter>)> getConstructorParameters(?List<mlsub.typing.AtomicConstraint> constraints, ! mlsub.typing.Monotype[] typeParameters) { let supTC = definition.getSuperClass(); --- 460,464 ---- private List<(?MethodDeclaration, List<Parameter>)> getConstructorParameters(?List<mlsub.typing.AtomicConstraint> constraints, ! mlsub.typing.Monotype[?] typeParameters) { let supTC = definition.getSuperClass(); *************** *** 534,538 **** constraints = new LinkedList(); ! mlsub.typing.Monotype[] typeParameters = definition.getTypeParameters(); List<(?MethodDeclaration, List<Parameter>)> allConstructorParams = --- 534,538 ---- constraints = new LinkedList(); ! mlsub.typing.Monotype[?] typeParameters = definition.getTypeParameters(); List<(?MethodDeclaration, List<Parameter>)> allConstructorParams = *************** *** 563,567 **** // duplicating the type variables. if (parent instanceof JavaMethod && ! notNull(parent.getType()).isMonomorphic()) ! specificCst = identifyTypeParameters(cst, parent, typeParameters); let cname = new LocatedString("<init>",definition.location()); --- 563,567 ---- // duplicating the type variables. if (parent instanceof JavaMethod && ! notNull(parent.getType()).isMonomorphic()) ! specificCst = identifyTypeParameters(cst, parent, notNull(typeParameters)); let cname = new LocatedString("<init>",definition.location()); |
From: Arjan B. <ar...@us...> - 2005-01-04 21:24:12
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20863/F:/nice/src/bossa/syntax Modified Files: NiceClass.java compilation.nice constructor.nice customConstructor.nice dispatch.java.bootstrap dispatchTest.nice importedconstructor.nice methodImplementation.nice niceMethod.nice niceclass.nice super.nice tools.nice typedef.nice Removed Files: TypeDefinition.java Log Message: Removed some superfluous conversion constructs. Index: customConstructor.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/customConstructor.nice,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** customConstructor.nice 2 Jan 2005 02:20:59 -0000 1.9 --- customConstructor.nice 4 Jan 2005 21:20:39 -0000 1.10 *************** *** 23,27 **** Statement body; ! ?NiceClass classe = null; private ?VarScope thisScope = null; private ?TypeScope thisTypeScope = null; --- 23,27 ---- Statement body; ! ?CNiceClass classe = null; private ?VarScope thisScope = null; private ?TypeScope thisTypeScope = null; *************** *** 45,49 **** let tc = Node.getGlobalTypeScope().globalLookup(className); addConstructor(tc, this); ! classe = NiceClass.get(tc); if (classe == null) --- 45,49 ---- let tc = Node.getGlobalTypeScope().globalLookup(className); addConstructor(tc, this); ! classe = getNiceClass(tc); if (classe == null) Index: dispatchTest.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/dispatchTest.nice,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dispatchTest.nice 2 Jan 2005 02:20:59 -0000 1.4 --- dispatchTest.nice 4 Jan 2005 21:20:39 -0000 1.5 *************** *** 243,247 **** return null; ! let NiceClass nc = cast(def.getImplementation()); return nc.getClassExp().getClassType(); } --- 243,247 ---- return null; ! let CNiceClass nc = cast(def.getImplementation()); return nc.getClassExp().getClassType(); } Index: compilation.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/compilation.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** compilation.nice 30 Dec 2004 18:49:01 -0000 1.3 --- compilation.nice 4 Jan 2005 21:20:39 -0000 1.4 *************** *** 108,112 **** Iterator<Alternative> i = sortedAlternatives.iterator(); Alternative a = i.next(); ! NiceClass c = declaringClass(m, a); i.remove(); --- 108,112 ---- Iterator<Alternative> i = sortedAlternatives.iterator(); Alternative a = i.next(); ! CNiceClass c = declaringClass(m, a); i.remove(); *************** *** 139,143 **** } ! private NiceClass declaringClass(JavaMethod m, Alternative alt) { ?mlsub.typing.TypeConstructor firstArgument = alt.getPatterns()[0].getTC(); --- 139,143 ---- } ! private CNiceClass declaringClass(JavaMethod m, Alternative alt) { ?mlsub.typing.TypeConstructor firstArgument = alt.getPatterns()[0].getTC(); Index: NiceClass.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/NiceClass.java,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -d -r1.95 -r1.96 *** NiceClass.java 25 Nov 2004 19:28:18 -0000 1.95 --- NiceClass.java 4 Jan 2005 21:20:24 -0000 1.96 *************** *** 35,76 **** abstract public LocatedString getName(); - abstract TypeDefinition getDefinition(); - - abstract public boolean isInterface(); - - static NiceClass get(TypeConstructor tc) - { - TypeDefinition res = bossa.syntax.dispatch.getTypeDefinition(tc); - if (res != null && res.getImplementation() instanceof NiceClass) - return ((NiceClass) res.getImplementation()); - else - return null; - } - - public static NiceClass get(mlsub.typing.Monotype type) - { - if (! nice.tools.typing.Types.isSure(type)) - return null; - - return get(nice.tools.typing.Types.constructor(type)); - } - - // FIXME change to MethodSymbol once this is converted to nice - abstract void addConstructorCallSymbol(VarSymbol sym); - - abstract public void addField(MonoSymbol sym, Expression value, - boolean isFinal, boolean isTransient, boolean isVolatile, String docString); - - abstract gnu.expr.Expression getInitializer(); - abstract public gnu.expr.ClassExp createClassExp(); - abstract public gnu.expr.ClassExp getClassExp(); - - abstract void precompile(); - - /** This native method is redefined for this Nice class. */ - abstract public gnu.expr.Expression addJavaMethod(gnu.expr.LambdaExp method); - /** Returns an expression to call a super method from outside a class method. --- 35,40 ---- *************** *** 81,88 **** stub. */ - abstract gnu.expr.Expression callSuperMethod(gnu.bytecode.Method superMethod); - abstract public Definition importMethod(gnu.bytecode.Method method); - - abstract public mlsub.typing.Monotype[] getTypeParameters(); } --- 45,48 ---- Index: niceclass.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/niceclass.nice,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** niceclass.nice 3 Jan 2005 01:24:28 -0000 1.12 --- niceclass.nice 4 Jan 2005 21:20:39 -0000 1.13 *************** *** 59,72 **** getName() = definition.getName(); ! getDefinition() = definition; ! getTypeParameters() = definition.getTypeParameters(); ! addField(sym, value, isFinal, isTransient, isVolatile, docString) { if (this.isInterface()) bossa.util.User.error(sym, "An interface cannot have a field."); ! if (isFinal && notNull(sym).getName().toString().equals("serialVersionUID")) { if (value instanceof ConstantExp && value.value instanceof Long) --- 59,73 ---- getName() = definition.getName(); ! TypeDefinition getDefinition() = definition; ! public mlsub.typing.Monotype[] getTypeParameters() = definition.getTypeParameters(); ! public void addField(MonoSymbol sym, ?Expression value, boolean isFinal, ! boolean isTransient, boolean isVolatile, ?String docString) { if (this.isInterface()) bossa.util.User.error(sym, "An interface cannot have a field."); ! if (isFinal && sym.getName().toString().equals("serialVersionUID")) { if (value instanceof ConstantExp && value.value instanceof Long) *************** *** 81,85 **** throw bossa.util.User.error(sym, "A field cannot be final and volatile"); ! fields.add(new NewField(declaringClass: this, sym: notNull(sym), value: value, isFinal_: isFinal, isVolatile: isVolatile, isTransient: isTransient, docString: docString)); --- 82,86 ---- throw bossa.util.User.error(sym, "A field cannot be final and volatile"); ! fields.add(new NewField(declaringClass: this, sym: sym, value: value, isFinal_: isFinal, isVolatile: isVolatile, isTransient: isTransient, docString: docString)); *************** *** 102,113 **** } ! isInterface() = definition instanceof InterfaceDefinition; ?CNiceClass getParent() { ! return cast(NiceClass.get(definition.getSuperClass())); } ! addConstructorCallSymbol(sym) { constructors.add(cast(sym)); --- 103,119 ---- } ! public boolean isInterface() = definition instanceof InterfaceDefinition; ?CNiceClass getParent() { ! let superTC = definition.getSuperClass(); ! if (superTC == null) ! return null; ! ! return getNiceClass(superTC); } ! // FIXME change to MethodSymbol once this is converted to nice ! void addConstructorCallSymbol(VarSymbol sym) { constructors.add(cast(sym)); *************** *** 243,247 **** } ! getInitializer() { if (initializerMethod != null) --- 249,253 ---- } ! ?gnu.expr.Expression getInitializer() { if (initializerMethod != null) *************** *** 368,372 **** } ! getClassExp() = classe; /** --- 374,378 ---- } ! public gnu.expr.ClassExp getClassExp() = classe; /** *************** *** 458,467 **** let supTC = definition.getSuperClass(); ! let ?NiceClass sup = (supTC == null) ? null : NiceClass.get(supTC); List<(?MethodDeclaration, List<Parameter>)> res; if (sup == null) res = this.getNativeConstructorParameters(cast(supTC)); else ! res = cast(sup).getParentConstructorParameters(typeParameters, constraints); /** --- 464,473 ---- let supTC = definition.getSuperClass(); ! let ?CNiceClass sup = (supTC == null) ? null : getNiceClass(supTC); List<(?MethodDeclaration, List<Parameter>)> res; if (sup == null) res = this.getNativeConstructorParameters(cast(supTC)); else ! res = sup.getParentConstructorParameters(typeParameters, constraints); /** *************** *** 571,575 **** } ! precompile() { // We have to do this after resolution, so that bytecode types are known, --- 577,581 ---- } ! void precompile() { // We have to do this after resolution, so that bytecode types are known, *************** *** 629,633 **** /** This native method is redefined for this Nice class. */ ! addJavaMethod(method) = classe.addMethod(method); private gnu.expr.LambdaExp createJavaMethod(String name, --- 635,639 ---- /** This native method is redefined for this Nice class. */ ! public gnu.expr.Expression addJavaMethod(gnu.expr.LambdaExp method) = classe.addMethod(method); private gnu.expr.LambdaExp createJavaMethod(String name, *************** *** 648,652 **** stub. */ ! callSuperMethod(superMethod) { gnu.expr.Expression[] params = cast(new gnu.expr.Expression --- 654,658 ---- stub. */ ! gnu.expr.Expression callSuperMethod(gnu.bytecode.Method superMethod) { gnu.expr.Expression[] params = cast(new gnu.expr.Expression *************** *** 731,735 **** } ! NiceClass createNiceClass(TypeDefinition cdef) = new CNiceClass(definition: cdef); private TypeSymbol asTypeSymbol(mlsub.typing.Monotype type) --- 737,741 ---- } ! CNiceClass createNiceClass(TypeDefinition cdef) = new CNiceClass(definition: cdef); private TypeSymbol asTypeSymbol(mlsub.typing.Monotype type) *************** *** 753,754 **** --- 759,777 ---- return new gnu.expr.QuoteExp(nice.tools.code.Types.javaType(tc)); } + + ?CNiceClass getNiceClass(TypeConstructor tc) + { + let res = getTypeDefinition(tc); + if (res != null && res.getImplementation() instanceof NiceClass) + return cast(res.getImplementation()); + else + return null; + } + + public ?CNiceClass getNiceClass(mlsub.typing.Monotype type) + { + if (! nice.tools.typing.Types.isSure(type)) + return null; + + return getNiceClass(nice.tools.typing.Types.constructor(type)); + } \ No newline at end of file Index: niceMethod.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/niceMethod.nice,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** niceMethod.nice 3 Jan 2005 01:24:28 -0000 1.8 --- niceMethod.nice 4 Jan 2005 21:20:39 -0000 1.9 *************** *** 361,370 **** // Try to compile the dispatch method as a member method if possible. ! ?NiceClass receiver; if (argTypes.length == 0) receiver = null; else { ! receiver = NiceClass.get(def.getArgTypes()[0]); // JVM interfaces cannot contain code. --- 361,370 ---- // Try to compile the dispatch method as a member method if possible. ! ?CNiceClass receiver; if (argTypes.length == 0) receiver = null; else { ! receiver = getNiceClass(def.getArgTypes()[0]); // JVM interfaces cannot contain code. Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.90 retrieving revision 1.91 diff -C2 -d -r1.90 -r1.91 *** tools.nice 3 Jan 2005 01:24:28 -0000 1.90 --- tools.nice 4 Jan 2005 21:20:40 -0000 1.91 *************** *** 223,229 **** ?mlsub.typing.Constraint getConstraint(mlsub.typing.Polytype) = native mlsub.typing.Constraint mlsub.typing.Polytype.getConstraint(); mlsub.typing.AtomicConstraint[?] AtomicConstraint_substitute(java.util.Map<mlsub.typing.TypeSymbol,mlsub.typing.TypeSymbol>, AtomicConstraint[?]) = native mlsub.typing.AtomicConstraint[] mlsub.typing.AtomicConstraint.substitute(java.util.Map, mlsub.typing.AtomicConstraint[]); - ?gnu.expr.Expression getInitializer(NiceClass) = native gnu.expr.Expression NiceClass.getInitializer(); - void addConstructorCallSymbol(NiceClass, VarSymbol) = native void NiceClass.addConstructorCallSymbol(VarSymbol); - gnu.expr.Expression callSuperMethod(NiceClass, gnu.bytecode.Method) = native gnu.expr.Expression NiceClass.callSuperMethod(gnu.bytecode.Method); Module module(Definition) = native Definition.module; ?Definition importMethod(NiceClass, gnu.bytecode.Method) = native Definition NiceClass.importMethod(gnu.bytecode.Method); --- 223,226 ---- *************** *** 237,242 **** ?Variance makeVariance(List<int>) = native Variance MethodContainer.makeVariance(List); List<AtomicConstraint> getAtoms(Constraint) = native List Constraint.getAtoms(); - ?mlsub.typing.Interface getAssociatedInterface(TypeDefinition) = native mlsub.typing.Interface TypeDefinition.getAssociatedInterface(); - ?mlsub.typing.Polytype getConstrainedType(TypeDefinition) = native mlsub.typing.Polytype TypeDefinition.getConstrainedType(); mlsub.typing.Monotype[?] resolve(TypeMap, Monotype[?]) = native mlsub.typing.Monotype[] Monotype.resolve(TypeMap, Monotype[]); MethodContainer.Constraint MethodContainer$Constraint(TypeSymbol[], List<AtomicConstraint>, ?mlsub.typing.Monotype[], Location) --- 234,237 ---- Index: typedef.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typedef.nice,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** typedef.nice 20 Dec 2004 16:05:19 -0000 1.8 --- typedef.nice 4 Jan 2005 21:20:51 -0000 1.9 *************** *** 30,34 **** */ ! public abstract class CTypeDefinition extends TypeDefinition { Modifiers modifiers = new Modifiers(); --- 30,34 ---- */ ! public abstract class TypeDefinition extends MethodContainer { Modifiers modifiers = new Modifiers(); *************** *** 71,75 **** } ! isConcrete() = !modifiers.isAbstract(); implementsJavaInterface(name) --- 71,75 ---- } ! boolean isConcrete() = !modifiers.isAbstract(); implementsJavaInterface(name) *************** *** 86,90 **** getTypeSymbol() = tc; ! getAssociatedInterface() = null; getSuperClass() = null; --- 86,90 ---- getTypeSymbol() = tc; ! ?mlsub.typing.Interface getAssociatedInterface() = null; getSuperClass() = null; *************** *** 92,96 **** getSuperClassDefinition() = null; ! getTC() = tc; getImplementedInterfaces() --- 92,96 ---- getSuperClassDefinition() = null; ! mlsub.typing.TypeConstructor getTC() = tc; getImplementedInterfaces() *************** *** 143,147 **** } ! getLocalScope() { TypeScope localScope = notNull(typeScope); --- 143,147 ---- } ! TypeScope getLocalScope() { TypeScope localScope = notNull(typeScope); *************** *** 178,182 **** or null if this class has no constraint on its type parameters. */ ! getConstrainedType() { ?mlsub.typing.Constraint cst = this.getResolvedConstraint(); --- 178,182 ---- or null if this class has no constraint on its type parameters. */ ! ?mlsub.typing.Polytype getConstrainedType() { ?mlsub.typing.Constraint cst = this.getResolvedConstraint(); *************** *** 341,345 **** } ! typecheckClass() { notNull(implementation).typecheck(); --- 341,345 ---- } ! void typecheckClass() { notNull(implementation).typecheck(); *************** *** 351,358 **** } ! precompile() { let impl = implementation; ! if (impl != null && impl instanceof NiceClass) impl.precompile(); } --- 351,358 ---- } ! void precompile() { let impl = implementation; ! if (impl != null && impl instanceof CNiceClass) impl.precompile(); } *************** *** 366,370 **** Called instead of compile if the package is up-to-date. */ ! recompile() { notNull(implementation).recompile(); --- 366,370 ---- Called instead of compile if the package is up-to-date. */ ! void recompile() { notNull(implementation).recompile(); *************** *** 427,431 **** getInterfaces() = interfaces.toArray(); ! addInterfaceImplementation(itf) { if (itf != null) --- 427,431 ---- getInterfaces() = interfaces.toArray(); ! void addInterfaceImplementation(?Interface itf) { if (itf != null) *************** *** 435,439 **** getJavaInterfaces() = javaInterfaces; ! setJavaType(javaType) { if (javaType == null) --- 435,439 ---- getJavaInterfaces() = javaInterfaces; ! void setJavaType(?gnu.bytecode.Type javaType) { if (javaType == null) *************** *** 444,455 **** } ! getJavaType() = notNull(javaType); ! setImplementation(implementation) { this.implementation = implementation; } ! getImplementation() = notNull(implementation); getBytecodeFlags() = modifiers.getBits(); --- 444,455 ---- } ! gnu.bytecode.Type getJavaType() = notNull(javaType); ! public void setImplementation(ClassImplementation implementation) { this.implementation = implementation; } ! ClassImplementation getImplementation() = notNull(implementation); getBytecodeFlags() = modifiers.getBits(); *************** *** 459,463 **** * Definition for a class */ ! class ClassDefinition extends CTypeDefinition { // Super class --- 459,463 ---- * Definition for a class */ ! class ClassDefinition extends TypeDefinition { // Super class *************** *** 538,542 **** * Definition for an interface */ ! class InterfaceDefinition extends CTypeDefinition { ?mlsub.typing.Interface associatedInterface = null; --- 538,542 ---- * Definition for an interface */ ! class InterfaceDefinition extends TypeDefinition { ?mlsub.typing.Interface associatedInterface = null; *************** *** 709,712 **** --- 709,728 ---- tcToTypeDef.get( itf.associatedTC() ); + //used in mlsub.typing.Enumeration + public ?mlsub.typing.Constraint getTypeDefResolvedConstraint(mlsub.typing.TypeConstructor tc) + { + let def = getTypeDefinition(tc); + if (def == null) + return null; + + return def.getResolvedConstraint(); + } + + //used in mlsub.typing.Enumeration + public mlsub.typing.Monotype[] getTypeDefTypeParameters(mlsub.typing.TypeConstructor tc) + { + return notNull(getTypeDefinition(tc)).getTypeParameters(); + } + /** Returns a monotype based on this tc, provided that the class *************** *** 715,719 **** ?mlsub.typing.Monotype getTypeWithTC(TypeConstructor tc) { ! ?CTypeDefinition def = cast(getTypeDefinition(tc)); if (def == null) --- 731,735 ---- ?mlsub.typing.Monotype getTypeWithTC(TypeConstructor tc) { ! ?TypeDefinition def = cast(getTypeDefinition(tc)); if (def == null) *************** *** 744,748 **** ?mlsub.typing.Monotype getTypeWithTC(TypeConstructor tc, mlsub.typing.Monotype[] sourceParams ) { ! ?CTypeDefinition def = cast(getTypeDefinition(tc)); if (def == null) --- 760,764 ---- ?mlsub.typing.Monotype getTypeWithTC(TypeConstructor tc, mlsub.typing.Monotype[] sourceParams ) { ! ?TypeDefinition def = cast(getTypeDefinition(tc)); if (def == null) *************** *** 784,788 **** // Variance lookup ! getVariance(CTypeDefinition t) { int arity = getVariance(t.implementations); --- 800,804 ---- // Variance lookup ! getVariance(TypeDefinition t) { int arity = getVariance(t.implementations); Index: methodImplementation.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/methodImplementation.nice,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** methodImplementation.nice 2 Jan 2005 02:20:59 -0000 1.6 --- methodImplementation.nice 4 Jan 2005 21:20:39 -0000 1.7 *************** *** 15,30 **** import bossa.util.*; - /* - import nice.tools.typing.Types; - import nice.tools.code.Gen; - import mlsub.typing.Typing; - import mlsub.typing.TypeConstructor; - import mlsub.typing.Monotype; - import mlsub.typing.MonotypeVar; - import gnu.bytecode.*; - import bossa.util.Debug; - import bossa.util.User; - */ - /** An implementation of a method --- 15,18 ---- *************** *** 211,215 **** return; ! NiceClass c = cast(def.getImplementation()); gnu.expr.Expression[] params = cast(new gnu.expr.Expression[arity]); --- 199,203 ---- return; ! CNiceClass c = cast(def.getImplementation()); gnu.expr.Expression[] params = cast(new gnu.expr.Expression[arity]); --- TypeDefinition.java DELETED --- Index: super.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/super.nice,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** super.nice 2 Jan 2005 02:20:59 -0000 1.7 --- super.nice 4 Jan 2005 21:20:39 -0000 1.8 *************** *** 169,173 **** // the base method), a call to super is emited. { ! let NiceClass nc = cast(notNull(getTypeDefinition(notNull(currentMethod).firstArgument())).getImplementation()); code = nc.callSuperMethod(notNull(superMethod)); } --- 169,173 ---- // the base method), a call to super is emited. { ! let CNiceClass nc = cast(notNull(getTypeDefinition(notNull(currentMethod).firstArgument())).getImplementation()); code = nc.callSuperMethod(notNull(superMethod)); } Index: importedconstructor.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/importedconstructor.nice,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** importedconstructor.nice 3 Jan 2005 01:24:28 -0000 1.7 --- importedconstructor.nice 4 Jan 2005 21:20:39 -0000 1.8 *************** *** 86,90 **** } ! public ?ImportedConstructor loadImportedConstructor(NiceClass def, gnu.bytecode.Method method) { if (! method.isConstructor()) --- 86,90 ---- } ! public ?ImportedConstructor loadImportedConstructor(CNiceClass def, gnu.bytecode.Method method) { if (! method.isConstructor()) Index: dispatch.java.bootstrap =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/dispatch.java.bootstrap,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** dispatch.java.bootstrap 2 Jan 2005 02:20:59 -0000 1.49 --- dispatch.java.bootstrap 4 Jan 2005 21:20:39 -0000 1.50 *************** *** 26,34 **** public static void resetConstructorsMap() {} - static boolean instantiableTC(mlsub.typing.TypeConstructor tc) - { return false; } - - public static void loadJavaMethods(String name) {} - public static mlsub.typing.TypeConstructor lookupJavaClass(String className, bossa.util.Location loc) { return null; } --- 26,29 ---- *************** *** 42,58 **** { return null;} - static Expression analyse(Expression e, VarScope v, TypeScope t) - { return null; } - - static Expression analyse(Expression e, Info i) - { return null; } - - static void typecheck(Expression e) {} - public static void resetTypeDefinitionMappings() {} ! public static TypeDefinition getTypeDefinition(mlsub.typing.TypeConstructor tc) { return null; } public static mlsub.typing.Monotype getTypeWithTC(mlsub.typing.TypeConstructor tc, mlsub.typing.Monotype[] sourceParams ) { return null; } --- 37,48 ---- { return null;} public static void resetTypeDefinitionMappings() {} ! public static mlsub.typing.Constraint getTypeDefResolvedConstraint(mlsub.typing.TypeConstructor tc) { return null; } + public static mlsub.typing.Monotype[] getTypeDefTypeParameters(mlsub.typing.TypeConstructor tc) + { return null; } + public static mlsub.typing.Monotype getTypeWithTC(mlsub.typing.TypeConstructor tc, mlsub.typing.Monotype[] sourceParams ) { return null; } *************** *** 63,66 **** public static void _printStackTraceWithSourceInfo(Throwable t) {} } - - class Info {} --- 53,54 ---- Index: constructor.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/constructor.nice,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** constructor.nice 3 Jan 2005 01:24:28 -0000 1.4 --- constructor.nice 4 Jan 2005 21:20:39 -0000 1.5 *************** *** 23,27 **** abstract class Constructor extends MethodDeclaration { ! NiceClass classe; final boolean isDefault; --- 23,27 ---- abstract class Constructor extends MethodDeclaration { ! CNiceClass classe; final boolean isDefault; |
From: Arjan B. <ar...@us...> - 2005-01-04 21:21:50
|
Update of /cvsroot/nice/Nice/src/mlsub/typing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20863/F:/nice/src/mlsub/typing Modified Files: Enumeration.java Log Message: Removed some superfluous conversion constructs. Index: Enumeration.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/Enumeration.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Enumeration.java 1 Dec 2004 02:00:13 -0000 1.17 --- Enumeration.java 4 Jan 2005 21:20:21 -0000 1.18 *************** *** 367,376 **** TypeConstructor sol) { ! bossa.syntax.TypeDefinition def = bossa.syntax.dispatch.getTypeDefinition(sol); ! ! if (def == null) ! return true; ! ! Constraint constraint = def.getResolvedConstraint(); if (mlsub.typing.Constraint.trivial(constraint)) --- 367,371 ---- TypeConstructor sol) { ! Constraint constraint = bossa.syntax.dispatch.getTypeDefResolvedConstraint(sol); if (mlsub.typing.Constraint.trivial(constraint)) *************** *** 395,399 **** Typing.introduce(tc); MonotypeConstructor type = ! new MonotypeConstructor(tc, def.getTypeParameters()); try { --- 390,394 ---- Typing.introduce(tc); MonotypeConstructor type = ! new MonotypeConstructor(tc, bossa.syntax.dispatch.getTypeDefTypeParameters(sol)); try { |
From: Arjan B. <ar...@us...> - 2005-01-04 21:21:18
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20863/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Removed some superfluous conversion constructs. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.296 retrieving revision 1.297 diff -C2 -d -r1.296 -r1.297 *** Parser.jj 3 Jan 2005 01:24:11 -0000 1.296 --- Parser.jj 4 Jan 2005 21:20:00 -0000 1.297 *************** *** 1090,1094 **** javaName=doted_string() { res.setImplementation(new JavaClass(res, javaName)); } ! | { res.setImplementation(bossa.syntax.dispatch.createPrimitiveType(res)); } ) ";" ) --- 1090,1094 ---- javaName=doted_string() { res.setImplementation(new JavaClass(res, javaName)); } ! | { res.setImplementation(res.createPrimitiveType()); } ) ";" ) |
From: Arjan B. <ar...@us...> - 2005-01-04 18:21:17
|
Update of /cvsroot/nice/Nice In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16577/Nice Modified Files: Makefile Log Message: Explicitly compile the mlsub.typing package. Index: Makefile =================================================================== RCS file: /cvsroot/nice/Nice/Makefile,v retrieving revision 1.155 retrieving revision 1.156 diff -C2 -d -r1.155 -r1.156 *** Makefile 7 Dec 2004 02:07:07 -0000 1.155 --- Makefile 4 Jan 2005 18:20:55 -0000 1.156 *************** *** 161,165 **** ${JAVAC} \ src/bossa/syntax/dispatch.java \ ! src/mlsub/typing/TypeConstructorLeqMonotypeCst.java \ src/gnu/expr/*.java \ stdlib/nice/lang/{Native,rawArray}.java \ --- 161,165 ---- ${JAVAC} \ src/bossa/syntax/dispatch.java \ ! src/mlsub/typing/*.java \ src/gnu/expr/*.java \ stdlib/nice/lang/{Native,rawArray}.java \ |
From: Arjan B. <ar...@us...> - 2005-01-03 01:25:02
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22850/F:/nice/src/bossa/parser Modified Files: JavaccParser.java Parser.jj Log Message: Converted FormalParameters. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.295 retrieving revision 1.296 diff -C2 -d -r1.295 -r1.296 *** Parser.jj 2 Jan 2005 02:20:57 -0000 1.295 --- Parser.jj 3 Jan 2005 01:24:11 -0000 1.296 *************** *** 854,858 **** } ! FormalParameters.Parameter formalParameter(List statements): { Monotype t; --- 854,858 ---- } ! Parameter formalParameter(List statements): { Monotype t; *************** *** 864,868 **** LOOKAHEAD(monotype()) t=monotype() [ id=ident() [ "=" val=Expression() ]] ! { return FormalParameters.createParameter(t, id ,val); } | { Token first,last; --- 864,868 ---- LOOKAHEAD(monotype()) t=monotype() [ id=ident() [ "=" val=Expression() ]] ! { return bossa.syntax.dispatch.createParameter(t, id ,val); } | { Token first,last; *************** *** 886,890 **** t.nullness = Monotype.absent; ! return FormalParameters.createParameter(t, ident ,val); } ) --- 886,890 ---- t.nullness = Monotype.absent; ! return bossa.syntax.dispatch.createParameter(t, ident ,val); } ) *************** *** 894,898 **** { List params = new LinkedList(); ! FormalParameters.Parameter p; } { --- 894,898 ---- { List params = new LinkedList(); ! Parameter p; } { *************** *** 902,906 **** ( "," p = formalParameter(statements) { params.add(p); } )* ] ! { return new FormalParameters(params.isEmpty() ? null : params ); } } --- 902,906 ---- ( "," p = formalParameter(statements) { params.add(p); } )* ] ! { return bossa.syntax.dispatch.createFormalParameters(params.isEmpty() ? null : params ); } } Index: JavaccParser.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/JavaccParser.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** JavaccParser.java 1 Jul 2004 10:46:18 -0000 1.2 --- JavaccParser.java 3 Jan 2005 01:24:11 -0000 1.3 *************** *** 86,90 **** ! public FormalParameters formalParameters(String parameters) { try { --- 86,90 ---- ! public /*bossa.syntax.FormalParameters*/Object formalParameters(String parameters) { try { |
From: Arjan B. <ar...@us...> - 2005-01-03 01:24:55
|
Update of /cvsroot/nice/Nice/src/bossa/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22850/F:/nice/src/bossa/modules Modified Files: Parser.java Log Message: Converted FormalParameters. Index: Parser.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/Parser.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Parser.java 30 Jun 2004 14:12:37 -0000 1.1 --- Parser.java 3 Jan 2005 01:24:12 -0000 1.2 *************** *** 29,32 **** void read(Reader r, List definitions); ! bossa.syntax.FormalParameters formalParameters(String parameters); } --- 29,32 ---- void read(Reader r, List definitions); ! /*bossa.syntax.FormalParameters*/Object formalParameters(String parameters); } |
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22850/F:/nice/src/bossa/syntax Modified Files: VarSymbol.java analyse.nice constructor.nice defaultMethod.nice defaultconstructor.nice importedconstructor.nice methodbody.nice niceMethod.nice niceclass.nice nicefield.nice nicefieldaccess.nice overloadedsymbol.nice symbol.nice symbolexp.nice tools.nice Added Files: formalParameters.nice Removed Files: FormalParameters.java Log Message: Converted FormalParameters. Index: analyse.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/analyse.nice,v retrieving revision 1.121 retrieving revision 1.122 diff -C2 -d -r1.121 -r1.122 *** analyse.nice 31 Dec 2004 18:40:45 -0000 1.121 --- analyse.nice 3 Jan 2005 01:24:12 -0000 1.122 *************** *** 520,530 **** VarSymbol sym = symbols[0]; ! if (sym instanceof FormalParameters.Parameter.Symbol) { int state = sym.getState(); ! if (state == 0/*XXX: FormalParameters.Parameter.Symbol.NOT_ACCESSIBLE*/) throw error(e, "Parameter " + e + " is not accessible"); ! if (state == 1/*XXX: FormalParameters.Parameter.Symbol.ARGUMENT_REFERENCE*/) return createParameterAccessExp(sym, e.location()); // Otherwise, we are in the normal case. --- 520,530 ---- VarSymbol sym = symbols[0]; ! if (sym instanceof ParameterSymbol) { int state = sym.getState(); ! if (state == NOT_ACCESSIBLE) throw error(e, "Parameter " + e + " is not accessible"); ! if (state == ARGUMENT_REFERENCE) return createParameterAccessExp(sym, e.location()); // Otherwise, we are in the normal case. Index: methodbody.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/methodbody.nice,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** methodbody.nice 2 Jan 2005 02:20:59 -0000 1.8 --- methodbody.nice 3 Jan 2005 01:24:28 -0000 1.9 *************** *** 197,201 **** for (int i = params.hasThis() ? 1 : 0; i < formals.length; i++) if (formals[i].atAny() && formals[i].name != null && params.getName(i) != null && ! !notNull(formals[i].name).toString().equals(params.getName(i).toString())) { errorList.add(m, new LocatedString("Parameter " + formals[i] + " should be called " + params.getName(i), --- 197,201 ---- for (int i = params.hasThis() ? 1 : 0; i < formals.length; i++) if (formals[i].atAny() && formals[i].name != null && params.getName(i) != null && ! !notNull(formals[i].name).toString().equals(notNull(params.getName(i)).toString())) { errorList.add(m, new LocatedString("Parameter " + formals[i] + " should be called " + params.getName(i), Index: defaultconstructor.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/defaultconstructor.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** defaultconstructor.nice 2 Jan 2005 02:20:59 -0000 1.3 --- defaultconstructor.nice 3 Jan 2005 01:24:28 -0000 1.4 *************** *** 75,79 **** let thisExp = new gnu.expr.ThisExp(thisDecl); ! let fullArgs = notNull(notNull(parameters).getMonoSymbols()); let fullArgTypes = this.javaArgTypes(); --- 75,79 ---- let thisExp = new gnu.expr.ThisExp(thisDecl); ! let fullArgs = notNull(parameters).getMonoSymbols(); let fullArgTypes = this.javaArgTypes(); Index: nicefield.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/nicefield.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** nicefield.nice 25 Nov 2004 19:28:18 -0000 1.3 --- nicefield.nice 3 Jan 2005 01:24:28 -0000 1.4 *************** *** 50,60 **** } ! FormalParameters.Parameter asParameter() { Monotype type = notNull(sym.syntacticType); if (value == null) ! return new FormalParameters.NamedParameter(type, sym.getName(), true); else ! return new FormalParameters.OptionalParameter (type, sym.getName(), true, value); } --- 50,61 ---- } ! Parameter asParameter() { Monotype type = notNull(sym.syntacticType); if (value == null) ! return new NamedParameter(type: type, name: sym.getName(), nameRequired: true); else ! return new OptionalParameter(type: type, name: sym.getName(), ! nameRequired: true, defaultValue: notNull(value)); } *************** *** 130,135 **** } ! void checkNoDuplicate(List<FormalParameters.Parameter> fields, ! int rankInThisClass) { /* --- 131,135 ---- } ! void checkNoDuplicate(List<Parameter> fields, int rankInThisClass) { /* *************** *** 159,163 **** to this overriding. */ ! void updateConstructorParameter(List<FormalParameters.Parameter> inherited) { String name = sym.getName().toString(); --- 159,163 ---- to this overriding. */ ! void updateConstructorParameter(List<Parameter> inherited) { String name = sym.getName().toString(); *************** *** 170,176 **** { if (value != null) ! inherited[i] = new FormalParameters.OptionalParameter(type, ! sym.getName(), true, value, ! param.value() == null || param.isOverriden()); else param.resetType(type); --- 170,176 ---- { if (value != null) ! inherited[i] = new OptionalParameter(type: type, ! name: sym.getName(), nameRequired: true, defaultValue: notNull(value), ! overriden: param.value() == null || param.isOverriden()); else param.resetType(type); *************** *** 254,258 **** boolean hasName(LocatedString name) = this.name.equals(name); ! void updateConstructorParameter(List<FormalParameters.Parameter> inherited) { for (int i = 0; i < inherited.size(); i++) --- 254,258 ---- boolean hasName(LocatedString name) = this.name.equals(name); ! void updateConstructorParameter(List<Parameter> inherited) { for (int i = 0; i < inherited.size(); i++) *************** *** 260,265 **** let param = inherited[i]; if (param.match(name.toString())) ! inherited[i] = new FormalParameters.OptionalParameter(param.type, ! name, true, value, param.value() == null || param.isOverriden()); } } --- 260,266 ---- let param = inherited[i]; if (param.match(name.toString())) ! inherited[i] = new OptionalParameter(type: param.type, ! name: name, nameRequired: true, defaultValue: value, ! overriden: param.value() == null || param.isOverriden()); } } --- FormalParameters.java DELETED --- Index: niceclass.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/niceclass.nice,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** niceclass.nice 2 Jan 2005 02:20:59 -0000 1.11 --- niceclass.nice 3 Jan 2005 01:24:28 -0000 1.12 *************** *** 231,235 **** Monotype.sure(new mlsub.typing.MonotypeConstructor(definition.getTC(), definition.getTypeParameters())); ! thisSymbol = new ThisSymbol(FormalParameters.thisName, thisType, declaringClass: this); Node.thisExp = createSymbolExp(notNull(thisSymbol), definition.location()); --- 231,235 ---- Monotype.sure(new mlsub.typing.MonotypeConstructor(definition.getTC(), definition.getTypeParameters())); ! thisSymbol = new ThisSymbol(thisName, thisType, declaringClass: this); Node.thisExp = createSymbolExp(notNull(thisSymbol), definition.location()); *************** *** 374,378 **** on the type parameters. */ ! private List<(?MethodDeclaration, List<FormalParameters.Parameter>)> getNativeConstructorParameters(TypeConstructor tc) { --- 374,378 ---- on the type parameters. */ ! private List<(?MethodDeclaration, List<Parameter>)> getNativeConstructorParameters(TypeConstructor tc) { *************** *** 384,388 **** } ! List<(?MethodDeclaration, List<FormalParameters.Parameter>)> res = new ArrayList(constructors.size()); --- 384,388 ---- } ! List<(?MethodDeclaration, List<Parameter>)> res = new ArrayList(constructors.size()); *************** *** 400,406 **** } ! List<FormalParameters.Parameter> params = new ArrayList(); for (arg : m.getArgTypes()) ! params.add(new FormalParameters.Parameter(Monotype.create(arg))); res.add((m, params)); --- 400,406 ---- } ! List<Parameter> params = new ArrayList(); for (arg : m.getArgTypes()) ! params.add(new Parameter(type: Monotype.create(arg))); res.add((m, params)); *************** *** 410,414 **** } ! private List<(?MethodDeclaration, List<FormalParameters.Parameter>)> getParentConstructorParameters(mlsub.typing.Monotype[?] typeParameters, ?List<mlsub.typing.AtomicConstraint> constraints) --- 410,414 ---- } ! private List<(?MethodDeclaration, List<Parameter>)> getParentConstructorParameters(mlsub.typing.Monotype[?] typeParameters, ?List<mlsub.typing.AtomicConstraint> constraints) *************** *** 433,437 **** } ! List<(?MethodDeclaration, List<FormalParameters.Parameter>)> res = new ArrayList(); for (msym : constructors) { --- 433,437 ---- } ! List<(?MethodDeclaration, List<Parameter>)> res = new ArrayList(); for (msym : constructors) { *************** *** 452,456 **** } ! private List<(?MethodDeclaration, List<FormalParameters.Parameter>)> getConstructorParameters(?List<mlsub.typing.AtomicConstraint> constraints, mlsub.typing.Monotype[] typeParameters) --- 452,456 ---- } ! private List<(?MethodDeclaration, List<Parameter>)> getConstructorParameters(?List<mlsub.typing.AtomicConstraint> constraints, mlsub.typing.Monotype[] typeParameters) *************** *** 459,463 **** let ?NiceClass sup = (supTC == null) ? null : NiceClass.get(supTC); ! List<(?MethodDeclaration, List<FormalParameters.Parameter>)> res; if (sup == null) res = this.getNativeConstructorParameters(cast(supTC)); --- 459,463 ---- let ?NiceClass sup = (supTC == null) ? null : NiceClass.get(supTC); ! List<(?MethodDeclaration, List<Parameter>)> res; if (sup == null) res = this.getNativeConstructorParameters(cast(supTC)); *************** *** 472,476 **** for (cparams : res) { ! (?MethodDeclaration m, List<FormalParameters.Parameter> params) = cparams; for (or : overrides) --- 472,476 ---- for (cparams : res) { ! (?MethodDeclaration m, List<Parameter> params) = cparams; for (or : overrides) *************** *** 484,488 **** for (cparams : res) { ! (?MethodDeclaration m, List<FormalParameters.Parameter> params) = cparams; for (field : fields) params.add(field.asParameter()); --- 484,488 ---- for (cparams : res) { ! (?MethodDeclaration m, List<Parameter> params) = cparams; for (field : fields) params.add(field.asParameter()); *************** *** 498,502 **** This must be done only once per class. */ ! private void checkFields(List<FormalParameters.Parameter> allFields) { for (int f = 0; f < fields.size(); f++) --- 498,502 ---- This must be done only once per class. */ ! private void checkFields(List<Parameter> allFields) { for (int f = 0; f < fields.size(); f++) *************** *** 530,534 **** mlsub.typing.Monotype[] typeParameters = definition.getTypeParameters(); ! List<(?MethodDeclaration, List<FormalParameters.Parameter>)> allConstructorParams = this.getConstructorParameters(constraints, typeParameters); --- 530,534 ---- mlsub.typing.Monotype[] typeParameters = definition.getTypeParameters(); ! List<(?MethodDeclaration, List<Parameter>)> allConstructorParams = this.getConstructorParameters(constraints, typeParameters); *************** *** 542,546 **** for (int i = 0; i < allConstructorParams.size(); i++) { ! (?MethodDeclaration parent, List<FormalParameters.Parameter> params) = allConstructorParams[i]; // Check only once. --- 542,546 ---- for (int i = 0; i < allConstructorParams.size(); i++) { ! (?MethodDeclaration parent, List<Parameter> params) = allConstructorParams[i]; // Check only once. *************** *** 548,552 **** this.checkFields(params); ! FormalParameters values = new FormalParameters(params.toArray()); mlsub.typing.Constraint specificCst = cst; --- 548,552 ---- this.checkFields(params); ! FormalParameters values = createFormalParameters(params); mlsub.typing.Constraint specificCst = cst; --- NEW FILE: formalParameters.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package bossa.syntax; import bossa.util.*; /** Parameters of a method declaration. */ public class FormalParameters extends Node { private Parameter[] parameters; int size; void addThis(Monotype type) { if (parameters[0] != null) Internal.error("No room for \"this\""); parameters[0] = new NamedParameter(type: type, name: thisName); } boolean hasThis() { return parameters.length > 0 && parameters[0].match("this"); } /** @return the name of the <code>rank</code>th parameter, or null if it is an anonymous parameter. */ public ?LocatedString getName(int rank) { return parameters[rank].getName(); } boolean hasDefaultValue(int rank) { Parameter p = parameters[rank]; return p.value() != null && ! p.isOverriden(); } boolean hasDefaultValue() { for (int i = size; --i>=0; ) if (parameters[i].value() != null) return true; return false; } boolean containsAlike() { for (int i = size; --i>=0; ) if (parameters[i] != null && parameters[i].type.containsAlike()) return true; return false; } void substitute(Map<java.lang.String, bossa.syntax.Monotype> map) { for (int i = size; --i>=0; ) if (parameters[i] != null) // it is the case for "this" placeholder parameters[i].type = parameters[i].type.substitute(map); } Monotype[?] types() { if (parameters.length == 0) return null; Monotype[] res = cast(new Monotype[size]); for (int i = 0; i < size; i++) res[i] = parameters[i].type; return res; } public MonoSymbol[] getMonoSymbols() { MonoSymbol[] res = cast(new MonoSymbol[size]); for (int i = 0; i < size; i++) res[i] = parameters[i].getSymbol(); return res; } void typecheck(mlsub.typing.Monotype[] domain) { for (int i = 0; i<size; i++) parameters[i].typecheck(domain[i]); } resolve() { for (int i = 0; i<size; i++) parameters[i].resolve(scope, typeScope); for (int i = 0; i<size; i++) if (parameters[i].symbol != null) notNull(parameters[i].symbol).state = ACCESSIBLE; } /** This is a hack to allow bossa.syntax.analyse to make the default values be resolved. */ void resolveCalledFromAnalyse(Info info) { for (int i = 0; i<size; i++) parameters[i].resolve(info); } /** Check if arguments match the formal parameters. If succesfull, append to <code>args</code>'s applicationExpressions the computed array of expressions, that denote the call, including the default values of the optional parameters not passed. */ // FIXME change VarSymbol to FunSymbol once converted to nice boolean match(Arguments args, VarSymbol symbol) { int[] map = new int[size]; // first pass, fill holes with names given at the call site for (int i = 0; i< args.size(); i++) { Arguments.Argument a = args.get(i); if (a.name != null) if (this.fill(map, notNull(a.name).toString(), i)) return false; } // second pass, fill with the positional parameters for (int i = 0; i< args.size(); i++) { Arguments.Argument a = args.get(i); if (a.name == null) if (this.fill(map, i)) return false; } // check that each parameter is either supplied or optional // stores the invocation expressions ?Expression[] exps = new Expression[size]; for (int i = 0; i < size; i++) if (map[i] == 0) { exps[i] = parameters[i].value(); if (exps[i] == null) return false; } else exps[i] = args.getExp(map[i] - 1); args.applicationExpressions.put(symbol, cast(exps)); args.usedArguments.put(symbol, map); return true; } boolean fill(int[] map, int num) { int i = 0; while (i < map.length && (map[i] != 0 || parameters[i].requiresName())) i++; if (i == map.length) return true; map[i] = num + 1; return false; } boolean fill(int[] map, String id, int num) { int i = 0; while (i < map.length && (map[i] != 0 || !parameters[i].match(id))) i++; if (i == map.length) return true; map[i] = num + 1; return false; } public boolean hasMatchFor(String s) { for (int i = 0; i<size; i++) if (parameters[i].match(s)) return true; return false; } toString() = Util.map("", ", ", "", parameters); public List<Parameter> asList() { if (parameters.length != 0) return Arrays.asList(parameters); return new ArrayList(); } public List<Parameter> getRequiredParameters() { LinkedList<Parameter> res = new LinkedList(); for(int i = 0; i < size; i++) { Parameter param = parameters[i]; if (!(param instanceof OptionalParameter)) { res.add(parameters[i]); } } return res; } public java.util.Stack<gnu.bytecode.Variable>[?] getParameterCopies() { java.util.Stack<gnu.bytecode.Variable>[?] res = null; for(int i = 0; i < size; i++) { Parameter param = parameters[i]; if (notNull(param.symbol).copies != null) { if (res == null) res = cast(new java.util.Stack[parameters.length]); notNull(res)[i] = notNull(notNull(param.symbol).copies); } } return res; } List<Parameter> getParameters(TypeScope scope) { ArrayList<Parameter> res = new ArrayList(size); for (int i = 0; i < size; i++) { Parameter p = parameters[i].cloneParam(); p.type = Monotype.create(p.type.resolve(scope)); res.add(p); } return res; } gnu.bytecode.Attribute asBytecodeAttribute() { return new gnu.bytecode.MiscAttr("parameters", this.toString().getBytes()); } } public FormalParameters createFormalParameters(?List<Parameter> parameters) { if (parameters == null) return new FormalParameters(Node.none, parameters: [], size: 0); return new FormalParameters(Node.none, parameters: parameters.toArray(), size: parameters.size()); } /* FormalParameters(Parameter[] parameters) { super(Node.none); if (parameters == null) return; this.parameters = parameters; this.size = parameters.length; } */ let LocatedString thisName = new LocatedString("this", Location.nowhere()); FormalParameters readParametersFromBytecodeAttribute(gnu.bytecode.MiscAttr attr, bossa.modules.Parser parser) { String value = new String(attr.data); if (bossa.util.Debug.bytecodeAttributes) bossa.util.Debug.println("Read attribute " + attr.getName() + "=\"" + value + "\" from " + attr.getContainer()); ?FormalParameters res = cast(parser.formalParameters(value)); if (res == null) throw Internal.error ("Could not parse '" + attr.getName() + "' bytecode attribute:\n" + "In method: " + attr.getContainer() + "\n" + "Value : " + value); return res; } /** An anonymous formal parameter. */ public class Parameter { Monotype type; private ?ParameterSymbol symbol = null; Parameter cloneParam() = new Parameter(type: type); boolean match(String id) = false; boolean requiresName() = false; void typecheck(mlsub.typing.Monotype domain) {} ?Expression value() = null; boolean isOverriden() = false; void resolve(?VarScope scope, ?TypeScope typeScope) { if (symbol != null) notNull(symbol).state = ARGUMENT_REFERENCE; } void resolve(Info info) { if (symbol != null) notNull(symbol).state = ARGUMENT_REFERENCE; } toString() = type.toString(); ?LocatedString getName() = null; void resetType(Monotype type) { this.type = type; if (symbol != null) notNull(symbol).syntacticType = type; } ParameterSymbol getSymbol() { symbol = new ParameterSymbol(this.getName(), type); return notNull(symbol); } } class ParameterSymbol extends MonoSymbol { private int state = NOT_ACCESSIBLE; ?Stack<gnu.bytecode.Variable> copies = null; int getState () { if (state == ARGUMENT_REFERENCE) // This parameter is referenced by a later one. // We will need to copy its value. copies = new Stack(); return state; } setDeclaration(declaration, isThis) { super; } } /** The symbol is not accessible. This ensures that there are no forward references to another parameter inside a default value. */ let int NOT_ACCESSIBLE = 0; /** The symbol can be accessed by later arguments, using special means. */ let int ARGUMENT_REFERENCE = 1; /** The symbol is fully accessible, for the body of the function. */ let int ACCESSIBLE = 2; /** A named parameter. It can thus be used out-of-order at the call site. */ public class NamedParameter extends Parameter { LocatedString name; boolean nameRequired = false; requiresName() = nameRequired; getName() = name; cloneParam() = new NamedParameter(type: type, name: name, nameRequired: nameRequired); match(id) = name.toString().equals(id); toString() = type + " " + name; } /** A named parameter with a default value. It can thus be omitted at the call site. */ public class OptionalParameter extends NamedParameter { Expression defaultValue; boolean overriden = false; value() = defaultValue; isOverriden() = overriden; cloneParam() { return new OptionalParameter(type: type, name: name, nameRequired: nameRequired, defaultValue: defaultValue, overriden: overriden); } resolve(scope, typeScope) { defaultValue = analyse(defaultValue, notNull(scope), notNull(typeScope)); super; } resolve(info) { defaultValue = analyse(defaultValue, info); // super.resolve(null, null); // XXX: this code is from Parameter.resolve if (symbol != null) notNull(symbol).state = ARGUMENT_REFERENCE; } typecheck(domain) { defaultValue = defaultValue.noOverloading(); //defaultValue = defaultValue.resolveOverloading(new mlsub.typing.Polytype(domain)); typecheck(defaultValue); try { mlsub.typing.Typing.leq(defaultValue.getType(), domain); } catch(mlsub.typing.TypingEx e){ User.error(name, defaultValue + " is not a value of type " + type); } } toString() { defaultValue = defaultValue.noOverloading(); return type + " " + name + " = " + defaultValue; } } public Parameter createParameter(Monotype type, ?LocatedString name, ?Expression defaultValue) { if (defaultValue != null) return new OptionalParameter(type: type, name: notNull(name), defaultValue: defaultValue); if (name != null) return new NamedParameter(type: type, name: name); return new Parameter(type: type); } Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.89 retrieving revision 1.90 diff -C2 -d -r1.89 -r1.90 *** tools.nice 2 Jan 2005 21:39:22 -0000 1.89 --- tools.nice 3 Jan 2005 01:24:28 -0000 1.90 *************** *** 16,21 **** Helper functions. - @version $Date$ - @author Daniel Bonniot (bo...@us...) */ --- 16,19 ---- *************** *** 167,171 **** call.function = createOverloadedSymbolExp(new ArrayList(cast(classe).getConstructorCallSymbols()), ! FormalParameters.thisName); call.function.setLocation(ident.location()); } --- 165,169 ---- call.function = createOverloadedSymbolExp(new ArrayList(cast(classe).getConstructorCallSymbols()), ! thisName); call.function.setLocation(ident.location()); } *************** *** 224,228 **** int[?] getUsedArguments(Arguments, VarSymbol) = native int[] Arguments.getUsedArguments(VarSymbol); ?mlsub.typing.Constraint getConstraint(mlsub.typing.Polytype) = native mlsub.typing.Constraint mlsub.typing.Polytype.getConstraint(); - MonoSymbol[?] getMonoSymbols(FormalParameters) = native MonoSymbol[] FormalParameters.getMonoSymbols(); mlsub.typing.AtomicConstraint[?] AtomicConstraint_substitute(java.util.Map<mlsub.typing.TypeSymbol,mlsub.typing.TypeSymbol>, AtomicConstraint[?]) = native mlsub.typing.AtomicConstraint[] mlsub.typing.AtomicConstraint.substitute(java.util.Map, mlsub.typing.AtomicConstraint[]); ?gnu.expr.Expression getInitializer(NiceClass) = native gnu.expr.Expression NiceClass.getInitializer(); --- 222,225 ---- *************** *** 232,239 **** ?Definition importMethod(NiceClass, gnu.bytecode.Method) = native Definition NiceClass.importMethod(gnu.bytecode.Method); boolean equals(LocatedString, LocatedString) = native boolean LocatedString.equals(LocatedString); - List<FormalParameters.Parameter> getParameters(FormalParameters, TypeScope) = native List FormalParameters.getParameters(TypeScope); mlsub.typing.AtomicConstraint[?] resolvedConstraints(MethodContainer) = native MethodContainer.resolvedConstraints; mlsub.typing.TypeSymbol[?] getBinders(MethodContainer) = native mlsub.typing.TypeSymbol[] MethodContainer.getBinders(); - ?Expression value(FormalParameters.Parameter) = native Expression FormalParameters.Parameter.value(); ?gnu.bytecode.Attribute get(gnu.bytecode.AttrContainer, String) = native gnu.bytecode.Attribute gnu.bytecode.Attribute.get(gnu.bytecode.AttrContainer, String); void printInterface(Definition, java.io.PrintWriter) = native void Definition.printInterface(java.io.PrintWriter); --- 229,234 ---- *************** *** 248,256 **** = native new MethodContainer.Constraint(TypeSymbol[], List, mlsub.typing.Monotype[], Location); ?gnu.bytecode.Type TypeImport_lookup(LocatedString) = native gnu.bytecode.Type nice.tools.code.TypeImport.lookup(LocatedString); - ?FormalParameters getFormalParameters(VarSymbol) = native FormalParameters VarSymbol.getFormalParameters(); List<Node> children(Node) = native Node.children; LocatedString name(Definition) = native Definition.name; void addMappingsLS(TypeScope, Collection<LocatedString>, TypeSymbol[]) = native void TypeScope.addMappingsLS(Collection, TypeSymbol[]); - Stack<gnu.bytecode.Variable> copies(FormalParameters.Parameter.Symbol) = native FormalParameters.Parameter.Symbol.copies; gnu.expr.CopyArgument CopyArgument(Stack<gnu.bytecode.Variable>) = native new gnu.expr.CopyArgument(Stack); MethodContainer MethodContainer(LocatedString, int, MethodContainer.Constraint, List<?boolean>) = native new MethodContainer(LocatedString, int, MethodContainer.Constraint, List); --- 243,249 ---- *************** *** 262,273 **** boolean containsAlike(List<bossa.syntax.Monotype>) = native boolean bossa.syntax.Monotype.containsAlike(List); mlsub.typing.Monotype[] rawResolve(TypeMap,Collection<bossa.syntax.Monotype>) = native mlsub.typing.Monotype[] bossa.syntax.Monotype.rawResolve(TypeMap, Collection); - List<FormalParameters.Parameter> getRequiredParameters(FormalParameters) = native List FormalParameters.getRequiredParameters(); - List<FormalParameters.Parameter> asList(FormalParameters) = native List FormalParameters.asList(); boolean containsAlike(Monotype[]) = native boolean Monotype.containsAlike(Monotype[]); bossa.syntax.Monotype[] substitute(Map<String,bossa.syntax.Monotype>,bossa.syntax.Monotype[]) = native bossa.syntax.Monotype[] bossa.syntax.Monotype.substitute(Map,bossa.syntax.Monotype[]); - Monotype[?] types(FormalParameters) = native Monotype[] FormalParameters.types(); ?mlsub.typing.TypeSymbol lookup(TypeMap, LocatedString) = native mlsub.typing.TypeSymbol TypeMap.lookup(LocatedString); ?mlsub.typing.TypeSymbol lookup(TypeMap, String) = native mlsub.typing.TypeSymbol TypeMap.lookup(String); - void substitute(bossa.syntax.FormalParameters, Map<java.lang.String, bossa.syntax.Monotype>) = native void FormalParameters.substitute(Map); Monotype[] Monotype_toArray(?List<Monotype>) = native Monotype[] Monotype.toArray(List); List<VarSymbol> lookup(VarScope, LocatedString) = native List VarScope.lookup(LocatedString); --- 255,262 ---- *************** *** 275,278 **** --- 264,269 ---- bossa.syntax.Constraint newConstraint(List<TypeSymbol>, List<AtomicConstraint>) = native new Constraint(List, List); void addAtoms(Constraint, List<AtomicConstraint>) = native void Constraint.addAtoms(List); + Map<VarSymbol, int[]> usedArguments(Arguments) = native Arguments.usedArguments; + Map<VarSymbol, Expression[]> applicationExpressions(Arguments) = native Arguments.applicationExpressions; // Retypings needed since java types are not strict. Index: niceMethod.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/niceMethod.nice,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** niceMethod.nice 2 Jan 2005 02:20:59 -0000 1.7 --- niceMethod.nice 3 Jan 2005 01:24:28 -0000 1.8 *************** *** 380,384 **** res = nice.tools.code.Gen.createMethod (name, argTypes, retType, def.getSymbols(), true, receiver != null); ! res.parameterCopies = notNull(def.formalParameters()).getParameterCopies(); // add unique information to disambiguate which method this represents --- 380,384 ---- res = nice.tools.code.Gen.createMethod (name, argTypes, retType, def.getSymbols(), true, receiver != null); ! res.parameterCopies = cast(notNull(def.formalParameters()).getParameterCopies()); // add unique information to disambiguate which method this represents Index: symbolexp.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/symbolexp.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** symbolexp.nice 1 Jan 2005 16:36:31 -0000 1.2 --- symbolexp.nice 3 Jan 2005 01:24:28 -0000 1.3 *************** *** 99,103 **** class ParameterAccessExp extends SymbolExp { ! override FormalParameters.Parameter.Symbol symbol; isAssignable() = false; --- 99,103 ---- class ParameterAccessExp extends SymbolExp { ! override ParameterSymbol symbol; isAssignable() = false; *************** *** 105,113 **** compile () { ! return new gnu.expr.CopyArgument(this.symbol.copies); } } ! SymbolExp createParameterAccessExp(FormalParameters.Parameter.Symbol symbol, Location loc) { let res = new ParameterAccessExp(symbol: symbol); --- 105,113 ---- compile () { ! return new gnu.expr.CopyArgument(notNull(this.symbol.copies)); } } ! SymbolExp createParameterAccessExp(ParameterSymbol symbol, Location loc) { let res = new ParameterAccessExp(symbol: symbol); Index: symbol.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/symbol.nice,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** symbol.nice 2 Jan 2005 02:21:00 -0000 1.4 --- symbol.nice 3 Jan 2005 01:24:28 -0000 1.5 *************** *** 77,81 **** isFunSymbol() = true; ! getFormalParameters() = this.parameters; String describeParameters() --- 77,81 ---- isFunSymbol() = true; ! getFormalParameters() = cast(this.parameters); String describeParameters() Index: nicefieldaccess.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/nicefieldaccess.nice,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** nicefieldaccess.nice 2 Jan 2005 02:20:59 -0000 1.4 --- nicefieldaccess.nice 3 Jan 2005 01:24:28 -0000 1.5 *************** *** 46,50 **** let argType = Monotype.sure(classDef.lowlevelMonotype()); ! let params = new FormalParameters([new FormalParameters.Parameter(Monotype.create(argType))]); let constr = Constraint.create(classDef.getBinders()); let res = new NiceFieldAccess(field.getName(), Node.down, --- 46,50 ---- let argType = Monotype.sure(classDef.lowlevelMonotype()); ! let params = createFormalParameters([new Parameter(type: Monotype.create(argType))]); let constr = Constraint.create(classDef.getBinders()); let res = new NiceFieldAccess(field.getName(), Node.down, Index: importedconstructor.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/importedconstructor.nice,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** importedconstructor.nice 2 Jan 2005 02:20:59 -0000 1.6 --- importedconstructor.nice 3 Jan 2005 01:24:28 -0000 1.7 *************** *** 103,108 **** let name = new LocatedString("<init>",def.getDefinition().location()); ! let parameters = FormalParameters.readBytecodeAttribute(attr, ! notNull(Node.compilation).parser); let res = new ImportedConstructor(name, Node.down, --- 103,108 ---- let name = new LocatedString("<init>",def.getDefinition().location()); ! let parameters = readParametersFromBytecodeAttribute(attr, ! notNull(notNull(Node.compilation).parser)); let res = new ImportedConstructor(name, Node.down, Index: VarSymbol.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/VarSymbol.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** VarSymbol.java 2 Jan 2005 02:20:59 -0000 1.40 --- VarSymbol.java 3 Jan 2005 01:24:12 -0000 1.41 *************** *** 82,86 **** * Get the FormalParameters, or null if this is not a functional symbol */ ! FormalParameters getFormalParameters() { return null; --- 82,86 ---- * Get the FormalParameters, or null if this is not a functional symbol */ ! /*FormalParameters*/Object getFormalParameters() { return null; Index: overloadedsymbol.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/overloadedsymbol.nice,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** overloadedsymbol.nice 2 Jan 2005 21:39:22 -0000 1.10 --- overloadedsymbol.nice 3 Jan 2005 01:24:28 -0000 1.11 *************** *** 657,661 **** for (noMatch : noMatches) if (noMatch.isFunSymbol()) ! argnames.retainAll(args.noMatchByName(noMatch.getFormalParameters())); if (!argnames.isEmpty()) --- 657,661 ---- for (noMatch : noMatches) if (noMatch.isFunSymbol()) ! argnames.retainAll(args.noMatchByName(cast(noMatch.getFormalParameters()))); if (!argnames.isEmpty()) Index: constructor.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/constructor.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** constructor.nice 2 Jan 2005 21:39:22 -0000 1.3 --- constructor.nice 3 Jan 2005 01:24:28 -0000 1.4 *************** *** 69,74 **** //an explanation of the syntax is necessary res = new StringBuffer(); ! List<FormalParameters.Parameter> missing = notNull(arguments).missingArgs(notNull(parameters)); ! List<FormalParameters.Parameter> fieldsToList; if (notNull(arguments).size() == 0) --- 69,74 ---- //an explanation of the syntax is necessary res = new StringBuffer(); ! List<Parameter> missing = notNull(arguments).missingArgs(notNull(parameters)); ! List<Parameter> fieldsToList; if (notNull(arguments).size() == 0) *************** *** 110,119 **** .append(" new ").append(name).append("("); ! let Iterator<FormalParameters.Parameter> params = notNull(parameters).getRequiredParameters().iterator(); int paramCount = 0; int len = name.length(); while(params.hasNext()) { ! FormalParameters.Parameter param = params.next(); if (paramCount != 0) res.append(", "); --- 110,119 ---- .append(" new ").append(name).append("("); ! let Iterator<Parameter> params = notNull(parameters).getRequiredParameters().iterator(); int paramCount = 0; int len = name.length(); while(params.hasNext()) { ! Parameter param = params.next(); if (paramCount != 0) res.append(", "); *************** *** 125,129 **** paramCount = 0; } ! if (param instanceof FormalParameters.NamedParameter) res.append(param.getName()).append(": value"); else --- 125,129 ---- paramCount = 0; } ! if (param instanceof NamedParameter) res.append(param.getName()).append(": value"); else *************** *** 136,143 **** } ! List<FormalParameters.Parameter> missingArgs(Arguments args, FormalParameters parameters) { ! List<FormalParameters.Parameter> missing = new LinkedList(); ! Iterator<FormalParameters.Parameter> reqParams = parameters.getRequiredParameters().iterator(); int lastUsedPositional = -1; while(reqParams.hasNext()) --- 136,143 ---- } ! List<Parameter> missingArgs(Arguments args, FormalParameters parameters) { ! List<Parameter> missing = new LinkedList(); ! Iterator<Parameter> reqParams = parameters.getRequiredParameters().iterator(); int lastUsedPositional = -1; while(reqParams.hasNext()) *************** *** 147,151 **** if (param.value() != null) continue; ! if (param instanceof FormalParameters.NamedParameter) { for (int i = 0; i < args.arguments.length; i++) --- 147,151 ---- if (param.value() != null) continue; ! if (param instanceof NamedParameter) { for (int i = 0; i < args.arguments.length; i++) Index: defaultMethod.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/defaultMethod.nice,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** defaultMethod.nice 2 Jan 2005 02:20:59 -0000 1.5 --- defaultMethod.nice 3 Jan 2005 01:24:28 -0000 1.6 *************** *** 128,132 **** { let res = new DefaultMethodImplementation(name, Node.down, body: body, ! formals: parameters.asList().mapToArray(FormalParameters.Parameter param => createPattern(param.getName() || new LocatedString("_", name.location())))); res.declaration = new MethodWithDefault(name, Node.down, --- 128,132 ---- { let res = new DefaultMethodImplementation(name, Node.down, body: body, ! formals: parameters.asList().mapToArray(Parameter param => createPattern(param.getName() || new LocatedString("_", name.location())))); res.declaration = new MethodWithDefault(name, Node.down, |
From: Arjan B. <ar...@us...> - 2005-01-02 21:39:32
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6568/F:/nice/src/bossa/syntax Modified Files: Arguments.java constructor.nice overloadedsymbol.nice tools.nice Log Message: Moved error reporting code out of Arguments. Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.88 retrieving revision 1.89 diff -C2 -d -r1.88 -r1.89 *** tools.nice 2 Jan 2005 02:21:00 -0000 1.88 --- tools.nice 2 Jan 2005 21:39:22 -0000 1.89 *************** *** 209,213 **** ?gnu.bytecode.ClassType staticClass(Arguments) = native gnu.bytecode.ClassType Arguments.staticClass(); ?gnu.bytecode.ClassType staticClass(Expression) = native gnu.bytecode.ClassType Expression.staticClass(); - ?String explainNoMatch(Arguments, List<VarSymbol>) = native String Arguments.explainNoMatch(List); Map<VarSymbol,mlsub.typing.Polytype> types(Arguments) = native Arguments.types; <T> String map(String, String, String, T[]) = native String bossa.util.Util.map(String, String, String, Object[]); --- 209,212 ---- *************** *** 263,268 **** boolean containsAlike(List<bossa.syntax.Monotype>) = native boolean bossa.syntax.Monotype.containsAlike(List); mlsub.typing.Monotype[] rawResolve(TypeMap,Collection<bossa.syntax.Monotype>) = native mlsub.typing.Monotype[] bossa.syntax.Monotype.rawResolve(TypeMap, Collection); - List<String> noMatchByName(Arguments, FormalParameters) = native List Arguments.noMatchByName(FormalParameters); - List<FormalParameters.Parameter> missingArgs(Arguments, FormalParameters) = native List Arguments.missingArgs(FormalParameters); List<FormalParameters.Parameter> getRequiredParameters(FormalParameters) = native List FormalParameters.getRequiredParameters(); List<FormalParameters.Parameter> asList(FormalParameters) = native List FormalParameters.asList(); --- 262,265 ---- Index: Arguments.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Arguments.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** Arguments.java 14 Dec 2004 20:18:05 -0000 1.29 --- Arguments.java 2 Jan 2005 21:39:22 -0000 1.30 *************** *** 212,292 **** } - String explainNoMatch(List /*VarSymbol*/ noMatches) - { - List argnames = new LinkedList(); - for (int i = 0; i < arguments.length; i++) - if (arguments[i].name != null) - argnames.add(arguments[i].name.toString()); - - if (!argnames.isEmpty()) - { - for (Iterator i = noMatches.iterator(); i.hasNext();) - { - VarSymbol noMatch = (VarSymbol)i.next(); - if (noMatch.isFunSymbol()) - argnames.retainAll(noMatchByName(noMatch.getFormalParameters())); - } - if (!argnames.isEmpty()) - return " has an argument named " + argnames.get(0); - } - //fall back to default error message - return null; - } - - List noMatchByName(FormalParameters parameters) - { - List res = new LinkedList(); - for (int i = 0; i < arguments.length; i++) - if (arguments[i].name != null) - { - String s = arguments[i].name.toString(); - if (parameters == null || !parameters.hasMatchFor(s)) - res.add(s); - } - - return res; - } - - List missingArgs(FormalParameters parameters) - { - List missing = new LinkedList(); - Iterator reqParams = parameters.getRequiredParameters().iterator(); - int lastUsedPositional = -1; - while(reqParams.hasNext()) - { - boolean found = false; - FormalParameters.Parameter param = (FormalParameters.Parameter)reqParams.next(); - if (param.value() != null) - continue; - if (param instanceof FormalParameters.NamedParameter) - { - for (int i = 0; i < arguments.length; i++) - if (arguments[i].name != null) - { - String s = arguments[i].name.toString(); - if (param.match(s)) - { - found = true; - break; - } - } - } - else { - for(int i = lastUsedPositional + 1; i < arguments.length; i++) - { - if (arguments[i].name == null) - { - found = true; - lastUsedPositional = i; - break; - } - } - } - if (!found) - missing.add(param); - } - return missing; - } - Argument[] arguments; } --- 212,215 ---- Index: constructor.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/constructor.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** constructor.nice 2 Jan 2005 02:20:59 -0000 1.2 --- constructor.nice 2 Jan 2005 21:39:22 -0000 1.3 *************** *** 134,136 **** return res.toString(); } ! } \ No newline at end of file --- 134,177 ---- return res.toString(); } ! } ! ! List<FormalParameters.Parameter> missingArgs(Arguments args, FormalParameters parameters) ! { ! List<FormalParameters.Parameter> missing = new LinkedList(); ! Iterator<FormalParameters.Parameter> reqParams = parameters.getRequiredParameters().iterator(); ! int lastUsedPositional = -1; ! while(reqParams.hasNext()) ! { ! boolean found = false; ! let param = reqParams.next(); ! if (param.value() != null) ! continue; ! if (param instanceof FormalParameters.NamedParameter) ! { ! for (int i = 0; i < args.arguments.length; i++) ! if (args.arguments[i].name != null) ! { ! String s = notNull(args.arguments[i].name).toString(); ! if (param.match(s)) ! { ! found = true; ! break; ! } ! } ! } ! else { ! for(int i = lastUsedPositional + 1; i <args.arguments.length; i++) ! { ! if (args.arguments[i].name == null) ! { ! found = true; ! lastUsedPositional = i; ! break; ! } ! } ! } ! if (!found) ! missing.add(param); ! } ! return missing; ! } Index: overloadedsymbol.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/overloadedsymbol.nice,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** overloadedsymbol.nice 2 Jan 2005 02:20:59 -0000 1.9 --- overloadedsymbol.nice 2 Jan 2005 21:39:22 -0000 1.10 *************** *** 645,646 **** --- 645,680 ---- return Arrays.equals(m1.javaArgTypes(), m2.javaArgTypes()); } + + ?String explainNoMatch(Arguments args, List<VarSymbol> noMatches) + { + List<String> argnames = new LinkedList(); + for (int i = 0; i < args.arguments.length; i++) + if (args.arguments[i].name != null) + argnames.add(notNull(args.arguments[i].name).toString()); + + if (!argnames.isEmpty()) + { + for (noMatch : noMatches) + if (noMatch.isFunSymbol()) + argnames.retainAll(args.noMatchByName(noMatch.getFormalParameters())); + + if (!argnames.isEmpty()) + return " has an argument named " + argnames.get(0); + } + //fall back to default error message + return null; + } + + List<String> noMatchByName(Arguments args, ?FormalParameters parameters) + { + List<String> res = new LinkedList(); + for (int i = 0; i < args.arguments.length; i++) + if (args.arguments[i].name != null) + { + String s = notNull(args.arguments[i].name).toString(); + if (parameters == null || !parameters.hasMatchFor(s)) + res.add(s); + } + + return res; + } |
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1879/F:/nice/src/bossa/syntax Modified Files: VarSymbol.java alternative.nice constructor.nice customConstructor.nice defaultMethod.nice defaultconstructor.nice dispatch.java.bootstrap dispatchTest.nice importedconstructor.nice inline.nice javaFieldAccess.nice javaMethod.nice methodImplementation.nice methodbody.nice niceMethod.nice niceclass.nice nicefieldaccess.nice overloadedsymbol.nice retypedMethod.nice super.nice symbol.nice tools.nice userOperator.nice Added Files: methodDeclaration.nice Removed Files: MethodDeclaration.java Log Message: Converted MethodDeclaration. Index: methodImplementation.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/methodImplementation.nice,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** methodImplementation.nice 30 Dec 2004 20:58:37 -0000 1.5 --- methodImplementation.nice 2 Jan 2005 02:20:59 -0000 1.6 *************** *** 48,52 **** public Pattern[] getPatterns() = formals; ! boolean hasThis() = notNull(declaration).formalParameters().hasThis(); void buildSymbols() --- 48,52 ---- public Pattern[] getPatterns() = formals; ! boolean hasThis() = notNull(notNull(declaration).formalParameters()).hasThis(); void buildSymbols() *************** *** 106,110 **** void addPatterns() { ! mlsub.typing.Monotype[] parameters = notNull(nice.tools.typing.Types.parameters(notNull(declaration).getType())); for (int i = 0; i < formals.length; i++) if (formals[i].tc == null) --- 106,110 ---- void addPatterns() { ! mlsub.typing.Monotype[] parameters = notNull(nice.tools.typing.Types.parameters(notNull(notNull(declaration).getType()))); for (int i = 0; i < formals.length; i++) if (formals[i].tc == null) Index: niceclass.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/niceclass.nice,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** niceclass.nice 26 Dec 2004 06:21:17 -0000 1.10 --- niceclass.nice 2 Jan 2005 02:20:59 -0000 1.11 *************** *** 389,393 **** for (msym : constructors) { ! let m = msym.getMethodDeclaration(); // Only consider parent methods for which a call from this class --- 389,393 ---- for (msym : constructors) { ! let MethodDeclaration m = cast(msym.getMethodDeclaration()); // Only consider parent methods for which a call from this class *************** *** 436,441 **** for (msym : constructors) { ! let decl = msym.getMethodDeclaration(); ! res.add((decl, decl.formalParameters().getParameters(scope))); } --- 436,441 ---- for (msym : constructors) { ! let MethodDeclaration decl = cast(msym.getMethodDeclaration()); ! res.add((decl, notNull(decl.formalParameters()).getParameters(scope))); } *************** *** 556,568 **** // There might be simpler code to do this, and we could avoid // duplicating the type variables. ! if (parent instanceof JavaMethod && ! parent.getType().isMonomorphic()) specificCst = identifyTypeParameters(cst, parent, typeParameters); notNull(constructorMethod)[i] = new DefaultConstructor ! (new LocatedString("<init>",definition.location()), values, ! specificCst, ! Monotype.resolve(definition.getLocalScope(), values.types()), ! Monotype.sure(new mlsub.typing.MonotypeConstructor(definition.getTC(), definition.getTypeParameters())), ! classe: this, isDefault: true, fields: fields, parent: parent); addConstructor(definition.getTC(), notNull(constructorMethod)[i]); } --- 556,570 ---- // There might be simpler code to do this, and we could avoid // duplicating the type variables. ! if (parent instanceof JavaMethod && ! notNull(parent.getType()).isMonomorphic()) specificCst = identifyTypeParameters(cst, parent, typeParameters); + let cname = new LocatedString("<init>",definition.location()); + let ctype = new mlsub.typing.Polytype(specificCst, new mlsub.typing.FunType(Monotype.resolve(definition.getLocalScope(), values.types()),Monotype.sure(new mlsub.typing.MonotypeConstructor(definition.getTC(), definition.getTypeParameters())))); notNull(constructorMethod)[i] = new DefaultConstructor ! (cname, Node.global, parameters: values, arity: values.size, ! symbol: cast(null), type: ctype, ! classe: this, isDefault: true, fields: fields, parent: parent); ! notNull(constructorMethod)[i].symbol = createMethodSymbol(notNull(constructorMethod)[i], cname, ctype); ! addConstructor(definition.getTC(), notNull(constructorMethod)[i]); } *************** *** 698,705 **** { mlsub.typing.MonotypeConstructor result = ! cast(nice.tools.typing.Types.rawType(method.getType().codomain())); let methodTP = result.getTP(); ! let cst2 = method.getType().getConstraint(); mlsub.typing.Constraint and = mlsub.typing.Constraint.and(cst, cst2); --- 700,707 ---- { mlsub.typing.MonotypeConstructor result = ! cast(nice.tools.typing.Types.rawType(notNull(method.getType()).codomain())); let methodTP = result.getTP(); ! let cst2 = notNull(method.getType()).getConstraint(); mlsub.typing.Constraint and = mlsub.typing.Constraint.and(cst, cst2); Index: retypedMethod.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/retypedMethod.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** retypedMethod.nice 29 Dec 2004 16:31:02 -0000 1.3 --- retypedMethod.nice 2 Jan 2005 02:20:59 -0000 1.4 *************** *** 228,233 **** FormalParameters parameters) { ! return new RetypedJavaMethod(name, constraint, returnType, parameters, ! className: className, methodName: methodName, javaTypes: javaTypes); } --- 228,246 ---- FormalParameters parameters) { ! let res = new RetypedJavaMethod(name, Node.down, ! parameters: parameters, ! syntacticConstraint: constraint.toString(), ! symbol: cast(null), ! arity: parameters.size, ! className: className, ! methodName: methodName, ! javaTypes: javaTypes); ! ! res.addChild(parameters); ! let symbol = createMethodSymbol(res, name, constraint, returnType); ! res.symbol = symbol; ! symbol.propagate = Node.global; ! res.addChild(symbol); ! return res; } Index: niceMethod.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/niceMethod.nice,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** niceMethod.nice 1 Jan 2005 13:10:55 -0000 1.6 --- niceMethod.nice 2 Jan 2005 02:20:59 -0000 1.7 *************** *** 34,38 **** { return name.toString().equals("main") && arity==1 && ! this.getType().domain()[0].toString().equals("java.lang.String[]"); } --- 34,38 ---- { return name.toString().equals("main") && arity==1 && ! notNull(this.getType()).domain()[0].toString().equals("java.lang.String[]"); } *************** *** 95,99 **** for (s : notNull(homonyms)) { ! let d = s.getMethodDeclaration(); // Ignore non-methods. --- 95,99 ---- for (s : notNull(homonyms)) { ! let MethodDeclaration d = cast(s.getMethodDeclaration()); // Ignore non-methods. *************** *** 203,208 **** Contract contract, boolean isOverride) { ! let res = new NiceMethod(name, constraint, returnType, parameters, contract: contract, ! isOverride: isOverride, returnTypeLocation: returnType.location()); return res; } --- 203,220 ---- Contract contract, boolean isOverride) { ! let res = new NiceMethod(name, Node.down, ! parameters: parameters, ! arity: parameters.size, ! syntacticConstraint: constraint.toString(), ! symbol: cast(null), ! contract: contract, ! isOverride: isOverride, ! returnTypeLocation: returnType.location()); ! ! res.addChild(parameters); ! let symbol = createMethodSymbol(res, name, constraint, returnType); ! res.symbol = symbol; ! symbol.propagate = Node.global; ! res.addChild(symbol); return res; } *************** *** 368,372 **** res = nice.tools.code.Gen.createMethod (name, argTypes, retType, def.getSymbols(), true, receiver != null); ! res.parameterCopies = def.formalParameters().getParameterCopies(); // add unique information to disambiguate which method this represents --- 380,384 ---- res = nice.tools.code.Gen.createMethod (name, argTypes, retType, def.getSymbols(), true, receiver != null); ! res.parameterCopies = notNull(def.formalParameters()).getParameterCopies(); // add unique information to disambiguate which method this represents Index: super.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/super.nice,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** super.nice 29 Dec 2004 23:10:48 -0000 1.6 --- super.nice 2 Jan 2005 02:20:59 -0000 1.7 *************** *** 109,113 **** computeType() { ! mlsub.typing.Polytype type = notNull(currentMethod).getDeclaration().getType(); mlsub.typing.FunType monotype; mlsub.typing.Constraint constraint; --- 109,113 ---- computeType() { ! mlsub.typing.Polytype type = notNull(notNull(currentMethod).getDeclaration().getType()); mlsub.typing.FunType monotype; mlsub.typing.Constraint constraint; *************** *** 180,184 **** } ! public ?gnu.bytecode.Method getImplementationAbove(MethodDeclaration /* JavaMethod */ decl, gnu.bytecode.ClassType firstArg) { let thisMethod = decl.getReflectMethod(); --- 180,184 ---- } ! public ?gnu.bytecode.Method getImplementationAbove(JavaMethod decl, gnu.bytecode.ClassType firstArg) { let thisMethod = decl.getReflectMethod(); Index: javaFieldAccess.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/javaFieldAccess.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** javaFieldAccess.nice 1 Jan 2005 16:36:31 -0000 1.3 --- javaFieldAccess.nice 2 Jan 2005 02:20:59 -0000 1.4 *************** *** 111,130 **** Monotype returnType, FormalParameters parameters) { ! return new JavaFieldAccess(name, cst, returnType, parameters, ! className : className, ! fieldName : fieldName ); } ! new JavaFieldAccess(gnu.bytecode.Field field, mlsub.typing.Monotype[?] parameters) { ! this( ! new LocatedString(field.getName(), Location.nowhere()), ! null, ! parameters, ! nice.tools.code.Types.monotype(field.getType(), field.isFinal()), ! field : field, ! className : new LocatedString(field.getDeclaringClass().getName(), Location.nowhere()), ! fieldName : field.getName() ); } --- 111,144 ---- Monotype returnType, FormalParameters parameters) { ! let res = new JavaFieldAccess(name, Node.down, ! parameters: parameters, ! syntacticConstraint: cst.toString(), ! arity: parameters.size, ! symbol: cast(null), ! className : className, ! fieldName : fieldName ); ! res.addChild(parameters); ! let symbol = createMethodSymbol(res, name, cst, returnType); ! res.symbol = symbol; ! symbol.propagate = Node.global; ! res.addChild(symbol); ! return res; } ! JavaFieldAccess createJavaFieldAccess(gnu.bytecode.Field field, mlsub.typing.Monotype[?] parameters) { ! let type = new mlsub.typing.Polytype(null, new mlsub.typing.FunType(parameters, ! nice.tools.code.Types.monotype(field.getType(), field.isFinal()))); ! let res = new JavaFieldAccess(new LocatedString(field.getName(),Location.nowhere()), Node.global, ! parameters: null, ! arity: type.domain().length, ! type: type, ! symbol: cast(null), ! field: field, ! className: new LocatedString(field.getDeclaringClass().getName(), Location.nowhere()), ! fieldName: field.getName() ); ! res.symbol = createMethodSymbol(res, new LocatedString(field.getName(),Location.nowhere()), type); ! return res; } *************** *** 140,144 **** params = null; ! JavaFieldAccess res = new JavaFieldAccess(f, params); if (bossa.util.Debug.javaTypes) --- 154,158 ---- params = null; ! JavaFieldAccess res = createJavaFieldAccess(f, params); if (bossa.util.Debug.javaTypes) Index: nicefieldaccess.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/nicefieldaccess.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** nicefieldaccess.nice 1 Jan 2005 16:36:31 -0000 1.3 --- nicefieldaccess.nice 2 Jan 2005 02:20:59 -0000 1.4 *************** *** 46,58 **** let argType = Monotype.sure(classDef.lowlevelMonotype()); ! return new NiceFieldAccess(field.getName(), ! Constraint.create(classDef.getBinders()), ! field.sym.syntacticType, ! new FormalParameters([new FormalParameters.Parameter(Monotype.create(argType))]), ! field: field); ! } ! private FormalParameters makeList(mlsub.typing.Monotype t) ! { ! return new FormalParameters([new FormalParameters.Parameter(Monotype.create(t))]); } --- 46,63 ---- let argType = Monotype.sure(classDef.lowlevelMonotype()); ! let params = new FormalParameters([new FormalParameters.Parameter(Monotype.create(argType))]); ! let constr = Constraint.create(classDef.getBinders()); ! let res = new NiceFieldAccess(field.getName(), Node.down, ! parameters: params, ! syntacticConstraint: constr.toString(), ! symbol: cast(null), ! arity: 1, ! field: field); ! res.addChild(params); ! let symbol = createMethodSymbol(res, field.getName(), constr, notNull(field.sym.syntacticType)); ! res.symbol = symbol; ! symbol.propagate = Node.global; ! res.addChild(symbol); ! return res; } Index: alternative.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/alternative.nice,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** alternative.nice 30 Dec 2004 18:49:01 -0000 1.5 --- alternative.nice 2 Jan 2005 02:20:59 -0000 1.6 *************** *** 142,146 **** Alternative addDefaultPatterns(MethodDeclaration def) { ! mlsub.typing.Monotype[?] parameters = nice.tools.typing.Types.parameters(def.getType()); Pattern[?] newPatterns = null; --- 142,146 ---- Alternative addDefaultPatterns(MethodDeclaration def) { ! mlsub.typing.Monotype[?] parameters = nice.tools.typing.Types.parameters(notNull(def.getType())); Pattern[?] newPatterns = null; *************** *** 186,190 **** String fullName = to.getFullName(); ! if (from.isJavaMethod()) createJavaAlternative(from).add(fullName); --- 186,190 ---- String fullName = to.getFullName(); ! if (from instanceof JavaMethod) createJavaAlternative(from).add(fullName); *************** *** 348,352 **** { ! Pattern[] patterns = notNull(nice.tools.typing.Types.parameters(method.getType())). mapToArray(mlsub.typing.Monotype param => createPattern(null, nice.tools.typing.Types.concreteConstructor(param), --- 348,352 ---- { ! Pattern[] patterns = notNull(nice.tools.typing.Types.parameters(notNull(method.getType()))). mapToArray(mlsub.typing.Monotype param => createPattern(null, nice.tools.typing.Types.concreteConstructor(param), *************** *** 418,423 **** loc: location); ! alt.add(nice.tools.util.System.split ! (fullName, MethodDeclaration.methodListSeparator)); } catch(UnknownPattern ex) { --- 418,422 ---- loc: location); ! alt.add(nice.tools.util.System.split(fullName, methodListSeparator)); } catch(UnknownPattern ex) { *************** *** 445,452 **** continue; ! MethodDeclaration md = notNull(sym.getMethodDeclaration()); if (md.getFullName().equals(fullName)) { ! md.registerForDispatch(); return; } --- 444,451 ---- continue; ! MethodDeclaration md = cast(sym.getMethodDeclaration()); if (md.getFullName().equals(fullName)) { ! cast(md).registerForDispatch(); return; } Index: inline.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/inline.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** inline.nice 16 Dec 2004 00:30:29 -0000 1.1 --- inline.nice 2 Jan 2005 02:20:59 -0000 1.2 *************** *** 130,131 **** --- 130,152 ---- } } + + public InlinedMethod createInlinedMethod(LocatedString name, + Constraint constraint, Monotype returnType, + FormalParameters parameters, + LocatedString inlineProcedure, String param) + { + let res = new InlinedMethod(name, Node.down, + parameters: parameters, + arity: parameters.size, + syntacticConstraint: constraint.toString(), + symbol: cast(null), + inlineProcedure: inlineProcedure, + parameter: param); + + res.addChild(parameters); + let symbol = createMethodSymbol(res, name, constraint, returnType); + res.symbol = symbol; + symbol.propagate = Node.global; + res.addChild(symbol); + return res; + } Index: constructor.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/constructor.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** constructor.nice 14 Dec 2004 22:49:12 -0000 1.1 --- constructor.nice 2 Jan 2005 02:20:59 -0000 1.2 *************** *** 30,34 **** void addConstructorCallSymbol() { ! let type = new mlsub.typing.Polytype(this.getType().getConstraint(), new mlsub.typing.FunType(this.getArgTypes(), nice.tools.typing.PrimitiveType.voidType)); classe.addConstructorCallSymbol(createConstructorCallSymbol(this, name, type)); --- 30,34 ---- void addConstructorCallSymbol() { ! let type = new mlsub.typing.Polytype(notNull(this.getType()).getConstraint(), new mlsub.typing.FunType(this.getArgTypes(), nice.tools.typing.PrimitiveType.voidType)); classe.addConstructorCallSymbol(createConstructorCallSymbol(this, name, type)); *************** *** 51,55 **** //Arguments where none expected ! if (parameters.size == 0) { res.append(" has no fields. Therefore its constructor takes no arguments."); --- 51,55 ---- //Arguments where none expected ! if (notNull(parameters).size == 0) { res.append(" has no fields. Therefore its constructor takes no arguments."); *************** *** 58,62 **** //No such field ! List<String> nonmatching = notNull(arguments).noMatchByName(parameters); if (!nonmatching.isEmpty()) { --- 58,62 ---- //No such field ! List<String> nonmatching = notNull(arguments).noMatchByName(notNull(parameters)); if (!nonmatching.isEmpty()) { *************** *** 69,73 **** //an explanation of the syntax is necessary res = new StringBuffer(); ! List<FormalParameters.Parameter> missing = notNull(arguments).missingArgs(parameters); List<FormalParameters.Parameter> fieldsToList; --- 69,73 ---- //an explanation of the syntax is necessary res = new StringBuffer(); ! List<FormalParameters.Parameter> missing = notNull(arguments).missingArgs(notNull(parameters)); List<FormalParameters.Parameter> fieldsToList; *************** *** 78,82 **** res.append(this.syntaxExample()) .append("Class ").append(name).append(" has the following fields:\n"); ! fieldsToList = parameters.asList(); } else if (missing.size() > 0) --- 78,82 ---- res.append(this.syntaxExample()) .append("Class ").append(name).append(" has the following fields:\n"); ! fieldsToList = notNull(parameters).asList(); } else if (missing.size() > 0) *************** *** 91,95 **** .append(".\n") .append("The constructor accepts the following arguments:\n" ); ! fieldsToList = parameters.asList(); } for (field : fieldsToList) --- 91,95 ---- .append(".\n") .append("The constructor accepts the following arguments:\n" ); ! fieldsToList = notNull(parameters).asList(); } for (field : fieldsToList) *************** *** 110,114 **** .append(" new ").append(name).append("("); ! let Iterator<FormalParameters.Parameter> params = parameters.getRequiredParameters().iterator(); int paramCount = 0; int len = name.length(); --- 110,114 ---- .append(" new ").append(name).append("("); ! let Iterator<FormalParameters.Parameter> params = notNull(parameters).getRequiredParameters().iterator(); int paramCount = 0; int len = name.length(); Index: customConstructor.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/customConstructor.nice,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** customConstructor.nice 1 Jan 2005 14:38:03 -0000 1.8 --- customConstructor.nice 2 Jan 2005 02:20:59 -0000 1.9 *************** *** 33,37 **** { mlsub.typing.Polytype type = new mlsub.typing.Polytype ! (this.getType().getConstraint(), new mlsub.typing.FunType(this.getArgTypes(), nice.tools.typing.PrimitiveType.voidType)); notNull(classe).addConstructorCallSymbol( --- 33,37 ---- { mlsub.typing.Polytype type = new mlsub.typing.Polytype ! (notNull(this.getType()).getConstraint(), new mlsub.typing.FunType(this.getArgTypes(), nice.tools.typing.PrimitiveType.voidType)); notNull(classe).addConstructorCallSymbol( *************** *** 110,119 **** // as the class definition, even if the source of this custom constructor // renamed them locally. ! let cst = this.getType().getConstraint(); if (mlsub.typing.Constraint.hasBinders(cst)) ! parameters.substitute (this.typeParamMap(notNull(cst).binders(), notNull(classe).getTypeParameters())); ! lambda.addBytecodeAttribute(parameters.asBytecodeAttribute()); initializationCode = new gnu.expr.QuoteExp(new gnu.expr.InitializeProc(lambda)); --- 110,119 ---- // as the class definition, even if the source of this custom constructor // renamed them locally. ! let cst = notNull(this.getType()).getConstraint(); if (mlsub.typing.Constraint.hasBinders(cst)) ! notNull(parameters).substitute (this.typeParamMap(notNull(cst).binders(), notNull(classe).getTypeParameters())); ! lambda.addBytecodeAttribute(notNull(parameters).asBytecodeAttribute()); initializationCode = new gnu.expr.QuoteExp(new gnu.expr.InitializeProc(lambda)); *************** *** 124,128 **** } ! getConstructorInvocation(boolean) { this.getCode(); --- 124,128 ---- } ! getConstructorInvocation(omitDefaults) { this.getCode(); *************** *** 143,150 **** FormalParameters params, Statement body) { ! return new CustomConstructor(new LocatedString("<init>", className.location()), ! cst, getCCReturnType(className, cst), params, contract: noContract, ! className: className, body: body); } --- 143,163 ---- FormalParameters params, Statement body) { ! let name = new LocatedString("<init>", className.location()); ! let returnType = getCCReturnType(className, cst); ! let res = new CustomConstructor(name, Node.down, ! parameters: params, ! arity: params.size, ! syntacticConstraint: cst.toString(), ! symbol: cast(null), ! contract: noContract, ! className: className, ! body: body); + res.addChild(params); + let symbol = createMethodSymbol(res, name, cst, returnType); + res.symbol = symbol; + symbol.propagate = Node.global; + res.addChild(symbol); + return res; } Index: methodbody.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/methodbody.nice,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** methodbody.nice 30 Dec 2004 18:49:01 -0000 1.7 --- methodbody.nice 2 Jan 2005 02:20:59 -0000 1.8 *************** *** 85,89 **** } ! MethodDeclaration m = s.getMethodDeclaration(); if (m.isIgnored()) { --- 85,89 ---- } ! MethodDeclaration m = cast(s.getMethodDeclaration()); if (m.isIgnored()) { *************** *** 108,112 **** try{ ! mlsub.typing.Polytype t = m.getType(); mlsub.typing.Constraint.enter(t.getConstraint()); mlsub.typing.Monotype[] domain = t.domain(); --- 108,112 ---- try{ ! mlsub.typing.Polytype t = notNull(m.getType()); mlsub.typing.Constraint.enter(t.getConstraint()); mlsub.typing.Monotype[] domain = t.domain(); *************** *** 151,155 **** for (int m1 = 0; m1 < size; m1++) { ! mlsub.typing.Monotype[] dom1 = tempSymbols[m1].getMethodDeclaration().getType().domain(); for (int m2 = 0; m2 < size; m2++) if (m1 != m2) --- 151,156 ---- for (int m1 = 0; m1 < size; m1++) { ! let MethodDeclaration md1 = cast(tempSymbols[m1].getMethodDeclaration()); ! mlsub.typing.Monotype[] dom1 = notNull(md1.getType()).domain(); for (int m2 = 0; m2 < size; m2++) if (m1 != m2) *************** *** 157,161 **** boolean remove = true; boolean additionalsEqual = true; ! mlsub.typing.Monotype[] dom2 = tempSymbols[m2].getMethodDeclaration().getType().domain(); for (int i = 0; i < len; i++) if (additionalTags[i] != null) --- 158,163 ---- boolean remove = true; boolean additionalsEqual = true; ! let MethodDeclaration md2 = cast(tempSymbols[m2].getMethodDeclaration()); ! mlsub.typing.Monotype[] dom2 = notNull(md2.getType()).domain(); for (int i = 0; i < len; i++) if (additionalTags[i] != null) *************** *** 190,196 **** // Check that the non-dispatched parameter names match the declaration outer: for(let it = symbols.iterator(); it.hasNext();) { ! MethodDeclaration m = it.next().getMethodDeclaration(); if( m instanceof NiceMethod) { ! FormalParameters params = m.formalParameters(); for (int i = params.hasThis() ? 1 : 0; i < formals.length; i++) if (formals[i].atAny() && formals[i].name != null && params.getName(i) != null && --- 192,198 ---- // Check that the non-dispatched parameter names match the declaration outer: for(let it = symbols.iterator(); it.hasNext();) { ! MethodDeclaration m = cast(it.next().getMethodDeclaration()); if( m instanceof NiceMethod) { ! FormalParameters params = notNull(m.formalParameters()); for (int i = params.hasThis() ? 1 : 0; i < formals.length; i++) if (formals[i].atAny() && formals[i].name != null && params.getName(i) != null && *************** *** 223,227 **** for (s : symbols) { ! MethodDeclaration m = s.getMethodDeclaration(); methods += m + " defined " + m.location() + "\n"; } --- 225,229 ---- for (s : symbols) { ! MethodDeclaration m = cast(s.getMethodDeclaration()); methods += m + " defined " + m.location() + "\n"; } *************** *** 269,273 **** User.error(this, name+" is not a method"); ! MethodDeclaration decl = s.getMethodDeclaration(); this.setDeclaration(decl); --- 271,275 ---- User.error(this, name+" is not a method"); ! MethodDeclaration decl = cast(s.getMethodDeclaration()); this.setDeclaration(decl); *************** *** 276,280 **** if (binders != null) { ! let cst = notNull(declaration).getType().getConstraint(); if (! mlsub.typing.Constraint.hasBinders(cst)) User.error(name, "Method " + name + " has no type parameters"); --- 278,282 ---- if (binders != null) { ! let cst = notNull(notNull(declaration).getType()).getConstraint(); if (! mlsub.typing.Constraint.hasBinders(cst)) User.error(name, "Method " + name + " has no type parameters"); *************** *** 312,316 **** boolean entered = false; ! if (mlsub.typing.Constraint.hasBinders(notNull(declaration).getType().getConstraint())) { mlsub.typing.Typing.enter(); --- 314,318 ---- boolean entered = false; ! if (mlsub.typing.Constraint.hasBinders(notNull(notNull(declaration).getType()).getConstraint())) { mlsub.typing.Typing.enter(); *************** *** 320,327 **** try { try { ! mlsub.typing.Constraint.enter(notNull(declaration).getType().getConstraint()); Typing.implies(); ! mlsub.typing.Monotype[] domain = notNull(declaration).getType().domain(); for (int n = 0; n < formals.length; n++) { --- 322,329 ---- try { try { ! mlsub.typing.Constraint.enter(notNull(notNull(declaration).getType()).getConstraint()); Typing.implies(); ! mlsub.typing.Monotype[] domain = notNull(notNull(declaration).getType()).domain(); for (int n = 0; n < formals.length; n++) { *************** *** 353,357 **** try { try { ! mlsub.typing.Constraint.enter(notNull(declaration).getType().getConstraint()); } catch(TypingEx e){ --- 355,359 ---- try { try { ! mlsub.typing.Constraint.enter(notNull(notNull(declaration).getType()).getConstraint()); } catch(TypingEx e){ *************** *** 373,377 **** } ! mlsub.typing.Monotype[] domain = notNull(declaration).getType().domain(); for(int n = 0; n < formals.length; n++) --- 375,379 ---- } ! mlsub.typing.Monotype[] domain = notNull(notNull(declaration).getType()).domain(); for(int n = 0; n < formals.length; n++) Index: dispatchTest.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/dispatchTest.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** dispatchTest.nice 29 Dec 2004 23:10:48 -0000 1.3 --- dispatchTest.nice 2 Jan 2005 02:20:59 -0000 1.4 *************** *** 99,103 **** } ! private boolean trivialTestJava(MethodDeclaration m, Stack<Alternative> alternatives) { gnu.bytecode.Method reflectMethod = m.getReflectMethod(); --- 99,103 ---- } ! private boolean trivialTestJava(JavaMethod m, Stack<Alternative> alternatives) { gnu.bytecode.Method reflectMethod = m.getReflectMethod(); *************** *** 289,293 **** if (firstArg != null) { ! let superImplementation = getImplementationAbove(method, firstArg); if (superImplementation != null && superImplementation.isAbstract() == false) // It's OK, this case is covered by a Java implementation. --- 289,293 ---- if (firstArg != null) { ! let superImplementation = getImplementationAbove(cast(method), firstArg); if (superImplementation != null && superImplementation.isAbstract() == false) // It's OK, this case is covered by a Java implementation. Index: userOperator.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/userOperator.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** userOperator.nice 1 Jan 2005 14:38:03 -0000 1.2 --- userOperator.nice 2 Jan 2005 02:21:00 -0000 1.3 *************** *** 41,45 **** this.getSymbol().doResolve(); ! symbols = parameters.getMonoSymbols(); if (symbols != null) { --- 41,45 ---- this.getSymbol().doResolve(); ! symbols = notNull(parameters).getMonoSymbols(); if (symbols != null) { *************** *** 76,80 **** // the default values of the formal parameters // (e.g. an anonymous function refering to a type parameter). ! let cst = this.getType().getConstraint(); if (mlsub.typing.Constraint.hasBinders(cst)) try { --- 76,80 ---- // the default values of the formal parameters // (e.g. an anonymous function refering to a type parameter). ! let cst = notNull(this.getType()).getConstraint(); if (mlsub.typing.Constraint.hasBinders(cst)) try { *************** *** 101,105 **** // Set bytecode types for type variables. ! mlsub.typing.FunType ft = cast(this.getType().getMonotype()); nice.tools.code.Types.setBytecodeType(ft.domain()); --- 101,105 ---- // Set bytecode types for type variables. ! mlsub.typing.FunType ft = cast(notNull(this.getType()).getMonotype()); nice.tools.code.Types.setBytecodeType(ft.domain()); Index: overloadedsymbol.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/overloadedsymbol.nice,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** overloadedsymbol.nice 4 Dec 2004 19:38:18 -0000 1.8 --- overloadedsymbol.nice 2 Jan 2005 02:20:59 -0000 1.9 *************** *** 624,629 **** for (int i = 0; i < syms.length; i++) for (int j = i+1; j < syms.length; j++) ! if (overlappingJavaMethods(syms[i].getMethodDeclaration(), ! syms[j].getMethodDeclaration())) { // We can remove either, since they lead to the same implementation --- 624,629 ---- for (int i = 0; i < syms.length; i++) for (int j = i+1; j < syms.length; j++) ! if (overlappingJavaMethods(cast(syms[i].getMethodDeclaration()), ! cast(syms[j].getMethodDeclaration()))) { // We can remove either, since they lead to the same implementation --- NEW FILE: methodDeclaration.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package bossa.syntax; import bossa.util.*; //import mlsub.typing.*; //import gnu.bytecode.*; //import gnu.expr.*; /** Declaration of a method. Can be - a {@link bossa.syntax.NiceMethod Nice method}, with several method bodies @see bossa.syntax.MethodBodyDefinition - a {@link bossa.syntax.JavaMethod Java method} - an {@link bossa.syntax.InlinedMethod inlined method} */ public abstract class MethodDeclaration extends Definition { int arity; ?FormalParameters parameters; private MethodSymbol symbol; ?mlsub.typing.Polytype type = null; private ?String syntacticConstraint = null; ?gnu.expr.Expression code = null; public ?mlsub.typing.Polytype getType() { return type; } public mlsub.typing.Monotype[] getArgTypes() { if (type == null) symbol.resolve(); return notNull(type).domain(); } public mlsub.typing.Monotype getReturnType() { return notNull(type).codomain(); } boolean isIgnored() { return false; } /** This is called in a pass before typechecking itself. This is important, to typecheck and disambiguate the default values of optional parameters, that will be used to typecheck code. */ void typedResolve() { if (module.interfaceFile() && ! notNull(parameters).hasDefaultValue()) return; if (!mlsub.typing.Constraint.hasBinders(notNull(type).getConstraint())) { notNull(parameters).typecheck(notNull(type).domain()); return; } try{ mlsub.typing.Typing.enter(); try{ notNull(notNull(type).getConstraint()).enter(); /* We typecheck with rigid type parameters. It means that default values must be valid for any instance of the method type. Alternatively, it could be decided that it is ok to have default values that satisfy only specific instances. In that case, it would be necessary to do some changes in K0. The difficulty is with overloading: the (now soft) type variables could be modified in an unsuccesful overloading resolution, and that modifications need to be discarded. */ mlsub.typing.Typing.implies(); notNull(parameters).typecheck(notNull(type).domain()); } finally{ mlsub.typing.Typing.leave(); } } catch(mlsub.typing.TypingEx e){ User.error(this, "The type of method " + symbol.name + " is not well formed: " + type + "\n" + e); } } /** Do further typechecking, once the context of the method is entered. */ void innerTypecheck() {} typecheck() { if (this.isIgnored()) return; // what we do here is equivalent to getType().checkWellFormedness(); // except we also want to find the bytecode types when // the constraint is asserted // see getType().checkWellFormedness mlsub.typing.Polytype type = notNull(this.getType()); ?UserError error = null; try{ if (mlsub.typing.Constraint.hasBinders(type.getConstraint())) mlsub.typing.Typing.enter(); else inGlobalContext = true; try{ mlsub.typing.Constraint.enter(type.getConstraint()); try { this.innerTypecheck(); } catch(UserError e){ error = e; } } finally{ if (! inGlobalContext) mlsub.typing.Typing.leave(); else inGlobalContext = false; } } catch(mlsub.typing.TypingEx e){ // If we got an earlier error, it's preferable to report that one. if (error == null) if (mlsub.typing.Constraint.hasBinders(type.getConstraint())) User.error(this, "The type of method " + symbol.name + " is not well formed: " + type + "\n" + e); else User.error(this, "Type error in method " + symbol.name); } if (error != null) throw error; } /** Typechecking when the package has already been compiled. */ void typecheckCompiled() { // Nothing by default } toString() { if(this.getType() == null) return "method " + this.getName(); return (syntacticConstraint != null ? notNull(syntacticConstraint) : mlsub.typing.Constraint.toString(notNull(this.getType()).getConstraint())) + String.valueOf(this.getReturnType()) + " " + this.getName().toQuotedString() + "(" // parameters can be null if type was set lowlevel (native code, ...) + (parameters != null ? notNull(parameters).toString() : Util.map("",", ","", notNull(this.getType()).domain())) + ")" ; } public int getArity() { return arity; } public ?FormalParameters formalParameters() { return parameters; } /** * true if this method represent the access to the field of an object. */ public boolean isFieldAccess() { return false; } void checkSpecialRequirements(Expression[?] arguments) { // Do nothing by default. } String explainWhyMatchFails(Arguments arguments) { return symbol.defaultExplainWhyMatchFails(arguments); } MethodSymbol getSymbol() { return symbol; } /**************************************************************** * Code generation ****************************************************************/ /** @return a string that uniquely represents this method */ public String getFullName() { return "NONE"; } public boolean specializesMethods() { return false; } public ?Iterator<MethodDeclaration> listSpecializedMethods() { return null; } /** @return a string that uniquely represents this method and those that it specializes. */ String getAllFullNames() { let i = this.listSpecializedMethods(); if (i == null) return this.getFullName(); StringBuffer res = new StringBuffer(); res.append(this.getFullName()); while (i.hasNext()) { res.append(methodListSeparator); res.append(i.next().getFullName()); } return res.toString(); } gnu.expr.Expression computeCode(); public gnu.expr.Expression getCode() { // Default implementation. return this.getCodeInCallPosition(); } /** Call to the constructor. This should be overriden by methods that really give access to a constructor. */ gnu.expr.Expression getConstructorInvocation(boolean omitDefaults) { throw new Error("Constructor for " + this + " (" + this.getClass() + ")"); } gnu.expr.Expression getCodeInCallPosition() { if (code == null) { code = this.computeCode(); if (code == null) Internal.error(this, "No code for " + this); } return notNull(code); } public gnu.bytecode.Type javaReturnType() { return nice.tools.code.Types.javaType(this.getReturnType()); } public gnu.bytecode.Type[] javaArgTypes() { return nice.tools.code.Types.javaType(notNull(this.getType()).domain()); } compile() {} } let char methodListSeparator = ';'; /** Whether typechecking is currently happening in the global context */ var boolean inGlobalContext = false; /** Make sure that we are in a local context, which will be discarded when typechecking this method is over. */ void enterLocalContext() { if (! inGlobalContext) return; mlsub.typing.Typing.enter(); inGlobalContext = false; } Index: defaultconstructor.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/defaultconstructor.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** defaultconstructor.nice 5 Nov 2004 22:46:55 -0000 1.2 --- defaultconstructor.nice 2 Jan 2005 02:20:59 -0000 1.3 *************** *** 75,79 **** let thisExp = new gnu.expr.ThisExp(thisDecl); ! let fullArgs = notNull(parameters.getMonoSymbols()); let fullArgTypes = this.javaArgTypes(); --- 75,79 ---- let thisExp = new gnu.expr.ThisExp(thisDecl); ! let fullArgs = notNull(notNull(parameters).getMonoSymbols()); let fullArgTypes = this.javaArgTypes(); *************** *** 81,87 **** List<gnu.bytecode.Type> argTypes = new LinkedList(); ! for (int i = 0; i < parameters.size; i++) { ! if (omitDefaults && parameters.hasDefaultValue(i)) continue; --- 81,87 ---- List<gnu.bytecode.Type> argTypes = new LinkedList(); ! for (int i = 0; i < notNull(parameters).size; i++) { ! if (omitDefaults && notNull(parameters).hasDefaultValue(i)) continue; *************** *** 114,118 **** // for the version omitting defaults, since that one is only there for // Java users' sake. ! lambda.addBytecodeAttribute(parameters.asBytecodeAttribute()); lambda.addBytecodeAttribute(new gnu.bytecode.MiscAttr("default")); } --- 114,118 ---- // for the version omitting defaults, since that one is only there for // Java users' sake. ! lambda.addBytecodeAttribute(notNull(parameters).asBytecodeAttribute()); lambda.addBytecodeAttribute(new gnu.bytecode.MiscAttr("default")); } *************** *** 131,135 **** for (int i = 0; i < len; i++) { ! if (! (omitDefaults && parameters.hasDefaultValue(i))) superArgs.add(args[i].compile()); } --- 131,135 ---- for (int i = 0; i < len; i++) { ! if (! (omitDefaults && notNull(parameters).hasDefaultValue(i))) superArgs.add(args[i].compile()); } Index: javaMethod.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/javaMethod.nice,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** javaMethod.nice 29 Dec 2004 16:31:02 -0000 1.4 --- javaMethod.nice 2 Jan 2005 02:20:59 -0000 1.5 *************** *** 29,34 **** } ! isJavaMethod() = true; ! getReflectMethod() = notNull(reflectMethod); /** @return a string that uniquely represents this method */ --- 29,33 ---- } ! public gnu.bytecode.Method getReflectMethod() = notNull(reflectMethod); /** @return a string that uniquely represents this method */ *************** *** 62,66 **** } ! registerForDispatch() { if (this.registered) --- 61,65 ---- } ! public void registerForDispatch() { if (this.registered) *************** *** 72,81 **** } - new JavaMethod( LocatedString name, mlsub.typing.Polytype type, - gnu.bytecode.Method reflectMethod ) - { - this( name, null, type, reflectMethod : reflectMethod ); - } - /** A Java constructor method. --- 71,74 ---- *************** *** 98,107 **** if (constructor) ! return new JavaConstructor( ! new LocatedString("new " + m.getDeclaringClass().getName(), ! Location.nowhere()), type, m); ! else ! return new JavaMethod(new LocatedString(m.getName(), Location.nowhere()), ! type, m); } --- 91,109 ---- if (constructor) ! { ! let name = new LocatedString("new " + m.getDeclaringClass().getName(), Location.nowhere()); ! let res = new JavaConstructor(name, Node.global, ! parameters: null, arity: type.domain().length, ! type: type, symbol: cast(null), reflectMethod: m); ! res.symbol = createMethodSymbol(res, name, type); ! return res; ! } ! ! let name = new LocatedString(m.getName(), Location.nowhere()); ! let res = new JavaMethod(name, Node.global, ! parameters: null, arity: type.domain().length, ! type: type, symbol: cast(null), reflectMethod: m); ! res.symbol = createMethodSymbol(res, name, type); ! return res; } Index: symbol.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/symbol.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** symbol.nice 1 Jan 2005 16:36:31 -0000 1.3 --- symbol.nice 2 Jan 2005 02:21:00 -0000 1.4 *************** *** 198,202 **** Constraint constraint, Monotype returnType ) { ! FormalParameters parameters = declaration.formalParameters(); this(name, declaration: declaration, parameters: parameters, arity: parameters.size, syntacticType: new Polytype(constraint, createFunType(parameters.types(), returnType))); --- 198,202 ---- Constraint constraint, Monotype returnType ) { ! FormalParameters parameters = notNull(declaration.formalParameters()); this(name, declaration: declaration, parameters: parameters, arity: parameters.size, syntacticType: new Polytype(constraint, createFunType(parameters.types(), returnType))); *************** *** 228,236 **** // Bootstrap (for conversion to nice) ! VarSymbol createMethodSymbol(MethodDeclaration declaration, LocatedString name, Constraint constraint, Monotype returnType ) = new MethodSymbol(declaration,name,constraint,returnType); ! VarSymbol createMethodSymbol(MethodDeclaration declaration, LocatedString name, mlsub.typing.Polytype type ) = new MethodSymbol(declaration,name,type); --- 228,236 ---- // Bootstrap (for conversion to nice) ! MethodSymbol createMethodSymbol(MethodDeclaration declaration, LocatedString name, Constraint constraint, Monotype returnType ) = new MethodSymbol(declaration,name,constraint,returnType); ! MethodSymbol createMethodSymbol(MethodDeclaration declaration, LocatedString name, mlsub.typing.Polytype type ) = new MethodSymbol(declaration,name,type); --- MethodDeclaration.java DELETED --- Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.87 retrieving revision 1.88 diff -C2 -d -r1.87 -r1.88 *** tools.nice 1 Jan 2005 16:36:31 -0000 1.87 --- tools.nice 2 Jan 2005 02:21:00 -0000 1.88 *************** *** 70,74 **** // Make sure we are in a local typing context, so the new type variables // are discarded when the typechecking of the current method is over. ! MethodDeclaration.enterLocalContext(); notNull(type.getConstraint).enter(true); --- 70,74 ---- // Make sure we are in a local typing context, so the new type variables // are discarded when the typechecking of the current method is over. ! enterLocalContext(); notNull(type.getConstraint).enter(true); *************** *** 227,231 **** MonoSymbol[?] getMonoSymbols(FormalParameters) = native MonoSymbol[] FormalParameters.getMonoSymbols(); mlsub.typing.AtomicConstraint[?] AtomicConstraint_substitute(java.util.Map<mlsub.typing.TypeSymbol,mlsub.typing.TypeSymbol>, AtomicConstraint[?]) = native mlsub.typing.AtomicConstraint[] mlsub.typing.AtomicConstraint.substitute(java.util.Map, mlsub.typing.AtomicConstraint[]); - FormalParameters parameters(MethodDeclaration) = native MethodDeclaration.parameters; ?gnu.expr.Expression getInitializer(NiceClass) = native gnu.expr.Expression NiceClass.getInitializer(); void addConstructorCallSymbol(NiceClass, VarSymbol) = native void NiceClass.addConstructorCallSymbol(VarSymbol); --- 227,230 ---- *************** *** 274,278 **** ?mlsub.typing.TypeSymbol lookup(TypeMap, String) = native mlsub.typing.TypeSymbol TypeMap.lookup(String); void substitute(bossa.syntax.FormalParameters, Map<java.lang.String, bossa.syntax.Monotype>) = native void FormalParameters.substitute(Map); - ?Iterator<MethodDeclaration> listSpecializedMethods(MethodDeclaration) = native Iterator MethodDeclaration.listSpecializedMethods(); Monotype[] Monotype_toArray(?List<Monotype>) = native Monotype[] Monotype.toArray(List); List<VarSymbol> lookup(VarScope, LocatedString) = native List VarScope.lookup(LocatedString); --- 273,276 ---- Index: importedconstructor.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/importedconstructor.nice,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** importedconstructor.nice 20 Dec 2004 16:05:18 -0000 1.5 --- importedconstructor.nice 2 Jan 2005 02:20:59 -0000 1.6 *************** *** 40,44 **** // the default values of the formal parameters // (e.g. an anonymous function refering to a type parameter). ! let cst = this.getType().getConstraint(); if (mlsub.typing.Constraint.hasBinders(cst)) try { --- 40,44 ---- // the default values of the formal parameters // (e.g. an anonymous function refering to a type parameter). ! let cst = notNull(this.getType()).getConstraint(); if (mlsub.typing.Constraint.hasBinders(cst)) try { *************** *** 77,82 **** List<gnu.bytecode.Type> argTypes = new LinkedList(); ! for (int i = 0; i < parameters.size; i++) ! if (! parameters.hasDefaultValue(i)) argTypes.add(fullArgTypes[i]); --- 77,82 ---- List<gnu.bytecode.Type> argTypes = new LinkedList(); ! for (int i = 0; i < notNull(parameters).size; i++) ! if (! notNull(parameters).hasDefaultValue(i)) argTypes.add(fullArgTypes[i]); *************** *** 100,112 **** let constraint = classDef.classConstraint == null ? ! null : notNull(classDef.classConstraint).shallowClone(); ! let res = new ImportedConstructor( ! new LocatedString("<init>",def.getDefinition().location()), ! constraint, returnType, ! FormalParameters.readBytecodeAttribute(attr, ! notNull(Node.compilation).parser), ! classe: def, isDefault: gnu.bytecode.Attribute.get(method, "default") != null, ! method: method); addConstructor(res.classe.getDefinition().getTC(), res); --- 100,122 ---- let constraint = classDef.classConstraint == null ? ! bossa.syntax.Constraint.True : notNull(classDef.classConstraint).shallowClone(); ! let name = new LocatedString("<init>",def.getDefinition().location()); ! let parameters = FormalParameters.readBytecodeAttribute(attr, ! notNull(Node.compilation).parser); ! ! let res = new ImportedConstructor(name, Node.down, ! parameters: parameters, ! arity: parameters.size, ! syntacticConstraint: constraint.toString(), ! symbol: cast(null), ! classe: def, ! isDefault: gnu.bytecode.Attribute.get(method, "default") != null, ! method: method); ! res.addChild(parameters); ! let symbol = createMethodSymbol(res, name, constraint, returnType); ! res.symbol = symbol; ! symbol.propagate = Node.global; ! res.addChild(symbol); addConstructor(res.classe.getDefinition().getTC(), res); Index: dispatch.java.bootstrap =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/dispatch.java.bootstrap,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** dispatch.java.bootstrap 30 Dec 2004 18:49:01 -0000 1.48 --- dispatch.java.bootstrap 2 Jan 2005 02:20:59 -0000 1.49 *************** *** 42,63 **** { return null;} - public static Expression createIdentExp(LocatedString i) - { return null; } - - public static Expression createCallExp(Expression function, Expression param1) - { return null; } - - public static Expression createCallExp(Expression function, Expression param1, Expression param2) - { return null; } - - public static VarSymbol createMethodSymbol(MethodDeclaration declaration, LocatedString name, Constraint constraint, Monotype returnType) - { return null; } - - public static VarSymbol createMethodSymbol(MethodDeclaration declaration, LocatedString name, mlsub.typing.Polytype type) - { return null; } - - public static gnu.bytecode.Method getImplementationAbove(MethodDeclaration decl, gnu.bytecode.ClassType firstArg) - { return null; } - static Expression analyse(Expression e, VarScope v, TypeScope t) { return null; } --- 42,45 ---- Index: VarSymbol.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/VarSymbol.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** VarSymbol.java 1 Jan 2005 16:36:31 -0000 1.39 --- VarSymbol.java 2 Jan 2005 02:20:59 -0000 1.40 *************** *** 54,58 **** } ! public MethodDeclaration getMethodDeclaration() { return null; --- 54,58 ---- } ! public Object getMethodDeclaration() { return null; Index: defaultMethod.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/defaultMethod.nice,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** defaultMethod.nice 1 Jan 2005 13:10:55 -0000 1.4 --- defaultMethod.nice 2 Jan 2005 02:20:59 -0000 1.5 *************** *** 130,135 **** formals: parameters.asList().mapToArray(FormalParameters.Parameter param => createPattern(param.getName() || new LocatedString("_", name.location())))); ! res.declaration = new MethodWithDefault(name, constraint, returnType, ! parameters, contract: contract, isOverride: isOverride, implementation: res); res.addChild(res.declaration); return res; --- 130,143 ---- formals: parameters.asList().mapToArray(FormalParameters.Parameter param => createPattern(param.getName() || new LocatedString("_", name.location())))); ! res.declaration = new MethodWithDefault(name, Node.down, ! parameters: parameters, arity: parameters.size, ! syntacticConstraint: constraint.toString(), symbol: cast(null), ! contract: contract, isOverride: isOverride, implementation: res); ! notNull(res.declaration).addChild(parameters); ! let symbol = createMethodSymbol(notNull(res.declaration), name, constraint, returnType); ! notNull(res.declaration).symbol = symbol; ! symbol.propagate = Node.global; ! notNull(res.declaration).addChild(symbol); ! res.addChild(res.declaration); return res; |
From: Arjan B. <ar...@us...> - 2005-01-02 02:21:10
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1879/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Converted MethodDeclaration. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.294 retrieving revision 1.295 diff -C2 -d -r1.294 -r1.295 *** Parser.jj 1 Jan 2005 16:36:31 -0000 1.294 --- Parser.jj 2 Jan 2005 02:20:57 -0000 1.295 *************** *** 1408,1412 **** ] ";" ! { res=new InlinedMethod(name,cst,returnType,parameters, inlinedName, param); } ) --- 1408,1412 ---- ] ";" ! { res=bossa.syntax.dispatch.createInlinedMethod(name,cst,returnType,parameters, inlinedName, param); } ) *************** *** 1424,1428 **** // Nice method ";" ! { res = new NiceMethod (name, cst, returnType, parameters, contract, isOverride); } ) --- 1424,1428 ---- // Nice method ";" ! { res = bossa.syntax.dispatch.createNiceMethod (name, cst, returnType, parameters, contract, isOverride); } ) |
From: Arjan B. <ar...@us...> - 2005-01-01 16:36:42
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3659/F:/nice/src/bossa/syntax Modified Files: Expression.java NiceUtils.java VarSymbol.java call.nice increment.nice javaFieldAccess.nice nicefieldaccess.nice symbol.nice symbolexp.nice tools.nice typecheck.nice Added Files: fieldAccess.nice Removed Files: FieldAccess.java Log Message: Converted FieldAccess. --- FieldAccess.java DELETED --- Index: Expression.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Expression.java,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** Expression.java 5 Aug 2004 10:45:29 -0000 1.57 --- Expression.java 1 Jan 2005 16:36:31 -0000 1.58 *************** *** 59,63 **** * @return the FieldAccess behind this expression, or null */ ! FieldAccess getFieldAccessMethod() { return null; --- 59,63 ---- * @return the FieldAccess behind this expression, or null */ ! /*FieldAccess*/Object getFieldAccessMethod() { return null; *************** *** 69,73 **** value. Returns null otherwise. */ ! FieldAccess getField() { return null; --- 69,73 ---- value. Returns null otherwise. */ ! /*FieldAccess*/Object getField() { return null; Index: typecheck.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typecheck.nice,v retrieving revision 1.119 retrieving revision 1.120 diff -C2 -d -r1.119 -r1.120 *** typecheck.nice 30 Dec 2004 20:58:37 -0000 1.119 --- typecheck.nice 1 Jan 2005 16:36:31 -0000 1.120 *************** *** 73,77 **** } ! ?FieldAccess field = to.getField(); String toName; if (field == null) --- 73,77 ---- } ! ?FieldAccess field = cast(to.getField()); String toName; if (field == null) Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -d -r1.86 -r1.87 *** tools.nice 30 Dec 2004 18:49:01 -0000 1.86 --- tools.nice 1 Jan 2005 16:36:31 -0000 1.87 *************** *** 215,221 **** ?mlsub.typing.lowlevel.Kind getKind(mlsub.typing.lowlevel.Element) = native mlsub.typing.lowlevel.Kind mlsub.typing.lowlevel.Element.getKind(); ?gnu.expr.Declaration getDeclaration(Expression) = native gnu.expr.Declaration Expression.getDeclaration(); ! ?FieldAccess getFieldAccessMethod(Expression) = native FieldAccess Expression.getFieldAccessMethod(); ! ?FieldAccess getField(Expression) = native FieldAccess Expression.getField(); ! ?FieldAccess getFieldAccessMethod(VarSymbol) = native FieldAccess VarSymbol.getFieldAccessMethod(); ?mlsub.typing.Monotype Types_getTypeParameter(mlsub.typing.Polytype, int) = native mlsub.typing.Monotype nice.tools.typing.Types.getTypeParameter(mlsub.typing.Polytype, int); ?mlsub.typing.Monotype Types_getTypeParameter(mlsub.typing.Monotype, int) = native mlsub.typing.Monotype nice.tools.typing.Types.getTypeParameter(mlsub.typing.Monotype, int); --- 215,221 ---- ?mlsub.typing.lowlevel.Kind getKind(mlsub.typing.lowlevel.Element) = native mlsub.typing.lowlevel.Kind mlsub.typing.lowlevel.Element.getKind(); ?gnu.expr.Declaration getDeclaration(Expression) = native gnu.expr.Declaration Expression.getDeclaration(); ! ?Object getFieldAccessMethod(Expression) = native Object Expression.getFieldAccessMethod(); ! ?Object getField(Expression) = native Object Expression.getField(); ! ?Object getFieldAccessMethod(VarSymbol) = native Object VarSymbol.getFieldAccessMethod(); ?mlsub.typing.Monotype Types_getTypeParameter(mlsub.typing.Polytype, int) = native mlsub.typing.Monotype nice.tools.typing.Types.getTypeParameter(mlsub.typing.Polytype, int); ?mlsub.typing.Monotype Types_getTypeParameter(mlsub.typing.Monotype, int) = native mlsub.typing.Monotype nice.tools.typing.Types.getTypeParameter(mlsub.typing.Monotype, int); Index: NiceUtils.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/NiceUtils.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** NiceUtils.java 29 Dec 2004 20:22:27 -0000 1.4 --- NiceUtils.java 1 Jan 2005 16:36:31 -0000 1.5 *************** *** 15,18 **** --- 15,23 ---- public final class NiceUtils { + public static gnu.expr.Expression doInline(gnu.mapping.Procedure1 proc) + { + return nice.tools.code.Inline.inline(proc); + } + public static gnu.expr.Expression doInline(gnu.mapping.Procedure1 proc, gnu.expr.Expression arg1) { --- NEW FILE: fieldAccess.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package bossa.syntax; import bossa.util.*; /** A field access. In terms of scoping, this is the symbol that is returned when the access to a field is done, either a 'get' or a 'set'. */ abstract class FieldAccess extends MethodDeclaration { ?gnu.expr.Declaration fieldDecl = null; /** * true if this method represent the access to the field of an object. */ isFieldAccess() = true; public boolean isFinal(); public boolean isStatic() = false; computeCode() { throw new UsingFieldAsValue(); } public gnu.expr.Expression compileAccess(gnu.expr.Expression[] arguments) { if (arguments.length == 0) return NiceUtils.doInline(new nice.tools.code.GetFieldProc(fieldDecl)); else return NiceUtils.doInline(new nice.tools.code.GetFieldProc(fieldDecl), arguments[0]); } public gnu.expr.Expression compileAssign(gnu.expr.Expression value) { return NiceUtils.doInline( new nice.tools.code.SetStaticFieldProc(fieldDecl), value); } public gnu.expr.Expression compileAssign(gnu.expr.Expression parameter, gnu.expr.Expression value) { return NiceUtils.doInline( new nice.tools.code.SetFieldProc(fieldDecl), parameter, value); } } class UsingFieldAsValue extends Error {} Index: symbolexp.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/symbolexp.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** symbolexp.nice 4 Dec 2004 19:38:18 -0000 1.1 --- symbolexp.nice 1 Jan 2005 16:36:31 -0000 1.2 *************** *** 49,53 **** return symbol.compile(); } ! catch(FieldAccess.UsingAsValue e) { throw User.error(this, "You must supply the object that contains this field"); --- 49,53 ---- return symbol.compile(); } ! catch(UsingFieldAsValue e) { throw User.error(this, "You must supply the object that contains this field"); *************** *** 62,66 **** return res; } ! catch(FieldAccess.UsingAsValue e) { throw User.error(this, "You must supply the object that contains this field"); --- 62,66 ---- return res; } ! catch(UsingFieldAsValue e) { throw User.error(this, "You must supply the object that contains this field"); Index: symbol.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/symbol.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** symbol.nice 15 Dec 2004 03:45:59 -0000 1.2 --- symbol.nice 1 Jan 2005 16:36:31 -0000 1.3 *************** *** 239,240 **** --- 239,253 ---- LocatedString name, mlsub.typing.Polytype type ) = new ConstructorCallSymbol(declaration,name,type); + + + boolean isNonStaticFieldAccess(VarSymbol sym) + { + FieldAccess access = cast(sym.getFieldAccessMethod()); + return access != null && ! access.isStatic(); + } + + boolean isStaticFieldAccess(VarSymbol sym) + { + FieldAccess access = cast(sym.getFieldAccessMethod()); + return access != null && access.isStatic(); + } Index: javaFieldAccess.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/javaFieldAccess.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** javaFieldAccess.nice 23 Dec 2004 15:22:05 -0000 1.2 --- javaFieldAccess.nice 1 Jan 2005 16:36:31 -0000 1.3 *************** *** 107,118 **** } ! new JavaFieldAccess(LocatedString className,String fieldName, LocatedString name,Constraint cst, Monotype returnType, FormalParameters parameters) { ! this(name, cst, parameters, returnType, className : className, fieldName : fieldName ); } new JavaFieldAccess(gnu.bytecode.Field field, mlsub.typing.Monotype[?] parameters) --- 107,119 ---- } ! JavaFieldAccess createJavaFieldAccess(LocatedString className,String fieldName, LocatedString name,Constraint cst, Monotype returnType, FormalParameters parameters) { ! return new JavaFieldAccess(name, cst, returnType, parameters, className : className, fieldName : fieldName ); } + new JavaFieldAccess(gnu.bytecode.Field field, mlsub.typing.Monotype[?] parameters) Index: nicefieldaccess.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/nicefieldaccess.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** nicefieldaccess.nice 25 Nov 2004 19:28:18 -0000 1.2 --- nicefieldaccess.nice 1 Jan 2005 16:36:31 -0000 1.3 *************** *** 48,53 **** return new NiceFieldAccess(field.getName(), Constraint.create(classDef.getBinders()), new FormalParameters([new FormalParameters.Parameter(Monotype.create(argType))]), ! field.sym.syntacticType, field: field); } --- 48,54 ---- return new NiceFieldAccess(field.getName(), Constraint.create(classDef.getBinders()), + field.sym.syntacticType, new FormalParameters([new FormalParameters.Parameter(Monotype.create(argType))]), ! field: field); } Index: VarSymbol.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/VarSymbol.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** VarSymbol.java 21 Nov 2004 23:24:37 -0000 1.38 --- VarSymbol.java 1 Jan 2005 16:36:31 -0000 1.39 *************** *** 49,65 **** } ! final boolean isNonStaticFieldAccess() ! { ! FieldAccess access = getFieldAccessMethod(); ! return access != null && ! access.isStatic(); ! } ! ! final boolean isStaticFieldAccess() ! { ! FieldAccess access = getFieldAccessMethod(); ! return access != null && access.isStatic(); ! } ! ! FieldAccess getFieldAccessMethod() { return null; --- 49,53 ---- } ! Object getFieldAccessMethod() { return null; Index: increment.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/increment.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** increment.nice 13 Oct 2004 23:22:22 -0000 1.3 --- increment.nice 1 Jan 2005 16:36:31 -0000 1.4 *************** *** 48,52 **** CallExp call = cast(variable); ! let access = call.function.getFieldAccessMethod(); if (access == null) Internal.error(this, "\"var\" is assignable and not a local, " + --- 48,52 ---- CallExp call = cast(variable); ! let ?FieldAccess access = cast(call.function.getFieldAccessMethod()); if (access == null) Internal.error(this, "\"var\" is assignable and not a local, " + Index: call.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/call.nice,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** call.nice 4 Dec 2004 19:38:18 -0000 1.6 --- call.nice 1 Jan 2005 16:36:31 -0000 1.7 *************** *** 111,115 **** { this.resolveOverloading(); ! let ?FieldAccess fa = function.getFieldAccessMethod(); return fa != null && ! fa.isFinal(); } --- 111,115 ---- { this.resolveOverloading(); ! let ?FieldAccess fa = cast(function.getFieldAccessMethod()); return fa != null && ! fa.isFinal(); } *************** *** 156,160 **** gnu.expr.Expression res; if (function.isFieldAccess()) ! res = notNull(function.getFieldAccessMethod()).compileAccess(this.compileParams()); else res = new gnu.expr.ApplyExp(function.generateCodeInCallPosition(), this.compileParams()); --- 156,160 ---- gnu.expr.Expression res; if (function.isFieldAccess()) ! res = cast(function.getFieldAccessMethod()).compileAccess(this.compileParams()); else res = new gnu.expr.ApplyExp(function.generateCodeInCallPosition(), this.compileParams()); *************** *** 198,202 **** Internal.error(this, "Assignment to a call that is not a field access"); ! FieldAccess access = notNull(function.getFieldAccessMethod()); if (access.isFinal()) --- 198,202 ---- Internal.error(this, "Assignment to a call that is not a field access"); ! FieldAccess access = cast(function.getFieldAccessMethod()); if (access.isFinal()) |
From: Arjan B. <ar...@us...> - 2005-01-01 16:36:39
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3659/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Converted FieldAccess. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.293 retrieving revision 1.294 diff -C2 -d -r1.293 -r1.294 *** Parser.jj 1 Jan 2005 14:38:03 -0000 1.293 --- Parser.jj 1 Jan 2005 16:36:31 -0000 1.294 *************** *** 1486,1490 **** name,cst,returnType,parameters); else ! return new JavaFieldAccess(className,methodName, name,cst,returnType,parameters); } --- 1486,1490 ---- name,cst,returnType,parameters); else ! return bossa.syntax.dispatch.createJavaFieldAccess(className,methodName, name,cst,returnType,parameters); } |
From: Arjan B. <ar...@us...> - 2005-01-01 14:38:27
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13867/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Converted Contract. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.292 retrieving revision 1.293 diff -C2 -d -r1.292 -r1.293 *** Parser.jj 31 Dec 2004 18:40:43 -0000 1.292 --- Parser.jj 1 Jan 2005 14:38:03 -0000 1.293 *************** *** 1513,1517 **** Contract contract() : { ! Contract res = Contract.noContract; Expression condition, name; } --- 1513,1517 ---- Contract contract() : { ! Contract res = bossa.syntax.fun.noContract; Expression condition, name; } *************** *** 1520,1524 **** contractElements(res, true) ] ! [ "ensures" { if (res == Contract.noContract) res = new Contract(); } contractElements(res, false) ] --- 1520,1524 ---- contractElements(res, true) ] ! [ "ensures" { if (res == bossa.syntax.fun.noContract) res = new Contract(); } contractElements(res, false) ] |