[Nice-commit] Nice/src/bossa/syntax Alike.java,1.7,1.8 customConstructor.nice,1.1,1.2 dispatch.java.
Brought to you by:
bonniot
From: Arjan B. <ar...@us...> - 2004-12-16 16:21:18
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5485/F:/nice/src/bossa/syntax Modified Files: Alike.java customConstructor.nice dispatch.java.bootstrap enum.nice loop.nice monotype.nice tools.nice try.nice Removed Files: MonotypeConstructor.java Log Message: Converted MonotypeConstructor. Index: loop.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/loop.nice,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** loop.nice 7 Dec 2004 17:33:57 -0000 1.6 --- loop.nice 16 Dec 2004 16:21:07 -0000 1.7 *************** *** 135,139 **** List<Monotype> tparams = new ArrayList(1); tparams.add(vartype); ! itertype = new MonotypeConstructor(new TypeIdent(new LocatedString("Iterator", loc)), new TypeParameters(tparams), loc); notNull(itertype).nullness = Monotype.sure; --- 135,139 ---- List<Monotype> tparams = new ArrayList(1); tparams.add(vartype); ! itertype = createMonotypeConstructor(new TypeIdent(new LocatedString("Iterator", loc)), new TypeParameters(tparams), loc); notNull(itertype).nullness = Monotype.sure; Index: monotype.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/monotype.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** monotype.nice 15 Dec 2004 03:45:59 -0000 1.1 --- monotype.nice 16 Dec 2004 16:21:07 -0000 1.2 *************** *** 16,19 **** --- 16,102 ---- /** + A monotype, build by application of + a type constructor to type parameters. + + */ + public class MonotypeConstructor extends Monotype + { + public ?TypeIdent tc = null; + // used when the lowlevel TC is know in advance + private ?mlsub.typing.TypeConstructor lowlevelTC = null; + TypeParameters parameters; + ?Location loc; + + Monotype cloneType() = new MonotypeConstructor(tc:tc,parameters:parameters,loc:loc); + + rawResolve(typeMap) + { + if (lowlevelTC == null) + { + let newTC = notNull(this.tc).resolveToTC(typeMap); + if (! (newTC instanceof TypeConstructor)) + throw User.error(notNull(this.tc), notNull(this.tc)+" should be a type constructor"); + lowlevelTC = newTC; + } + + mlsub.typing.Monotype[] resolvedParams = parameters.resolve(typeMap); + + try{ + return new mlsub.typing.MonotypeConstructor(lowlevelTC, resolvedParams); + } + catch(mlsub.typing.BadSizeEx e){ + // See if this is a class with default type parameters + let res = getTypeWithTC(notNull(lowlevelTC), resolvedParams); + if (res == null) + throw User.error(this, (tc!=null ? "Class "+tc : notNull(lowlevelTC).toString()) + + Util.has(e.expected, "type parameter", e.actual)); + + return res; + } + } + + substitute(map) + { + let TypeIdent newTC = cast(map.get(notNull(tc))) || notNull(tc); + + Monotype res = createMonotypeConstructor + (newTC, + new TypeParameters(Monotype.substitute(map, notNull(parameters.content))), + loc); + res.nullness = this.nullness; + return res; + } + + containsAlike() = Monotype.containsAlike(notNull(parameters.content)); + + public ?TypeIdent getTC() = tc; + + public TypeParameters getTP() = parameters; + + location() = loc || notNull(tc).location(); + + toString() + { + return this.nullnessString() + + (lowlevelTC != null ? notNull(lowlevelTC).toString() : notNull(tc).toString()) + + parameters; + } + + } + + public MonotypeConstructor createMonotypeConstructor(TypeIdent tc, ?TypeParameters parameters, + ?Location loc) + { + return new MonotypeConstructor(tc: tc, + parameters: parameters || new TypeParameters([]), loc: loc); + } + + Monotype createMonotypeConstructor(mlsub.typing.TypeConstructor tc, TypeParameters parameters, + Location loc) + { + return new MonotypeConstructor(lowlevelTC: tc, parameters: parameters, loc: loc); + } + + /** Functional type. Index: Alike.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Alike.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Alike.java 28 May 2003 12:57:25 -0000 1.7 --- Alike.java 16 Dec 2004 16:21:07 -0000 1.8 *************** *** 54,58 **** return this; ! Monotype res = new MonotypeConstructor ((mlsub.typing.TypeConstructor) tc, new TypeParameters(Monotype.substitute(map, parameters)), --- 54,58 ---- return this; ! Monotype res = dispatch.createMonotypeConstructor ((mlsub.typing.TypeConstructor) tc, new TypeParameters(Monotype.substitute(map, parameters)), Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** tools.nice 15 Dec 2004 03:45:59 -0000 1.73 --- tools.nice 16 Dec 2004 16:21:07 -0000 1.74 *************** *** 193,196 **** --- 193,197 ---- List<VarSymbol> findJavaMethods(?gnu.bytecode.ClassType, String) = native List JavaClasses.findJavaMethods(gnu.bytecode.ClassType,java.lang.String); TypeParameters TypeParameters(List<Monotype>) = native new bossa.syntax.TypeParameters(List); + TypeParameters TypeParameters(Monotype[]) = native new bossa.syntax.TypeParameters(Monotype[]); ?String explainNoMatch(Arguments, List<VarSymbol>) = native String Arguments.explainNoMatch(List); Map<VarSymbol,mlsub.typing.Polytype> types(Arguments) = native Arguments.types; *************** *** 252,257 **** ?String getParentFor(AtomicConstraint, mlsub.typing.TypeConstructor) = native String AtomicConstraint.getParentFor(mlsub.typing.TypeConstructor); mlsub.typing.AtomicConstraint resolve(AtomicConstraint, TypeScope) = native mlsub.typing.AtomicConstraint AtomicConstraint.resolve(TypeScope); ! bossa.syntax.Monotype substitute(bossa.syntax.Monotype,Map<String,bossa.syntax.Monotype>) = native bossa.syntax.Monotype bossa.syntax.Monotype.substitute(Map); ! List<bossa.syntax.Monotype> substitute(Map<String,bossa.syntax.Monotype>,Collection<bossa.syntax.Monotype>) = native List bossa.syntax.Monotype.substitute(Map,Collection); 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); --- 253,258 ---- ?String getParentFor(AtomicConstraint, mlsub.typing.TypeConstructor) = native String AtomicConstraint.getParentFor(mlsub.typing.TypeConstructor); mlsub.typing.AtomicConstraint resolve(AtomicConstraint, TypeScope) = native mlsub.typing.AtomicConstraint AtomicConstraint.resolve(TypeScope); ! bossa.syntax.Monotype substitute(bossa.syntax.Monotype,Map<TypeIdent,bossa.syntax.Monotype>) = native bossa.syntax.Monotype bossa.syntax.Monotype.substitute(Map); ! List<bossa.syntax.Monotype> substitute(Map<TypeIdent,bossa.syntax.Monotype>,Collection<bossa.syntax.Monotype>) = native List bossa.syntax.Monotype.substitute(Map,Collection); 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); *************** *** 261,265 **** 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(); --- 262,266 ---- List<FormalParameters.Parameter> asList(FormalParameters) = native List FormalParameters.asList(); boolean containsAlike(Monotype[]) = native boolean Monotype.containsAlike(Monotype[]); ! bossa.syntax.Monotype[] substitute(Map<TypeIdent,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(); Index: enum.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/enum.nice,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** enum.nice 7 Dec 2004 17:33:57 -0000 1.7 --- enum.nice 16 Dec 2004 16:21:07 -0000 1.8 *************** *** 67,71 **** let classDef = makeClass (name,true,false, null, new ArrayList(), ! new MonotypeConstructor(new TypeIdent(new LocatedString("nice.lang.Enum", name.location())), null, name.location()), interfaces, null); let impl = createNiceClass(classDef); --- 67,71 ---- let classDef = makeClass (name,true,false, null, new ArrayList(), ! createMonotypeConstructor(new TypeIdent(new LocatedString("nice.lang.Enum", name.location())), null, name.location()), interfaces, null); let impl = createNiceClass(classDef); Index: dispatch.java.bootstrap =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/dispatch.java.bootstrap,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** dispatch.java.bootstrap 11 Dec 2004 23:58:02 -0000 1.32 --- dispatch.java.bootstrap 16 Dec 2004 16:21:07 -0000 1.33 *************** *** 13,16 **** --- 13,19 ---- public class dispatch { + static Monotype createMonotypeConstructor(mlsub.typing.TypeConstructor tc, TypeParameters parameters, bossa.util.Location loc) + { return null; } + public static Expression createIdentExp(LocatedString i) { return null; } Index: try.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/try.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** try.nice 1 Dec 2004 02:00:32 -0000 1.2 --- try.nice 16 Dec 2004 16:21:07 -0000 1.3 *************** *** 101,105 **** public new ACatch(TypeIdent tc, LocatedString varName, Statement body) { ! Monotype type = new MonotypeConstructor(tc, null, tc.location()); type.nullness = Monotype.sure; --- 101,105 ---- public new ACatch(TypeIdent tc, LocatedString varName, Statement body) { ! Monotype type = createMonotypeConstructor(tc, null, tc.location()); type.nullness = Monotype.sure; Index: customConstructor.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/customConstructor.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** customConstructor.nice 11 Dec 2004 23:58:02 -0000 1.1 --- customConstructor.nice 16 Dec 2004 16:21:07 -0000 1.2 *************** *** 158,162 **** TypeSymbol[] syms = cst.getBinderArray(); ! Monotype[?] params = cast(new Monotype[syms.length]); for (int i = 0; i < syms.length; i++) --- 158,162 ---- TypeSymbol[] syms = cst.getBinderArray(); ! Monotype[] params = cast(new Monotype[syms.length]); for (int i = 0; i < syms.length; i++) *************** *** 167,171 **** } ! let res = new MonotypeConstructor (classe, new TypeParameters(params), classe.location()); res.nullness = Monotype.sure; --- 167,171 ---- } ! let res = createMonotypeConstructor (classe, new TypeParameters(params), classe.location()); res.nullness = Monotype.sure; --- MonotypeConstructor.java DELETED --- |