[Nice-commit] Nice/src/bossa/syntax modifiers.nice,NONE,1.1 typedef.nice,NONE,1.1 AST.java,1.60,1.61
Brought to you by:
bonniot
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7541/F:/nice/src/bossa/syntax Modified Files: AST.java AbstractInterfaceImplementation.java Definition.java MethodImplementation.java MonotypeConstructor.java NiceClass.java Pattern.java PrimitiveType.java TypeConstructorLeqCst.java TypeConstructors.java TypeIdent.java dispatch.java.bootstrap enum.nice importedconstructor.nice javaclass.nice new.nice niceclass.nice nicefield.nice nicefieldaccess.nice super.nice tools.nice Added Files: modifiers.nice typedef.nice Removed Files: ClassDefinition.java Log Message: Converted ClassDefinition. (patch by Luc Perrin) Index: Pattern.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Pattern.java,v retrieving revision 1.93 retrieving revision 1.94 diff -C2 -d -r1.93 -r1.94 *** Pattern.java 11 Oct 2004 15:21:34 -0000 1.93 --- Pattern.java 25 Nov 2004 19:28:18 -0000 1.94 *************** *** 124,128 **** // Class constraints ! ClassDefinition def = ClassDefinition.get(tc); if (def == null) return; --- 124,128 ---- // Class constraints ! TypeDefinition def = dispatch.getTypeDefinition(tc); if (def == null) return; Index: NiceClass.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/NiceClass.java,v retrieving revision 1.94 retrieving revision 1.95 diff -C2 -d -r1.94 -r1.95 *** NiceClass.java 21 Nov 2004 23:24:36 -0000 1.94 --- NiceClass.java 25 Nov 2004 19:28:18 -0000 1.95 *************** *** 35,39 **** abstract public LocatedString getName(); ! abstract ClassDefinition getDefinition(); abstract public boolean isInterface(); --- 35,39 ---- abstract public LocatedString getName(); ! abstract TypeDefinition getDefinition(); abstract public boolean isInterface(); *************** *** 41,47 **** static NiceClass get(TypeConstructor tc) { ! ClassDefinition res = ClassDefinition.get(tc); ! if (res != null && res.implementation instanceof NiceClass) ! return ((NiceClass) res.implementation); else return null; --- 41,47 ---- static NiceClass get(TypeConstructor tc) { ! TypeDefinition res = bossa.syntax.dispatch.getTypeDefinition(tc); ! if (res != null && res.getImplementation() instanceof NiceClass) ! return ((NiceClass) res.getImplementation()); else return null; Index: niceclass.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/niceclass.nice,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** niceclass.nice 21 Nov 2004 23:24:37 -0000 1.5 --- niceclass.nice 25 Nov 2004 19:28:18 -0000 1.6 *************** *** 21,25 **** public class CNiceClass extends NiceClass { ! ClassDefinition definition; private List<NewField> fields = new ArrayList(); --- 21,25 ---- public class CNiceClass extends NiceClass { ! TypeDefinition definition; private List<NewField> fields = new ArrayList(); *************** *** 102,106 **** } ! isInterface() = definition instanceof ClassDefinition.Interface; ?CNiceClass getParent() --- 102,106 ---- } ! isInterface() = definition instanceof InterfaceDefinition; ?CNiceClass getParent() *************** *** 229,233 **** VarScope scope = notNull(definition.scope); mlsub.typing.Monotype thisType = ! Monotype.sure(new mlsub.typing.MonotypeConstructor(definition.tc, definition.getTypeParameters())); thisSymbol = new ThisSymbol(FormalParameters.thisName, thisType, declaringClass: this); --- 229,233 ---- VarScope scope = notNull(definition.scope); mlsub.typing.Monotype thisType = ! Monotype.sure(new mlsub.typing.MonotypeConstructor(definition.getTC(), definition.getTypeParameters())); thisSymbol = new ThisSymbol(FormalParameters.thisName, thisType, declaringClass: this); *************** *** 553,559 **** (this, true, definition.location(), values, cst, Monotype.resolve(definition.getLocalScope(), values.types()), ! Monotype.sure(new mlsub.typing.MonotypeConstructor(definition.tc, definition.getTypeParameters())), fields: fields, parent: parent); ! TypeConstructors.addConstructor(definition.tc, notNull(constructorMethod)[i]); } } --- 553,559 ---- (this, true, definition.location(), values, cst, Monotype.resolve(definition.getLocalScope(), values.types()), ! Monotype.sure(new mlsub.typing.MonotypeConstructor(definition.getTC(), definition.getTypeParameters())), fields: fields, parent: parent); ! TypeConstructors.addConstructor(definition.getTC(), notNull(constructorMethod)[i]); } } *************** *** 598,602 **** res.add(typeExpression(superClass)); ! for (intf : definition.interfaces) { let ?mlsub.typing.TypeConstructor assocTC = intf.associatedTC(); --- 598,602 ---- res.add(typeExpression(superClass)); ! for (intf : definition.getInterfaces()) { let ?mlsub.typing.TypeConstructor assocTC = intf.associatedTC(); *************** *** 605,611 **** } ! if (definition.javaInterfaces != null) ! for (itf : notNull(definition.javaInterfaces)) ! res.add(typeExpression(notNull(itf))); if (res.isEmpty()) --- 605,612 ---- } ! let ji = definition.getJavaInterfaces(); ! if (ji != null) ! for (itf : ji) ! res.add(typeExpression(itf)); if (res.isEmpty()) *************** *** 686,690 **** } ! NiceClass createNiceClass(ClassDefinition cdef) = new CNiceClass(definition: cdef); private TypeSymbol asTypeSymbol(mlsub.typing.Monotype type) --- 687,691 ---- } ! NiceClass createNiceClass(TypeDefinition cdef) = new CNiceClass(definition: cdef); private TypeSymbol asTypeSymbol(mlsub.typing.Monotype type) *************** *** 699,706 **** private gnu.expr.Expression typeExpression(TypeConstructor tc) { ! let c = ClassDefinition.get(tc); ! if (c != null && c.implementation instanceof NiceClass) { ! CNiceClass nc = cast(c.implementation); return nc.classe; } --- 700,707 ---- private gnu.expr.Expression typeExpression(TypeConstructor tc) { ! let c = getTypeDefinition(tc); ! if (c != null && c.getImplementation() instanceof NiceClass) { ! CNiceClass nc = cast(c.getImplementation()); return nc.classe; } --- NEW FILE: modifiers.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; enum Modifier( short bit ) { PUBLIC(0x0001), PRIVATE(0x0002), PROTECTED(0x0004), STATIC(0x0008), FINAL(0x0010), SUPER(0x0020), SYNCHRONIZED(0x0020), VOLATILE(0x0040), TRANSIENT(0x0080), NATIVE(0x0100), INTERFACE(0x0200), ABSTRACT(0x0400) } /** * A set of modifiers * @author Luc Perrin */ class Modifiers { short bits = 0; short getBits() = bits; private void setBit( short bit ) { bits |= bit; } private void removeBit( short bit ) { bits &= short(~bit); } private boolean getBit( short bit ) = ( bits & bit ) != 0; void setModifier( Modifier mod ) = this.setBit( mod.bit ); void removeModifier( Modifier mod ) = this.removeBit( mod.bit ); boolean getModifier( Modifier mod ) = this.getBit( mod.bit ); void makePublic( ) { this.setModifier( PUBLIC ); } boolean isPublic() = this.getModifier( PUBLIC ); void makeProtected( ) { this.setModifier( PROTECTED ); } boolean isProtected() = this.getModifier( PROTECTED ); void makePrivate( ) { this.setModifier( PRIVATE ); } boolean isPrivate() = this.getModifier( PRIVATE ); void makeStatic( ) { this.setModifier( STATIC ); } boolean isStatic() = this.getModifier( STATIC ); void makeFinal( ) { this.setModifier( FINAL ); } boolean isFinal() = this.getModifier( FINAL ); void makeSynchronized( ) { this.setModifier( SYNCHRONIZED ); } boolean isSynchronized() = this.getModifier( SYNCHRONIZED ); void makeVolatile( ) { this.setModifier( VOLATILE ); } boolean isVolatile() = this.getModifier( VOLATILE ); void makeTransient( ) { this.setModifier( TRANSIENT ); } boolean isTransient() = this.getModifier( TRANSIENT ); void makeNative( ) { this.setModifier( NATIVE ); } boolean isNative() = this.getModifier( NATIVE ); void makeInterface( ) { this.setModifier( INTERFACE ); } boolean isInterface() = this.getModifier( INTERFACE ); void makeAbstract( ) { this.setModifier( ABSTRACT ); } boolean isAbstract() = this.getModifier( ABSTRACT ); toString() { StringBuffer buf = new StringBuffer(); // Cannot be printed to nicei files yet // if( this.getModifier( PUBLIC ) ) buf.append(" public"); // if( this.getModifier( PRIVATE ) ) buf.append(" private"); if( this.getModifier( PROTECTED ) ) buf.append(" protected"); if( this.getModifier( STATIC ) ) buf.append(" static"); if( this.getModifier( FINAL ) ) buf.append(" final"); if( this.getModifier( SYNCHRONIZED ) ) buf.append(" synchronized"); if( this.getModifier( VOLATILE ) ) buf.append(" volatile"); if( this.getModifier( TRANSIENT ) ) buf.append(" transient"); if( this.getModifier( NATIVE ) ) buf.append(" native"); if( this.getModifier( ABSTRACT ) ) buf.append(" abstract"); return buf.toString(); } } Index: enum.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/enum.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** enum.nice 21 Nov 2004 22:36:56 -0000 1.2 --- enum.nice 25 Nov 2004 19:28:18 -0000 1.3 *************** *** 20,24 **** public class EnumDefinition extends Definition { ! ClassDefinition classDef; List<EnumSymbol> symbols; String representation; --- 20,24 ---- public class EnumDefinition extends Definition { ! TypeDefinition classDef; List<EnumSymbol> symbols; String representation; *************** *** 65,72 **** public EnumDefinition createEnumDefinition(LocatedString name, List<LocatedString> elements, List<MonoSymbol> fields, List<List<Expression>> argsList, ! List<Definition> globalDefs, ?List<TypeIdent> interfaces) { let shortName = name.toString(); ! let classDef = ClassDefinition.makeClass (name,true,false, null, new ArrayList(), new MonotypeConstructor(new TypeIdent(new LocatedString("nice.lang.Enum", --- 65,72 ---- public EnumDefinition createEnumDefinition(LocatedString name, List<LocatedString> elements, List<MonoSymbol> fields, List<List<Expression>> argsList, ! List<Definition> globalDefs, ?List<MonotypeConstructor> interfaces) { let shortName = name.toString(); ! let classDef = makeClass (name,true,false, null, new ArrayList(), new MonotypeConstructor(new TypeIdent(new LocatedString("nice.lang.Enum", Index: MonotypeConstructor.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MonotypeConstructor.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** MonotypeConstructor.java 12 Aug 2004 23:21:41 -0000 1.34 --- MonotypeConstructor.java 25 Nov 2004 19:28:18 -0000 1.35 *************** *** 80,84 **** catch(mlsub.typing.BadSizeEx e){ // See if this is a class with default type parameters ! mlsub.typing.Monotype res = ClassDefinition.toType(lowlevelTC, resolvedParams); if (res != null) return res; --- 80,84 ---- catch(mlsub.typing.BadSizeEx e){ // See if this is a class with default type parameters ! mlsub.typing.Monotype res = dispatch.getTypeWithTC(lowlevelTC, resolvedParams); if (res != null) return res; Index: nicefield.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/nicefield.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** nicefield.nice 5 Nov 2004 22:46:55 -0000 1.2 --- nicefield.nice 25 Nov 2004 19:28:18 -0000 1.3 *************** *** 31,35 **** } ! ClassDefinition getClassDefinition() = declaringClass.definition; LocatedString getName() = sym.getName(); --- 31,35 ---- } ! TypeDefinition getTypeDefinition() = declaringClass.definition; LocatedString getName() = sym.getName(); Index: AST.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/AST.java,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** AST.java 21 Nov 2004 18:33:17 -0000 1.60 --- AST.java 25 Nov 2004 19:28:17 -0000 1.61 *************** *** 54,58 **** { Definition node = (Definition)i.next(); ! if (node instanceof ClassDefinition) classes.add(node); else if (node instanceof CustomConstructor) --- 54,58 ---- { Definition node = (Definition)i.next(); ! if (node instanceof TypeDefinition) classes.add(node); else if (node instanceof CustomConstructor) *************** *** 73,78 **** } ! this.classes = (ClassDefinition[]) ! classes.toArray(new ClassDefinition[classes.size()]); this.methods = (MethodDeclaration[]) --- 73,78 ---- } ! this.classes = (TypeDefinition[]) ! classes.toArray(new TypeDefinition[classes.size()]); this.methods = (MethodDeclaration[]) *************** *** 231,235 **** private Module module; ! private ClassDefinition[] classes; private MethodDeclaration[] methods; private MethodBodyDefinition[] methodImplementations; --- 231,235 ---- private Module module; ! private TypeDefinition[] classes; private MethodDeclaration[] methods; private MethodBodyDefinition[] methodImplementations; Index: Definition.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Definition.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Definition.java 21 Nov 2004 18:33:17 -0000 1.24 --- Definition.java 25 Nov 2004 19:28:18 -0000 1.25 *************** *** 88,92 **** } ! ClassDefinition getEnumClass() { return null; --- 88,92 ---- } ! TypeDefinition getEnumClass() { return null; Index: TypeConstructorLeqCst.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/TypeConstructorLeqCst.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** TypeConstructorLeqCst.java 25 Jun 2002 07:07:41 -0000 1.12 --- TypeConstructorLeqCst.java 25 Nov 2004 19:28:18 -0000 1.13 *************** *** 48,52 **** TypeConstructor tc2 = (TypeConstructor) s; ! ClassDefinition c2 = ClassDefinition.get(tc2); if(c2!=null) { --- 48,52 ---- TypeConstructor tc2 = (TypeConstructor) s; ! TypeDefinition c2 = dispatch.getTypeDefinition(tc2); if(c2!=null) { --- NEW FILE: typedef.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; // Abstract // These are used by nice code only, therefore do not need to be in the // java file. int getBytecodeFlags(TypeDefinition c); ?mlsub.typing.TypeConstructor getSuperClass(TypeDefinition c); boolean implementsJavaInterface(TypeDefinition c, String name); ?mlsub.typing.Monotype lowlevelMonotype(TypeDefinition c); List<mlsub.typing.Interface> getInterfaces(TypeDefinition c); TypeConstructor[?] getJavaInterfaces(TypeDefinition c); ?ClassDefinition getSuperClassDefinition(TypeDefinition c); int getVariance(TypeDefinition t); InterfaceDefinition[] getImplementedInterfaces(TypeDefinition c); /** Abstract syntax for a type definition. */ public abstract class CTypeDefinition extends TypeDefinition { Modifiers modifiers = new Modifiers(); mlsub.typing.TypeConstructor tc = cast(null); ?ClassImplementation implementation = null; ?gnu.bytecode.Type javaType = null; ?List<int> typeParametersVariances = null; // Interfaces ?List<MonotypeConstructor> implementations = new LinkedList(); TypeConstructor[?] javaInterfaces = null; List<mlsub.typing.Interface> interfaces = new ArrayList(5); ?List<MonotypeConstructor> extensions = null; // Abstract Interfaces ?List<MonotypeConstructor> abstractions = new LinkedList(); mlsub.typing.Interface[?] abs = null; // Parameters ?mlsub.typing.Monotype[?] parentParams = null; int[?] parentTypeParameterMap = null; { modifiers.makePublic(); int arity = getVariance(this); let tpv = notNull( typeParametersVariances ); if (arity == -1 || arity <= tpv.size()) this.variance = makeVariance(tpv); else this.variance = Variance.make(new int[arity]); this.createTC(); typeParametersVariances = null; if( modifiers.isFinal() ) tc.setMinimal(); } isConcrete() = !modifiers.isAbstract(); implementsJavaInterface(name) { let ji = javaInterfaces; if (ji != null) for (int i = 0; i < ji.length; i++) if (ji[i].toString().equals(name)) return true; return false; } getTypeSymbol() = tc; getAssociatedInterface() = null; getSuperClass() = null; getSuperClassDefinition() = null; getTC() = tc; getImplementedInterfaces() { if (interfaces.size() == 0) return new InterfaceDefinition[0]; List<InterfaceDefinition> res = new LinkedList(); for (mlsub.typing.Interface ai : interfaces) { let itf = getTypeDefinition(ai.associatedTC()); if (itf != null && itf instanceof InterfaceDefinition ) res.add(itf); } return res.toArray(); } void createTC() { String name = notNull(this.name).toString(); if (name.equals("nice.lang.Array")) tc = new ArrayTypeConstructor(name,variance,this.isConcrete(),true); else if (name.equals("nice.lang.Sure")) tc = new SureTypeConstructor(name,mlsub.typing.NullnessKind.instance, this.isConcrete(), true ); else if (name.equals("nice.lang.Maybe")) tc = new MaybeTypeConstructor(name,mlsub.typing.NullnessKind.instance, this.isConcrete(), true ); else if (name.equals("nice.lang.Null")) { tc = new mlsub.typing.TypeConstructor ("null", mlsub.typing.NullnessKind.instance, this.isConcrete(), true); PrimitiveType.registerPrimType(name, tc); } else { tc = new mlsub.typing.TypeConstructor(name, variance, this.isConcrete(), true); if (name.equals("nice.lang.Throwable")) PrimitiveType.throwableTC = tc; else if (name.equals("nice.lang.Collection")) PrimitiveType.collectionTC = tc; else if (name.equals("nice.lang.Class")) PrimitiveType.classTC = tc; } tcToTypeDef.put(tc, this); Typing.introduce(tc); this.addTypeSymbol(tc); } getLocalScope() { TypeScope localScope = notNull(typeScope); if (classConstraint != null) try { localScope = new TypeScope(localScope); mlsub.typing.TypeSymbol[] binders = notNull(this.getBinders()); for (int i = 0; i < binders.length; i++) localScope.addSymbol(binders[i]); } catch(TypeScope.DuplicateName e) { User.error(this, e); } return localScope; } /**************************************************************** * Selectors ****************************************************************/ lowlevelMonotype() { try { return new mlsub.typing.MonotypeConstructor(tc, this.getTypeParameters()); } catch(mlsub.typing.BadSizeEx e) { return getTypeWithTC(tc, this.getTypeParameters()); } } /** Return the type representing a constrained instance of this class, or null if this class has no constraint on its type parameters. */ getConstrainedType() { ?mlsub.typing.Constraint cst = this.getResolvedConstraint(); if (cst == null) return null; mlsub.typing.Polytype res = new mlsub.typing.Polytype (cst, this.lowlevelMonotype()); return res.cloneType(); } /**************************************************************** * Resolution ****************************************************************/ /** Marker to avoid cycles and multiple resolutions. */ boolean isResolved = false; boolean isResolving = false; resolve() { if (isResolved) return; if (isResolving) { // We found a cycle. String message; if (TypeConstructors.isInterface(tc)) message = "Interface " + this.getName() + " extends itself"; else message = "Class " + this.getName() + " extends itself"; throw User.error(this, message); } isResolving = true; try { this.resolveClass(); super; // This needs to be after super.resolve(), so that the constraint is resolved notNull(implementation).resolveClass(); } finally { isResolved = true; isResolving = false; } } void resolveClass() { this.resolveInterfaces(implementations); abs = AbstractInterface.resolve(notNull(typeScope), abstractions); implementations = null; abstractions = null; // Resolve the super-interfaces first. for (mlsub.typing.Interface itf : interfaces) { let d = getTypeDefinition(itf.associatedTC()); if (d != null) d.resolve(); } this.createContext(); } void createContext() { try { for (mlsub.typing.Interface itf : interfaces) { try { Typing.assertImp(tc, itf, true); } catch(KindingEx e) { User.error(name, "Class " + name + " cannot implement " + e.t2 + ": they do not have the same number or kind of type parameters"); } } if (abs != null) { Typing.assertImp(tc, abs, true); Typing.assertAbs(tc, abs); } let ji = javaInterfaces; if (ji != null) for (int i = 0; i < ji.length; i++) if (tc.arity() == 0 || ! JavaClasses.excludedInterface(ji[i])) try { Typing.initialLeq(tc, ji[i]); } catch(KindingEx e) { User.error(name, "Class " + name + " cannot implement " + e.t2 + ": they do not have the same number or kind of type parameters"); } } catch(TypingEx e) { User.error(name, "Error in " + name + " : " + e.getMessage()); } } void resolveInterfaces(?List<MonotypeConstructor> names) { if (names == null) return; ?ArrayList<mlsub.typing.TypeConstructor> javaInterfaces = null; for (MonotypeConstructor parent : names) { this.useInheritanceParams(this.resolveParams(parent, notNull(this.getLocalScope()))); let name = notNull(parent.tc); let s = name.resolvePreferablyToItf(typeScope); if (s instanceof mlsub.typing.Interface) { interfaces.add(s); } else if (s instanceof mlsub.typing.TypeConstructor) { let tc = s; if (!TypeConstructors.isInterface(tc)) throw User.error(name, tc + " is not an interface"); if (javaInterfaces == null) javaInterfaces = new ArrayList(5); notNull(javaInterfaces).add(s); } else Internal.error("Symbol "+s+" is not Interface or TypeConstructor"); } if (javaInterfaces != null) this.javaInterfaces = javaInterfaces.toArray(); } mlsub.typing.Monotype[?] resolveParams(MonotypeConstructor parent, TypeScope typeScope) { if (parent.parameters == null) return null; return bossa.syntax.Monotype.resolve(typeScope, cast(notNull(parent.parameters).content)); } resolveBody() { notNull(implementation).resolveBody(); } typecheckClass() { notNull(implementation).typecheck(); } typecheck() { // Typechecking is done earlier, in typecheckClass. } precompile() { let impl = implementation; if (impl != null && impl instanceof NiceClass) impl.precompile(); } compile() { notNull(implementation).compile(); } /** Called instead of compile if the package is up-to-date. */ recompile() { notNull(implementation).recompile(); } MethodContainer.Constraint specialize(?MethodContainer.Constraint our, mlsub.typing.Monotype[?] params) { if (params == null) return notNull(our); this.parentParams = cast(params); let parentMap = new int[params.length]; this.parentTypeParameterMap = parentMap; let parentParams = notNull( this.parentParams ); List<mlsub.typing.TypeSymbol> binders = new ArrayList(); List<AtomicConstraint> atoms = new ArrayList(); let typeParameters = new mlsub.typing.Monotype[params.length]; if (our != null) { binders.addAll(Arrays.asList(our.getBinderArray())); atoms.addAll(our.getAtoms()); } for (int i = 0; i < params.length; i++) { if (params[i] instanceof MonotypeVar) { typeParameters[i] = params[i]; parentMap[i] = find(params[i], notNull(our).typeParameters); parentParams[i] = null; continue; } MonotypeVar mvar = new MonotypeVar("D" + i); binders.add(mvar); typeParameters[i] = mvar; bossa.syntax.Monotype v = bossa.syntax.Monotype.create(mvar); atoms.add(new MonotypeLeqCst(bossa.syntax.Monotype.create(params[i]), v)); atoms.add(new MonotypeLeqCst(v, bossa.syntax.Monotype.create(params[i]))); } return new MethodContainer.Constraint( binders.toArray(), atoms, typeParameters, this.location()); } void useInheritanceParams(mlsub.typing.Monotype[?] params) { if (parentParams == null && params != null) classConstraint = this.specialize(this.classConstraint, params); } getInterfaces() = interfaces.toArray(); addInterfaceImplementation(itf) { if (itf != null) interfaces.add(itf); } getJavaInterfaces() = javaInterfaces; setJavaType(javaType) { if (javaType == null) return; this.javaType = javaType; nice.tools.code.Types.set(tc, javaType); } getJavaType() = notNull(javaType); setImplementation(implementation) { this.implementation = implementation; } getImplementation() = notNull(implementation); getBytecodeFlags() = modifiers.getBits(); } /** * Definition for a class */ class ClassDefinition extends CTypeDefinition { // Super class ?MonotypeConstructor superClassIdent = null; ?mlsub.typing.TypeConstructor superClass = null; getSuperClass() = superClass; getSuperClassDefinition() { if (superClass == null) return null; let s = getTypeDefinition(notNull(superClass)); if (s instanceof ClassDefinition) return s; else return null; } resolveClass() { let s = this.superClassIdent; if (s != null) { this.useInheritanceParams(this.resolveParams(s, this.getLocalScope())); let superClass = notNull(s.tc).resolveToTC(typeScope); let name = notNull(this.name); this.superClass = superClass; if (superClass.isMinimal()) User.error(superClassIdent, superClass + " is a final class. It cannot be extended"); if (TypeConstructors.isInterface(superClass)) User.error(superClassIdent, superClass + " is an interface, so " + name + " may only implement it"); if (! nice.tools.code.Types.legalAccess(superClass, module.getName())) User.error(superClassIdent, name + " cannot extend " + superClass + ". It is not available to this package."); superClassIdent = null; } ?ClassDefinition d = this.getSuperClassDefinition(); if (d != null) { d.resolve(); if (d.getImplementation() instanceof PrimitiveType && !(this.getImplementation() instanceof PrimitiveType)) User.error(this, "A class can't extends a primitive"); } super; } createContext() { try { if (superClass != null) try { Typing.initialLeq(tc, superClass); } catch(KindingEx e) { User.error(name, "Class " + name + " cannot extend " + e.t2 + ": they do not have the same number or kind of type parameters"); } } catch(TypingEx e) { User.error(name, "Error in class " + name + " : " + e.getMessage()); } super; } } /** * Definition for an interface */ class InterfaceDefinition extends CTypeDefinition { ?mlsub.typing.Interface associatedInterface = null; { modifiers.makeInterface(); associatedInterface = new mlsub.typing.Interface(variance, tc); } isConcrete() = false; implementsJavaInterface(String name) = false; getTypeSymbol() = notNull( associatedInterface ); resolveClass() { this.resolveInterfaces(extensions); extensions = null; this.createAssociatedInterface(); super; } createContext() { try { Typing.assertImp(tc, associatedInterface, true); } catch(TypingEx e) { User.error(name, "Error in interface " + name, e.getMessage()); } super; } getAssociatedInterface() = associatedInterface; void createAssociatedInterface() { // the associated interface extends the associated interfaces // of the classes we extend for (mlsub.typing.Interface ai : interfaces) { try { Typing.assertLeq(associatedInterface, ai); } catch(KindingEx e) { User.error(this, "Cannot extend interface " +ai+ " which has a different variance"); } } } } /**************************************************************** * Printing ****************************************************************/ toString(ClassDefinition c) = "class "+c.name; toString(InterfaceDefinition i) = "interface "+i.name; printInterface(ClassDefinition c, java.io.PrintWriter s) { super; s.print(c.modifiers.toString() ); s.print(" class " ); s.print(c.getSimpleName()); s.print(c.printTypeParameters()); if (c.superClass != null) s.print(" extends " + c.superClass); s.print(printInterfaces(" implements ", c.interfaces, c.javaInterfaces)); if (c.abs != null) s.print(Util.map(" finally implements ",", ","",notNull(c.abs))); notNull(c.implementation).printInterface(s); } printInterface(InterfaceDefinition i, java.io.PrintWriter s) { super; s.print(i.modifiers.toString()); s.print(" interface "); s.print(i.getSimpleName()); s.print(i.printTypeParameters()); s.print(printInterfaces(" extends ", i.interfaces, i.javaInterfaces)); notNull(i.implementation).printInterface(s); } String printInterfaces(String keyword, ?List<mlsub.typing.Interface> interfaces, ?List<mlsub.typing.TypeConstructor> javaInterfaces ) { ?String sNice = null; ?String sJava = null; if (interfaces != null && interfaces.size() != 0) sNice = Util.map("", ", ", "", interfaces ); if (javaInterfaces != null && javaInterfaces.size() != 0) sJava = Util.map("", ", ", "", javaInterfaces ); if (sNice != null) return keyword + sNice + ( sJava != null ? ( ", " + sJava ) : "" ); else if (sJava != null) return keyword + sJava; else return ""; } // TypeConstructors with specialized printing class ArrayTypeConstructor extends mlsub.typing.TypeConstructor { toString(parameters) { if (parameters == null) return ""; return parameters[0].toString(false, "[]"); } toString(parameters, isNull, suffix) { if (parameters == null) return ""; return parameters[0].toString(false, (suffix || "") + (isNull ? "[?]" : "[]")); } } class SureTypeConstructor extends mlsub.typing.TypeConstructor { toString(parameters, isNull, suffix) { if (parameters == null) return ""; if (parameters[0] instanceof MonotypeVar) return "!" + parameters[0].toString(false, suffix); else // return "!" + parameters[0].toString(); return parameters[0].toString(false, suffix); } } class MaybeTypeConstructor extends mlsub.typing.TypeConstructor { toString(parameters, isNull, suffix) { if (parameters == null) return ""; return parameters[0].toString(true, suffix); } } /**************************************************************** * Map TypeConstructors to TypeDefinitions ****************************************************************/ var Map<mlsub.typing.TypeConstructor,TypeDefinition> tcToTypeDef = new HashMap(); void resetTypeDefinitionMappings() { tcToTypeDef = new HashMap(); } ?TypeDefinition getTypeDefinition(mlsub.typing.TypeConstructor tc) = tcToTypeDef.get(tc); ?TypeDefinition getTypeDefinition(mlsub.typing.Interface itf) = tcToTypeDef.get( itf.associatedTC() ); /** Returns a monotype based on this tc, provided that the class requires no type parameter because it specializes its parent. */ ?mlsub.typing.Monotype getTypeWithTC(TypeConstructor tc) { ?CTypeDefinition def = cast(getTypeDefinition(tc)); if (def == null) return null; let params = def.parentParams; if (params == null) return null; // Look for missing type parameters int missing = 0; for (int i = 0; i < params.length; i++) if (params[i] == null) missing++; if (missing == 0) return new mlsub.typing.MonotypeConstructor(tc, cast(params) ); return null; } /** Returns a monotype based on this tc, provided that the class requires exactly these type parameters because it specializes its parent. */ ?mlsub.typing.Monotype getTypeWithTC( TypeConstructor tc, mlsub.typing.Monotype[] sourceParams ) { ?CTypeDefinition def = cast(getTypeDefinition(tc)); if (def == null) return null; let params = def.parentParams; let paramMap = def.parentTypeParameterMap; if (params == null || paramMap == null) return null; ?mlsub.typing.Monotype[] fullParams = new mlsub.typing.Monotype[params.length]; int used = 0; for (int i = 0; i < fullParams.length; i++) if (params[i] == null) { fullParams[i] = sourceParams[paramMap[i]]; used++; } else fullParams[i] = params[i]; if (used < sourceParams.length) return null; return new mlsub.typing.MonotypeConstructor(tc, cast(fullParams)); } <T> int find(T o, T[?] array) { if (o == null || array == null) return -1; for (int i = 0; ; i++) if (array[i] == o) return i; } // Variance lookup getVariance(CTypeDefinition t) { int arity = getVariance(t.implementations); if (arity != -1) return arity; arity = getVariance(t.abstractions); return arity; } getVariance(ClassDefinition c) { int arity = getVariance(c.superClassIdent); return arity >= 0 ? arity : super; } getVariance(InterfaceDefinition i) { int arity = getVariance(i.extensions); return arity >= 0 ? arity : super; } int getVariance(?List<MonotypeConstructor> parents) { if (parents == null) return -1; int res; for (MonotypeConstructor m : parents) { res = getVariance(m); if (res != -1) return res; } return -1; } int getVariance(?MonotypeConstructor parent) { if (parent == null) return -1; if (notNull(parent.parameters).content == null) return -1; // Assume non-variance return notNull(notNull(parent.parameters).content).length; } // Constructors ClassDefinition makeClass(LocatedString name, boolean isFinal, boolean isAbstract, ?MethodContainer.Constraint typeParameters, List<int> typeParametersVariances, MonotypeConstructor superClassIdent, ?List<MonotypeConstructor> implementations, ?List<MonotypeConstructor> abstractions ) { Modifiers mod = new Modifiers(); if (isFinal) mod.makeFinal(); if (isAbstract) mod.makeAbstract(); return new ClassDefinition( name, Node.upper, typeParameters, modifiers : mod, typeParametersVariances : typeParametersVariances, superClassIdent : superClassIdent, implementations : implementations, abstractions : abstractions ); } InterfaceDefinition makeInterface(LocatedString name, ?MethodContainer.Constraint typeParameters, List<int> typeParametersVariances, ?List<MonotypeConstructor> extensions, ?List<MonotypeConstructor> implementations, ?List<MonotypeConstructor> abstractions ) { return new InterfaceDefinition( name, Node.upper, typeParameters, typeParametersVariances : typeParametersVariances, extensions : extensions, implementations : implementations, abstractions : abstractions ); } Index: super.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/super.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** super.nice 13 Oct 2004 23:22:22 -0000 1.3 --- super.nice 25 Nov 2004 19:28:19 -0000 1.4 *************** *** 170,174 **** // the base method), a call to super is emited. { ! let NiceClass nc = cast(notNull(ClassDefinition.get(notNull(currentMethod).firstArgument())).implementation); code = nc.callSuperMethod(notNull(superMethod)); } --- 170,174 ---- // the base method), a call to super is emited. { ! let NiceClass nc = cast(notNull(getTypeDefinition(notNull(currentMethod).firstArgument())).getImplementation()); code = nc.callSuperMethod(notNull(superMethod)); } Index: nicefieldaccess.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/nicefieldaccess.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** nicefieldaccess.nice 5 Nov 2004 14:57:57 -0000 1.1 --- nicefieldaccess.nice 25 Nov 2004 19:28:18 -0000 1.2 *************** *** 37,41 **** { return "" + field.sym.type + " " + ! field.getClassDefinition().name + "." + field.getName(); } } --- 37,41 ---- { return "" + field.sym.type + " " + ! field.getTypeDefinition().name + "." + field.getName(); } } *************** *** 43,47 **** NiceFieldAccess createNiceFieldAccess(NiceField field) { ! let classDef = field.getClassDefinition(); let argType = Monotype.sure(classDef.lowlevelMonotype()); --- 43,47 ---- NiceFieldAccess createNiceFieldAccess(NiceField field) { ! let classDef = field.getTypeDefinition(); let argType = Monotype.sure(classDef.lowlevelMonotype()); Index: AbstractInterfaceImplementation.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/AbstractInterfaceImplementation.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** AbstractInterfaceImplementation.java 18 Nov 2004 17:31:15 -0000 1.9 --- AbstractInterfaceImplementation.java 25 Nov 2004 19:28:17 -0000 1.10 *************** *** 65,69 **** interfaceITF = ident.resolveToItf(typeScope); ! ClassDefinition def = ClassDefinition.get(classTC); boolean isNiceClass = def != null && --- 65,69 ---- interfaceITF = ident.resolveToItf(typeScope); ! TypeDefinition def = dispatch.getTypeDefinition(classTC); boolean isNiceClass = def != null && Index: TypeIdent.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/TypeIdent.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** TypeIdent.java 12 Aug 2004 23:21:41 -0000 1.30 --- TypeIdent.java 25 Nov 2004 19:28:18 -0000 1.31 *************** *** 92,96 **** catch(mlsub.typing.BadSizeEx e){ // See if this is a class with default type parameters ! mlsub.typing.Monotype type = ClassDefinition.toType(tc); if (type != null) return type; --- 92,96 ---- catch(mlsub.typing.BadSizeEx e){ // See if this is a class with default type parameters ! mlsub.typing.Monotype type = dispatch.getTypeWithTC(tc); if (type != null) return type; *************** *** 127,131 **** if (res instanceof TypeConstructor) { ! ClassDefinition def = ClassDefinition.get((TypeConstructor) res); if (def != null) { --- 127,131 ---- if (res instanceof TypeConstructor) { ! TypeDefinition def = dispatch.getTypeDefinition((TypeConstructor) res); if (def != null) { *************** *** 148,152 **** if (res instanceof TypeConstructor) { ! ClassDefinition def = ClassDefinition.get((TypeConstructor) res); if (def != null) { --- 148,152 ---- if (res instanceof TypeConstructor) { ! TypeDefinition def = dispatch.getTypeDefinition((TypeConstructor) res); if (def != null) { Index: MethodImplementation.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MethodImplementation.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** MethodImplementation.java 7 Oct 2004 22:03:44 -0000 1.9 --- MethodImplementation.java 25 Nov 2004 19:28:18 -0000 1.10 *************** *** 221,225 **** return; ! ClassDefinition def = ClassDefinition.get(firstArgument()); if (def == null || ! (def.getImplementation() instanceof NiceClass)) return; --- 221,225 ---- return; ! TypeDefinition def = dispatch.getTypeDefinition(firstArgument()); if (def == null || ! (def.getImplementation() instanceof NiceClass)) return; --- ClassDefinition.java DELETED --- Index: new.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/new.nice,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** new.nice 21 Nov 2004 23:24:37 -0000 1.6 --- new.nice 25 Nov 2004 19:28:18 -0000 1.7 *************** *** 56,60 **** // Make sure that the constructors have been created. ! let definition = ClassDefinition.get(tc); if (definition != null) definition.resolve(); --- 56,60 ---- // Make sure that the constructors have been created. ! let definition = getTypeDefinition(tc); if (definition != null) definition.resolve(); Index: PrimitiveType.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/PrimitiveType.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** PrimitiveType.java 18 Nov 2004 17:31:16 -0000 1.14 --- PrimitiveType.java 25 Nov 2004 19:28:18 -0000 1.15 *************** *** 34,40 **** public class PrimitiveType extends ClassImplementation { ! public PrimitiveType(ClassDefinition definition) { ! gnu.bytecode.Type t = registerPrimType(definition.name.toString(), definition.tc); if (t == null) User.error(definition, definition.name + " is not a known primitive type"); --- 34,40 ---- public class PrimitiveType extends ClassImplementation { ! public PrimitiveType(TypeDefinition definition) { ! gnu.bytecode.Type t = registerPrimType(definition.name.toString(), definition.getTC()); if (t == null) User.error(definition, definition.name + " is not a known primitive type"); Index: javaclass.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/javaclass.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** javaclass.nice 18 Nov 2004 17:31:16 -0000 1.1 --- javaclass.nice 25 Nov 2004 19:28:18 -0000 1.2 *************** *** 24,28 **** public class JavaClass extends ClassImplementation { ! ClassDefinition definition; LocatedString javaName; boolean ignoredRetyping = false; --- 24,28 ---- public class JavaClass extends ClassImplementation { ! TypeDefinition definition; LocatedString javaName; boolean ignoredRetyping = false; *************** *** 55,63 **** int nativeArity = classType.getArity(); ! if (nativeArity != -1 && nativeArity != notNull(definition.tc).arity()) User.error(definition, javaName + " has " + nativeArity + " type parameters"); let old = JavaClasses.setTypeConstructorForJavaClass ! (definition.compilation(), definition.tc, classType); if (old != null) --- 55,63 ---- int nativeArity = classType.getArity(); ! if (nativeArity != -1 && nativeArity != definition.getTC().arity()) User.error(definition, javaName + " has " + nativeArity + " type parameters"); let old = JavaClasses.setTypeConstructorForJavaClass ! (definition.compilation(), definition.getTC(), classType); if (old != null) *************** *** 72,76 **** return; ! JavaClasses.fetchMethods(definition.tc, cast(definition.getJavaType())); } --- 72,76 ---- return; ! JavaClasses.fetchMethods(definition.getTC(), cast(definition.getJavaType())); } Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** tools.nice 21 Nov 2004 23:24:37 -0000 1.62 --- tools.nice 25 Nov 2004 19:28:19 -0000 1.63 *************** *** 212,216 **** mlsub.typing.Monotype[?] Types_parameters(mlsub.typing.Polytype) = native mlsub.typing.Monotype[] nice.tools.typing.Types.parameters(mlsub.typing.Polytype); ?mlsub.typing.TypeConstructor head(mlsub.typing.Monotype) = native mlsub.typing.TypeConstructor mlsub.typing.Monotype.head(); - ?ClassDefinition ClassDefinition_get(mlsub.typing.TypeConstructor) = native ClassDefinition ClassDefinition.get(mlsub.typing.TypeConstructor); ?gnu.bytecode.ClassType getSuperclass(gnu.bytecode.ClassType) = native gnu.bytecode.ClassType gnu.bytecode.ClassType.getSuperclass(); int[?] getUsedArguments(Arguments, VarSymbol) = native int[] Arguments.getUsedArguments(VarSymbol); --- 212,215 ---- *************** *** 226,231 **** ?Definition importMethod(NiceClass, gnu.bytecode.Method) = native Definition NiceClass.importMethod(gnu.bytecode.Method); boolean equals(LocatedString, LocatedString) = native boolean LocatedString.equals(LocatedString); - ?mlsub.typing.TypeConstructor getSuperClass(ClassDefinition) = native mlsub.typing.TypeConstructor ClassDefinition.getSuperClass(); - List<mlsub.typing.Interface> interfaces(ClassDefinition) = native ClassDefinition.interfaces; List<FormalParameters.Parameter> getParameters(FormalParameters, TypeScope) = native List FormalParameters.getParameters(TypeScope); mlsub.typing.AtomicConstraint[?] resolvedConstraints(MethodContainer) = native MethodContainer.resolvedConstraints; --- 225,228 ---- *************** *** 237,242 **** ?gnu.expr.Declaration getDeclaration(VarSymbol) = native gnu.expr.Declaration VarSymbol.getDeclaration(); void printInterface(ClassImplementation, java.io.PrintWriter) = native void ClassImplementation.printInterface(java.io.PrintWriter); ?gnu.bytecode.Type TypeImport_lookup(LocatedString) = native gnu.bytecode.Type nice.tools.code.TypeImport.lookup(LocatedString); - ClassDefinition.Class ClassDefinition_makeClass(LocatedString, boolean, boolean, ?MethodContainer.Constraint, List<?boolean>, MonotypeConstructor, ?List<TypeIdent>, ?List<TypeIdent>) = native ClassDefinition.Class ClassDefinition.makeClass(LocatedString, boolean, boolean, MethodContainer.Constraint, List, MonotypeConstructor, List, List); MethodBodyDefinition MethodBodyDefinition(NiceClass, LocatedString, ?Collection<LocatedString>, List<Pattern>, Statement) = native new MethodBodyDefinition(NiceClass, LocatedString, Collection, List, Statement); ?FormalParameters getFormalParameters(VarSymbol) = native FormalParameters VarSymbol.getFormalParameters(); --- 234,246 ---- ?gnu.expr.Declaration getDeclaration(VarSymbol) = native gnu.expr.Declaration VarSymbol.getDeclaration(); void printInterface(ClassImplementation, java.io.PrintWriter) = native void ClassImplementation.printInterface(java.io.PrintWriter); + ?Variance makeVariance(List<int>) = native Variance MethodContainer.makeVariance(List); + mlsub.typing.Interface[] resolve(TypeMap, ?List<MonotypeConstructor>) = native mlsub.typing.Interface[] AbstractInterface.resolve(TypeMap,List); + List<AtomicConstraint> getAtoms(Constraint) = native List Constraint.getAtoms(); + ?mlsub.typing.Interface getAssociatedInterface(TypeDefinition) = native mlsub.typing.Interface TypeDefinition.getAssociatedInterface(); + ?mlsub.typing.Polytype getConstrainedType(TypeDefinition) = native mlsub.typing.Polytype TypeDefinition.getConstrainedType(); + mlsub.typing.Monotype[?] resolve(TypeMap, Monotype[?]) = native mlsub.typing.Monotype[] Monotype.resolve(TypeMap, Monotype[]); + MethodContainer.Constraint MethodContainer$Constraint(TypeSymbol[], List<AtomicConstraint>, ?mlsub.typing.Monotype[], Location) + = native new MethodContainer.Constraint(TypeSymbol[], List, mlsub.typing.Monotype[], Location); ?gnu.bytecode.Type TypeImport_lookup(LocatedString) = native gnu.bytecode.Type nice.tools.code.TypeImport.lookup(LocatedString); MethodBodyDefinition MethodBodyDefinition(NiceClass, LocatedString, ?Collection<LocatedString>, List<Pattern>, Statement) = native new MethodBodyDefinition(NiceClass, LocatedString, Collection, List, Statement); ?FormalParameters getFormalParameters(VarSymbol) = native FormalParameters VarSymbol.getFormalParameters(); Index: importedconstructor.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/importedconstructor.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** importedconstructor.nice 6 Nov 2004 00:28:17 -0000 1.1 --- importedconstructor.nice 25 Nov 2004 19:28:18 -0000 1.2 *************** *** 97,101 **** let classDef = def.getDefinition(); let returnType = Monotype.create(Monotype.sure ! (new mlsub.typing.MonotypeConstructor(classDef.tc, classDef.getTypeParameters()))); let constraint = classDef.classConstraint == null ? --- 97,101 ---- let classDef = def.getDefinition(); let returnType = Monotype.create(Monotype.sure ! (new mlsub.typing.MonotypeConstructor(classDef.getTC(), classDef.getTypeParameters()))); let constraint = classDef.classConstraint == null ? *************** *** 109,113 **** constraint, returnType, method: method); ! TypeConstructors.addConstructor(res.classe.getDefinition().tc, res); return res; } --- 109,113 ---- constraint, returnType, method: method); ! TypeConstructors.addConstructor(res.classe.getDefinition().getTC(), res); return res; } Index: dispatch.java.bootstrap =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/dispatch.java.bootstrap,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** dispatch.java.bootstrap 22 Nov 2004 21:24:54 -0000 1.26 --- dispatch.java.bootstrap 25 Nov 2004 19:28:18 -0000 1.27 *************** *** 84,87 **** --- 84,98 ---- static void typecheck(Expression e) {} + public static void resetTypeDefinitionMappings() {} + + public static TypeDefinition getTypeDefinition(mlsub.typing.TypeConstructor tc) + { return null; } + + public static mlsub.typing.Monotype getTypeWithTC(mlsub.typing.TypeConstructor tc) + { return null; } + + public static mlsub.typing.Monotype getTypeWithTC(mlsub.typing.TypeConstructor tc, mlsub.typing.Monotype[] sourceParams ) + { return null; } + static bossa.util.UserError unknownIdent(LocatedString ident) { Index: TypeConstructors.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/TypeConstructors.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** TypeConstructors.java 29 Aug 2003 16:52:42 -0000 1.11 --- TypeConstructors.java 25 Nov 2004 19:28:18 -0000 1.12 *************** *** 80,84 **** return true; ! ClassDefinition definition = ClassDefinition.get(tc); return definition != null && definition.isConcrete(); } --- 80,84 ---- return true; ! TypeDefinition definition = dispatch.getTypeDefinition(tc); return definition != null && definition.isConcrete(); } *************** *** 86,95 **** static boolean isInterface(TypeConstructor tc) { ! ClassDefinition def = ClassDefinition.get(tc); ! if (def instanceof ClassDefinition.Interface) ! return true; if (def != null) ! return false; gnu.bytecode.ClassType c = (gnu.bytecode.ClassType) Types.get(tc); --- 86,93 ---- static boolean isInterface(TypeConstructor tc) { ! TypeDefinition def = dispatch.getTypeDefinition(tc); if (def != null) ! return def.getAssociatedInterface() != null; gnu.bytecode.ClassType c = (gnu.bytecode.ClassType) Types.get(tc); |