[Nice-commit] Nice/src/bossa/syntax ai.nice,NONE,1.1 tools.nice,1.65,1.66 typedef.nice,1.1,1.2 Abstr
Brought to you by:
bonniot
From: Arjan B. <ar...@us...> - 2004-11-28 01:01:33
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14105/F:/nice/src/bossa/syntax Modified Files: tools.nice typedef.nice Added Files: ai.nice Removed Files: AbstractInterface.java AbstractInterfaceImplementation.java Log Message: Converted AbstractInterface. Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** tools.nice 27 Nov 2004 16:52:52 -0000 1.65 --- tools.nice 28 Nov 2004 01:00:47 -0000 1.66 *************** *** 196,200 **** Map<VarSymbol,mlsub.typing.Polytype> types(Arguments) = native Arguments.types; <T> String map(String, String, String, T[]) = native String bossa.util.Util.map(String, String, String, Object[]); ! <T> String map(String, String, String, Collection<T>) = native String bossa.util.Util.map(String, String, String, Collection); Stack<bossa.link.Alternative> sortedAlternatives(MethodDeclaration) = native Stack bossa.link.Alternative.sortedAlternatives(MethodDeclaration); ?LinkedList<VarSymbol> getConstructors(mlsub.typing.TypeConstructor) = native LinkedList TypeConstructors.getConstructors(mlsub.typing.TypeConstructor); --- 196,200 ---- Map<VarSymbol,mlsub.typing.Polytype> types(Arguments) = native Arguments.types; <T> String map(String, String, String, T[]) = native String bossa.util.Util.map(String, String, String, Object[]); ! <T> String map(String, String, String, ?Collection<T>) = native String bossa.util.Util.map(String, String, String, Collection); Stack<bossa.link.Alternative> sortedAlternatives(MethodDeclaration) = native Stack bossa.link.Alternative.sortedAlternatives(MethodDeclaration); ?LinkedList<VarSymbol> getConstructors(mlsub.typing.TypeConstructor) = native LinkedList TypeConstructors.getConstructors(mlsub.typing.TypeConstructor); *************** *** 235,239 **** 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(); --- 235,238 ---- Index: typedef.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typedef.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** typedef.nice 25 Nov 2004 19:28:19 -0000 1.1 --- typedef.nice 28 Nov 2004 01:00:47 -0000 1.2 *************** *** 232,236 **** { this.resolveInterfaces(implementations); ! abs = AbstractInterface.resolve(notNull(typeScope), abstractions); implementations = null; --- 232,239 ---- { this.resolveInterfaces(implementations); ! ! if (abstractions != null && notNull(abstractions).size() != 0) ! abs = notNull(abstractions).mapToArray(MonotypeConstructor parent => ! notNull(parent.tc).resolveToItf(notNull(typeScope))); implementations = null; --- NEW FILE: ai.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.*; /** Declaration of an abstract interface (i.e. a ML-Sub interface). */ public class AbstractInterface extends MethodContainer { /** ML-Sub interface. */ private mlsub.typing.Interface itf = cast(null); private ?List<MonotypeConstructor> extensions; // the super-interfaces private mlsub.typing.Interface[?] superInterfaces = null; // resolved super-interfaces getTypeSymbol()= itf; resolve() { super; if (extensions != null && notNull(extensions).size() != 0) superInterfaces = notNull(extensions).mapToArray(MonotypeConstructor parent => notNull(parent.tc).resolveToItf(notNull(typeScope))); extensions = null; this.createContext(); } private void createContext() { if (superInterfaces != null) try{ mlsub.typing.Typing.assertLeq(itf, notNull(superInterfaces)); } catch(mlsub.typing.KindingEx e){ User.error(name, name + " cannot extends one of the interfaces " + " because they don't have the same number or kind of " + " type parameters"); } } printInterface(w) { super; w.print("abstract interface " + this.getSimpleName() + this.printTypeParameters() + Util.map(" extends ",", ","", superInterfaces) + "{}\n"); } compile() {} toString() = name.toString(); } public AbstractInterface createAbstractInterface(LocatedString name, MethodContainer.Constraint typeParameters, List<?boolean> typeParametersVariances, List<MonotypeConstructor> extensions ) { let res = new AbstractInterface(name, Node.global, typeParameters, typeParametersVariances, extensions: extensions); res.itf = new Interface(res.variance, name.toString()); res.addTypeSymbol(res.itf); return res; } /** Declaration that an existing class implements an abstract interface. The abstract interface must belong to the current package. */ public class AbstractInterfaceImplementation extends Definition { final LocatedString className; final LocatedString interfaceName; final boolean _finally; final boolean _interface; ?TypeConstructor classTC = null; ?Interface interfaceITF = null; resolve() { classTC = new TypeIdent(className).resolveToTC(typeScope); if (TypeConstructors.isInterface(classTC)) { if (!_interface) User.error(this, ""+classTC+" is not a class"); } else { if (_interface) User.error(this, ""+classTC+" is not an interface"); } let ident = new TypeIdent (new LocatedString(module.getName() + '.' + interfaceName.content, interfaceName.location())); interfaceITF = ident.resolveToItf(typeScope); let def = getTypeDefinition(notNull(classTC)); boolean isNiceClass = def != null && (def.getImplementation() instanceof NiceClass); if (!isNiceClass && notNull(interfaceITF).associatedTC() != null) User.error(this, className + " is not a class defined in Nice.\n" + "It can only implement abstract interfaces."); if (def != null) def.addInterfaceImplementation(interfaceITF); this.createContext(); } private void createContext() { try { mlsub.typing.Typing.assertImp(classTC, interfaceITF, true); if (_finally) mlsub.typing.Typing.assertAbs(classTC, interfaceITF); } catch(mlsub.typing.TypingEx ex) { User.error(this, "Class " + classTC + " cannot implement " + interfaceITF + ": they do not have the same number or kind of type parameters"); } } printInterface(w) { if (_interface) w.print("interface "); else w.print("class "); w.print(classTC); w.print(" implements "); w.print(interfaceName); w.println(";"); } compile() {} } --- AbstractInterfaceImplementation.java DELETED --- --- AbstractInterface.java DELETED --- |