[Nice-commit] Nice/src/bossa/syntax typeIdent.nice,NONE,1.1 Monotype.java,1.38,1.39 Pattern.java,1.9
Brought to you by:
bonniot
From: Arjan B. <ar...@us...> - 2004-12-18 19:41:20
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7828/F:/nice/src/bossa/syntax Modified Files: Monotype.java Pattern.java ai.nice customConstructor.nice dispatch.java.bootstrap enum.nice loop.nice methodbody.nice monotype.nice pattern.nice typedef.nice Added Files: typeIdent.nice Removed Files: TypeIdent.java Log Message: Converted TypeIdent. Index: Pattern.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Pattern.java,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -d -r1.95 -r1.96 *** Pattern.java 1 Dec 2004 02:00:31 -0000 1.95 --- Pattern.java 18 Dec 2004 19:41:00 -0000 1.96 *************** *** 35,40 **** { LocatedString name; ! TypeIdent typeConstructor; ! private TypeIdent additional; TypeConstructor tc; TypeConstructor tc2; --- 35,40 ---- { LocatedString name; ! /*TypeIdent*/bossa.syntax.Monotype typeConstructor; ! private /*TypeIdent*/bossa.syntax.Monotype additional; TypeConstructor tc; TypeConstructor tc2; *************** *** 60,64 **** } ! Pattern(TypeConstructor tc, TypeIdent add, Location loc) { this.tc = tc; --- 60,64 ---- } ! Pattern(TypeConstructor tc, /*TypeIdent*/bossa.syntax.Monotype add, Location loc) { this.tc = tc; *************** *** 67,71 **** } ! Pattern(LocatedString name, TypeIdent ti, TypeIdent add, Location loc) { this.name = name; --- 67,71 ---- } ! Pattern(LocatedString name, /*TypeIdent*/bossa.syntax.Monotype ti, /*TypeIdent*/bossa.syntax.Monotype add, Location loc) { this.name = name; --- NEW FILE: typeIdent.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package bossa.syntax; import bossa.util.*; /** A syntactic type identifier. After scoping, it will either reveal to be a TypeConstructor or a MonotypeVar. */ public final class TypeIdent extends bossa.syntax.Monotype implements Located { public LocatedString name; public TypeIdent cloneTypeIdent() { return new TypeIdent(name: name); } containsAlike() = false; isVoid() = "void".equals(name.toString()); substitute(map) { return map.get(name.toString()) || this; } resolveToTypeSymbol(scope) { let res = notNull(scope).lookup(name); if (res == null) throw unknownIdent(name); return res; } rawResolve(scope) { let res = this.resolveToTypeSymbol(scope); if (res instanceof mlsub.typing.Monotype) return res; if (res instanceof mlsub.typing.TypeConstructor) { try{ return nice.tools.typing.Types.zeroArgMonotype(res); } catch(mlsub.typing.BadSizeEx e){ // See if this is a class with default type parameters let type = getTypeWithTC(res); if (type != null) return type; throw User.error(this, name + Util.has(e.expected, "type parameter", e.actual)); } } if (res instanceof mlsub.typing.Interface) User.error(this, "This abstract interface cannot be used as a type"); throw Internal.error("Invalid type ident: " + res.getClass() + " = " + res); } public mlsub.typing.TypeConstructor resolveToTC(TypeMap scope) { let res = this.resolveToTypeSymbol(scope); if (res instanceof mlsub.typing.TypeConstructor) return res; throw User.error(this, this + " is not a class"); } public mlsub.typing.TypeSymbol resolvePreferablyToItf(TypeMap scope) { let res = this.resolveToTypeSymbol(scope); if (res instanceof mlsub.typing.Interface) return res; if (res instanceof TypeConstructor) { let def = getTypeDefinition(res); if (def != null) { let itf = def.getAssociatedInterface(); if (itf != null) return itf; } } return res; } public mlsub.typing.Interface resolveToItf(TypeMap scope) { let res = this.resolvePreferablyToItf(scope); if (res instanceof mlsub.typing.Interface) return res; throw User.error(this, res + " should be an interface"); } toString() = this.nullnessString() + name.toString(); public LocatedString getName() = name; public boolean hasName(LocatedString name) { return this.name.equals(name); } location() = notNull(name.location()); } public Monotype createTypeIdent(LocatedString name) { return new TypeIdent(name: name); } /* public mlsub.typing.Interface[?] resolveToItf(TypeMap scope, ?List<TypeIdent> idents) { if (idents==null || idents.size()==0) return null; return idents.mapToArray(TypeIdent ti => ti.resolveToItf(scope)); } */ Index: customConstructor.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/customConstructor.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** customConstructor.nice 17 Dec 2004 17:38:01 -0000 1.3 --- customConstructor.nice 18 Dec 2004 19:41:01 -0000 1.4 *************** *** 151,155 **** private Monotype getCCReturnType(LocatedString className, Constraint cst) { ! let classe = new TypeIdent(className); classe.nullness = Monotype.sure; --- 151,155 ---- private Monotype getCCReturnType(LocatedString className, Constraint cst) { ! let classe = new TypeIdent(name: className); classe.nullness = Monotype.sure; Index: methodbody.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/methodbody.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** methodbody.nice 4 Dec 2004 19:38:18 -0000 1.3 --- methodbody.nice 18 Dec 2004 19:41:01 -0000 1.4 *************** *** 501,505 **** List<Pattern> res = new ArrayList(); res.add(createPattern(new LocatedString("this", loc), ! new TypeIdent(container.getName()))); res.addAll(formals); return res.toArray(); --- 501,505 ---- List<Pattern> res = new ArrayList(); res.add(createPattern(new LocatedString("this", loc), ! new TypeIdent(name: container.getName()))); res.addAll(formals); return res.toArray(); --- TypeIdent.java DELETED --- Index: enum.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/enum.nice,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** enum.nice 16 Dec 2004 16:21:07 -0000 1.8 --- enum.nice 18 Dec 2004 19:41:01 -0000 1.9 *************** *** 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); --- 67,71 ---- let classDef = makeClass (name,true,false, null, new ArrayList(), ! createMonotypeConstructor(new TypeIdent(name: new LocatedString("nice.lang.Enum", name.location())), null, name.location()), interfaces, null); let impl = createNiceClass(classDef); *************** *** 173,177 **** List<Expression> argExps) { ! Monotype type = new TypeIdent(enumName); type.nullness = Monotype.absent; List<Arguments.Argument> args = new ArrayList(2 + fields.size()); --- 173,177 ---- List<Expression> argExps) { ! Monotype type = new TypeIdent(name: enumName); type.nullness = Monotype.absent; List<Arguments.Argument> args = new ArrayList(2 + fields.size()); *************** *** 185,188 **** return new EnumSymbol(name, type, definition: def, value: ! createNewExp(new TypeIdent(enumName), new Arguments(args))); } --- 185,188 ---- return new EnumSymbol(name, type, definition: def, value: ! createNewExp(new TypeIdent(name: enumName), new Arguments(args))); } Index: ai.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/ai.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ai.nice 28 Nov 2004 01:00:47 -0000 1.1 --- ai.nice 18 Dec 2004 19:41:01 -0000 1.2 *************** *** 101,105 **** resolve() { ! classTC = new TypeIdent(className).resolveToTC(typeScope); if (TypeConstructors.isInterface(classTC)) --- 101,105 ---- resolve() { ! classTC = new TypeIdent(name: className).resolveToTC(notNull(typeScope)); if (TypeConstructors.isInterface(classTC)) *************** *** 113,119 **** let ident = new TypeIdent ! (new LocatedString(module.getName() + '.' + interfaceName.content, interfaceName.location())); ! interfaceITF = ident.resolveToItf(typeScope); let def = getTypeDefinition(notNull(classTC)); --- 113,119 ---- let ident = new TypeIdent ! (name: new LocatedString(module.getName() + '.' + interfaceName.content, interfaceName.location())); ! interfaceITF = ident.resolveToItf(notNull(typeScope)); let def = getTypeDefinition(notNull(classTC)); Index: loop.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/loop.nice,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** loop.nice 16 Dec 2004 16:21:07 -0000 1.7 --- loop.nice 18 Dec 2004 19:41:01 -0000 1.8 *************** *** 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; --- 135,139 ---- List<Monotype> tparams = new ArrayList(1); tparams.add(vartype); ! itertype = createMonotypeConstructor(new TypeIdent(name: new LocatedString("Iterator", loc)), new TypeParameters(tparams), loc); notNull(itertype).nullness = Monotype.sure; Index: typedef.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typedef.nice,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** typedef.nice 17 Dec 2004 20:45:08 -0000 1.5 --- typedef.nice 18 Dec 2004 19:41:01 -0000 1.6 *************** *** 303,307 **** let name = notNull(parent.tc); ! let s = name.resolvePreferablyToItf(typeScope); if (s instanceof mlsub.typing.Interface) --- 303,307 ---- let name = notNull(parent.tc); ! let s = name.resolvePreferablyToItf(notNull(typeScope)); if (s instanceof mlsub.typing.Interface) *************** *** 484,488 **** { this.useInheritanceParams(this.resolveParams(s, this.getLocalScope())); ! let superClass = notNull(s.tc).resolveToTC(typeScope); let name = notNull(this.name); --- 484,488 ---- { this.useInheritanceParams(this.resolveParams(s, this.getLocalScope())); ! let superClass = notNull(s.tc).resolveToTC(notNull(typeScope)); let name = notNull(this.name); Index: pattern.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/pattern.nice,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** pattern.nice 8 Dec 2004 20:00:58 -0000 1.11 --- pattern.nice 18 Dec 2004 19:41:01 -0000 1.12 *************** *** 64,68 **** if (value instanceof StringConstantExp) ! return new StringPattern(null, new TypeIdent(new LocatedString("java.lang.String", value.location())), additional, value.location(), atValue: value); --- 64,68 ---- if (value instanceof StringConstantExp) ! return new StringPattern(null, new TypeIdent(name: new LocatedString("java.lang.String", value.location())), additional, value.location(), atValue: value); Index: Monotype.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Monotype.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** Monotype.java 17 Dec 2004 20:45:10 -0000 1.38 --- Monotype.java 18 Dec 2004 19:40:59 -0000 1.39 *************** *** 45,49 **** static Monotype fresh(LocatedString associatedVariable) { ! return new TypeIdent(associatedVariable); } --- 45,49 ---- static Monotype fresh(LocatedString associatedVariable) { ! return dispatch.createTypeIdent(associatedVariable); } *************** *** 200,203 **** --- 200,209 ---- } + //temporarily method to call on TypeIdent's + public mlsub.typing.TypeSymbol resolveToTypeSymbol(TypeMap scope) + { + return null; + } + /**************************************************************** * Printing Index: dispatch.java.bootstrap =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/dispatch.java.bootstrap,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** dispatch.java.bootstrap 16 Dec 2004 20:18:47 -0000 1.34 --- dispatch.java.bootstrap 18 Dec 2004 19:41:01 -0000 1.35 *************** *** 13,16 **** --- 13,19 ---- public class dispatch { + public static Monotype createTypeIdent(LocatedString name) + { return null;} + public static Definition createMethodWithDefault(LocatedString name, Constraint constraint, Monotype returnType, FormalParameters parameters, Statement body, Contract contract, boolean isOverride) { return null; } Index: monotype.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/monotype.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** monotype.nice 18 Dec 2004 18:18:13 -0000 1.3 --- monotype.nice 18 Dec 2004 19:41:01 -0000 1.4 *************** *** 34,38 **** 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"); --- 34,38 ---- if (lowlevelTC == null) { ! let newTC = notNull(this.tc).resolveToTC(notNull(typeMap)); if (! (newTC instanceof TypeConstructor)) throw User.error(notNull(this.tc), notNull(this.tc)+" should be a type constructor"); |