[Nice-commit] Nice/src/bossa/syntax formalParameters.nice,NONE,1.1 VarSymbol.java,1.40,1.41 analyse.
Brought to you by:
bonniot
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, |