[Nice-commit] Nice/src/bossa/syntax new.nice,NONE,1.1 EnumDefinition.java,1.11,1.12 dispatch.java.bo
Brought to you by:
bonniot
From: Arjan B. <ar...@us...> - 2004-08-04 18:36:18
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14627/F:/nice/src/bossa/syntax Modified Files: EnumDefinition.java dispatch.java.bootstrap tools.nice Added Files: new.nice Removed Files: NewExp.java Log Message: Converted NewExp to nice code. Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** tools.nice 4 Aug 2004 17:09:07 -0000 1.42 --- tools.nice 4 Aug 2004 18:36:09 -0000 1.43 *************** *** 291,295 **** Stack<bossa.link.Alternative> sortedAlternatives(MethodDeclaration) = native Stack bossa.link.Alternative.sortedAlternatives(MethodDeclaration); List<VarSymbol> getConstructorCallSymbols(NiceClass) = native List NiceClass.getConstructorCallSymbols(); ! // Retypings needed since java types are not strict. --- 291,295 ---- Stack<bossa.link.Alternative> sortedAlternatives(MethodDeclaration) = native Stack bossa.link.Alternative.sortedAlternatives(MethodDeclaration); List<VarSymbol> getConstructorCallSymbols(NiceClass) = native List NiceClass.getConstructorCallSymbols(); ! LinkedList<VarSymbol> getConstructors(mlsub.typing.TypeConstructor) = native LinkedList TypeConstructors.getConstructors(mlsub.typing.TypeConstructor); // Retypings needed since java types are not strict. Index: dispatch.java.bootstrap =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/dispatch.java.bootstrap,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** dispatch.java.bootstrap 4 Aug 2004 17:09:07 -0000 1.16 --- dispatch.java.bootstrap 4 Aug 2004 18:36:09 -0000 1.17 *************** *** 28,31 **** --- 28,34 ---- { return null; } + public static Expression createNewExp(TypeIdent ti, Arguments arguments) + { return null; } + public static gnu.bytecode.Method getImplementationAbove(JavaMethod decl, gnu.bytecode.ClassType firstArg) { return null; } --- NEW FILE: new.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.*; import java.util.*; /** Call of an object constructor. */ public class NewExp extends CallExp { private final TypeIdent ti; /** Can be null if the class instantiated is Object. */ ?mlsub.typing.TypeConstructor tc = null; void resolve(TypeMap typeScope) { mlsub.typing.TypeSymbol sym = ti.resolveToTypeSymbol(typeScope); if (sym == mlsub.typing.TopMonotype.instance) this.setObject(); else if (sym instanceof mlsub.typing.TypeConstructor) this.setTC(sym); else throw User.error(ti, ti + " is not a class" + sym.getClass()); } private void setTC(mlsub.typing.TypeConstructor tc) { this.tc = tc; if (! TypeConstructors.instantiable(tc)) { String message; if (TypeConstructors.isInterface(tc)) message = tc + " is an interface, it can't be instantiated"; else if (TypeConstructors.isClass(tc)) message = tc + " is an abstract class, it can't be instantiated"; else message = tc + " is a type variable, it can't be instantiated"; throw User.error(this, message); } // Make sure that the constructors have been created. ClassDefinition definition = ClassDefinition.get(tc); if (definition != null) definition.resolve(); LinkedList<VarSymbol> constructors = TypeConstructors.getConstructors(tc); if (constructors == null) { if (tc.arity() > 0) User.error(this, "Class " + tc + " has no constructor with " + tc.arity() + " type parameters.\n" + "A retyping is needed to use this constructor."); else User.error(this, "Class " + tc + " has no constructor"); } // the list of constructors must be cloned, as // OverloadedSymbolExp removes elements from it constructors = constructors.clone(); function = createOverloadedSymbolExp(constructors, new LocatedString("new " + tc, this.location())); } private void setObject() { JavaMethod method = JavaClasses.getObjectConstructor(); function = new SymbolExp(method.getSymbol(), ti.location()); } toString() = "new " + ti.toString() + arguments; } public Expression createNewExp(TypeIdent ti, Arguments arguments) { return new NewExp(null, arguments, ti: ti); } --- NewExp.java DELETED --- Index: EnumDefinition.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/EnumDefinition.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** EnumDefinition.java 28 Jul 2004 14:40:33 -0000 1.11 --- EnumDefinition.java 4 Aug 2004 18:36:08 -0000 1.12 *************** *** 108,112 **** ((MonoSymbol)fields.get(i)).getName())); ! this.value = new NewExp(new TypeIdent(enumName), new Arguments(args)); } --- 108,112 ---- ((MonoSymbol)fields.get(i)).getName())); ! this.value = bossa.syntax.dispatch.createNewExp(new TypeIdent(enumName), new Arguments(args)); } |