[Nice-commit] Nice/src/bossa/syntax contract.nice,1.1,1.2 customConstructor.nice,1.11,1.12 enum.nice
Brought to you by:
bonniot
|
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 |