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