nice-commit Mailing List for The Nice Programming Language (Page 29)
Brought to you by:
bonniot
You can subscribe to this list here.
2003 |
Jan
|
Feb
(60) |
Mar
(125) |
Apr
(183) |
May
(140) |
Jun
(227) |
Jul
(141) |
Aug
(181) |
Sep
(75) |
Oct
(89) |
Nov
(187) |
Dec
(162) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(69) |
Feb
(197) |
Mar
(98) |
Apr
(26) |
May
(10) |
Jun
(85) |
Jul
(88) |
Aug
(79) |
Sep
(80) |
Oct
(81) |
Nov
(53) |
Dec
(109) |
2005 |
Jan
(68) |
Feb
(77) |
Mar
(232) |
Apr
(79) |
May
(37) |
Jun
(37) |
Jul
(3) |
Aug
(18) |
Sep
|
Oct
|
Nov
|
Dec
|
2006 |
Jan
(10) |
Feb
|
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(1) |
Dec
(9) |
2007 |
Jan
(2) |
Feb
(8) |
Mar
(2) |
Apr
(5) |
May
|
Jun
|
Jul
|
Aug
(4) |
Sep
|
Oct
|
Nov
(17) |
Dec
(6) |
2008 |
Jan
|
Feb
(3) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Arjan B. <ar...@us...> - 2004-12-07 02:07:16
|
Update of /cvsroot/nice/Nice In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24196/Nice Modified Files: Makefile Log Message: Explicitly compile the gnu.expr package. Index: Makefile =================================================================== RCS file: /cvsroot/nice/Nice/Makefile,v retrieving revision 1.154 retrieving revision 1.155 diff -C2 -d -r1.154 -r1.155 *** Makefile 7 Oct 2004 09:41:51 -0000 1.154 --- Makefile 7 Dec 2004 02:07:07 -0000 1.155 *************** *** 162,166 **** src/bossa/syntax/dispatch.java \ src/mlsub/typing/TypeConstructorLeqMonotypeCst.java \ ! src/gnu/expr/LoopExp.java \ stdlib/nice/lang/{Native,rawArray}.java \ src/bossa/modules/{Package,CompilationListener}.java \ --- 162,166 ---- src/bossa/syntax/dispatch.java \ src/mlsub/typing/TypeConstructorLeqMonotypeCst.java \ ! src/gnu/expr/*.java \ stdlib/nice/lang/{Native,rawArray}.java \ src/bossa/modules/{Package,CompilationListener}.java \ |
From: Arjan B. <ar...@us...> - 2004-12-06 23:32:35
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23981/F:/nice/src/bossa/syntax Modified Files: tools.nice Log Message: Avoid use of new features. Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** tools.nice 4 Dec 2004 19:38:18 -0000 1.68 --- tools.nice 6 Dec 2004 23:32:23 -0000 1.69 *************** *** 246,249 **** --- 246,254 ---- Pattern[] formals(MethodImplementation) = native MethodImplementation.formals; LocatedString name(Definition) = native Definition.name; + void addMappingsLS(TypeScope, Collection<LocatedString>, TypeSymbol[]) = native void TypeScope.addMappingsLS(Collection, TypeSymbol[]); + Stack<gnu.bytecode.Variable> copies(FormalParameters.Parameter.Symbol) = native FormalParameters.Parameter.Symbol.copies; + gnu.expr.CopyArgument CopyArgument(Stack<gnu.bytecode.Variable>) = native new gnu.expr.CopyArgument(Stack); + MethodContainer MethodContainer(LocatedString, int, MethodContainer.Constraint, List<?boolean>) = native new MethodContainer(LocatedString, int, MethodContainer.Constraint, List); + AST AST(List<Definition>, int) = native new AST(List, int); // Retypings needed since java types are not strict. |
From: Arjan B. <ar...@us...> - 2004-12-04 19:38:29
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28773/F:/nice/src/bossa/syntax Modified Files: DefaultMethodImplementation.java FormalParameters.java MethodImplementation.java analyse.nice call.nice dispatch.java.bootstrap methodbody.nice new.nice niceclass.nice overloadedsymbol.nice tools.nice Added Files: symbolexp.nice Removed Files: SymbolExp.java Log Message: Converted SymbolExp. Index: analyse.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/analyse.nice,v retrieving revision 1.115 retrieving revision 1.116 diff -C2 -d -r1.115 -r1.116 *** analyse.nice 1 Dec 2004 02:00:31 -0000 1.115 --- analyse.nice 4 Dec 2004 19:38:18 -0000 1.116 *************** *** 503,507 **** return createOverloadedSymbolExp(sym, notNull(e.ident)); else ! return new SymbolExp(sym, e.location()); } } --- 503,507 ---- return createOverloadedSymbolExp(sym, notNull(e.ident)); else ! return createSymbolExp(sym, e.location()); } } *************** *** 526,530 **** if (state == 1/*XXX: FormalParameters.Parameter.Symbol.ARGUMENT_REFERENCE*/) ! return new FormalParameters.Parameter.AccessExp(sym, e.location()); // Otherwise, we are in the normal case. } --- 526,530 ---- if (state == 1/*XXX: FormalParameters.Parameter.Symbol.ARGUMENT_REFERENCE*/) ! return createParameterAccessExp(sym, e.location()); // Otherwise, we are in the normal case. } *************** *** 547,551 **** } ! return new SymbolExp(sym, e.location()); } else --- 547,551 ---- } ! return createSymbolExp(sym, e.location()); } else Index: methodbody.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/methodbody.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** methodbody.nice 1 Dec 2004 02:00:32 -0000 1.2 --- methodbody.nice 4 Dec 2004 19:38:18 -0000 1.3 *************** *** 415,419 **** Node.currentFunction = this; if (this.hasThis()) ! Node.thisExp = new SymbolExp(notNull(parameters)[0], this.location()); typecheck(body); --- 415,419 ---- Node.currentFunction = this; if (this.hasThis()) ! Node.thisExp = createSymbolExp(notNull(parameters)[0], this.location()); typecheck(body); Index: MethodImplementation.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MethodImplementation.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** MethodImplementation.java 25 Nov 2004 19:28:18 -0000 1.10 --- MethodImplementation.java 4 Dec 2004 19:38:18 -0000 1.11 *************** *** 114,118 **** { if (hasThis()) ! Node.thisExp = new SymbolExp(parameters[0], location()); try { --- 114,118 ---- { if (hasThis()) ! Node.thisExp = dispatch.createSymbolExp(parameters[0], location()); try { Index: DefaultMethodImplementation.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/DefaultMethodImplementation.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** DefaultMethodImplementation.java 10 Oct 2004 12:48:42 -0000 1.10 --- DefaultMethodImplementation.java 4 Dec 2004 19:38:18 -0000 1.11 *************** *** 92,96 **** Node.currentFunction = this; if (hasThis()) ! Node.thisExp = new SymbolExp(parameters[0], location()); try{ --- 92,96 ---- Node.currentFunction = this; if (hasThis()) ! Node.thisExp = dispatch.createSymbolExp(parameters[0], location()); try{ --- SymbolExp.java DELETED --- Index: niceclass.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/niceclass.nice,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** niceclass.nice 25 Nov 2004 19:28:18 -0000 1.6 --- niceclass.nice 4 Dec 2004 19:38:18 -0000 1.7 *************** *** 233,237 **** thisSymbol = new ThisSymbol(FormalParameters.thisName, thisType, declaringClass: this); ! Node.thisExp = new SymbolExp(thisSymbol, definition.location()); scope.addSymbol(thisSymbol); --- 233,237 ---- thisSymbol = new ThisSymbol(FormalParameters.thisName, thisType, declaringClass: this); ! Node.thisExp = createSymbolExp(notNull(thisSymbol), definition.location()); scope.addSymbol(thisSymbol); *************** *** 295,299 **** { this.enterTypingContext(); ! Node.thisExp = new SymbolExp(thisSymbol, definition.location()); for (init : initializers) typecheck(init); --- 295,299 ---- { this.enterTypingContext(); ! Node.thisExp = createSymbolExp(notNull(thisSymbol), definition.location()); for (init : initializers) typecheck(init); Index: overloadedsymbol.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/overloadedsymbol.nice,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** overloadedsymbol.nice 7 Nov 2004 01:07:26 -0000 1.7 --- overloadedsymbol.nice 4 Dec 2004 19:38:18 -0000 1.8 *************** *** 35,44 **** private Expression uniqueExpression() { ! return new SymbolExp(symbols.get(0), this.location()); } private Expression uniqueExpression(VarSymbol sym, mlsub.typing.Polytype t) { ! SymbolExp res = new SymbolExp(sym, this.location()); res.type = t; return res; --- 35,44 ---- private Expression uniqueExpression() { ! return createSymbolExp(symbols.get(0), this.location()); } private Expression uniqueExpression(VarSymbol sym, mlsub.typing.Polytype t) { ! SymbolExp res = cast(createSymbolExp(sym, this.location())); res.type = t; return res; Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** tools.nice 1 Dec 2004 02:00:32 -0000 1.67 --- tools.nice 4 Dec 2004 19:38:18 -0000 1.68 *************** *** 36,40 **** localVariable(SymbolExp e) { ! let sym = e.getSymbol(); if (! (sym instanceof bossa.syntax.MonoSymbol)) return null; --- 36,40 ---- localVariable(SymbolExp e) { ! let sym = e.symbol; if (! (sym instanceof bossa.syntax.MonoSymbol)) return null; Index: new.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/new.nice,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** new.nice 25 Nov 2004 19:28:18 -0000 1.7 --- new.nice 4 Dec 2004 19:38:18 -0000 1.8 *************** *** 80,84 **** JavaMethod method = JavaClasses.getObjectConstructor(); ! function = new SymbolExp(method.getSymbol(), ti.location()); } --- 80,84 ---- JavaMethod method = JavaClasses.getObjectConstructor(); ! function = createSymbolExp(method.getSymbol(), ti.location()); } --- NEW FILE: symbolexp.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.*; /** Access to a symbol (variable, function parameter). */ public class SymbolExp extends Expression { final VarSymbol symbol; isAssignable() = symbol.isAssignable(); getFieldAccessMethod() = symbol.getFieldAccessMethod(); checkSpecialRequirements(arguments) { symbol.checkSpecialRequirements(arguments); } computeType() { // Very important: each SymbolExp gets a copy of the type of the symbol. // Thus it has fresh binders. // Otherwise there would be an "aliasing" effect. // An important supposition is that two uses of a symbol // are two different SymbolExp objects // (with a reference to the same symbol). // So they hold different (but equivalent) types. type = symbol.getType().cloneType(); } compile() { try { return symbol.compile(); } catch(FieldAccess.UsingAsValue e) { throw User.error(this, "You must supply the object that contains this field"); } } generateCodeInCallPosition() { try { gnu.expr.Expression res = symbol.compileInCallPosition(); this.location().write(res); return res; } catch(FieldAccess.UsingAsValue e) { throw User.error(this, "You must supply the object that contains this field"); } } getDeclaration() { let decl = symbol.getDeclaration(); if(decl==null) Internal.error(this+" has no bytecode declaration"); return decl; } public LocatedString getName() { return symbol.name; } toString() = symbol.name.toQuotedString(); } Expression createSymbolExp(VarSymbol symbol, Location loc) { let res = new SymbolExp(symbol: symbol); res.setLocation(loc); return res; } /** Access to a symbol of a previous formal parameter. */ class ParameterAccessExp extends SymbolExp { override FormalParameters.Parameter.Symbol symbol; isAssignable() = false; compile () { return new gnu.expr.CopyArgument(this.symbol.copies); } } SymbolExp createParameterAccessExp(FormalParameters.Parameter.Symbol symbol, Location loc) { let res = new ParameterAccessExp(symbol: symbol); res.setLocation(loc); return res; } Index: call.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/call.nice,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** call.nice 1 Dec 2004 02:00:32 -0000 1.5 --- call.nice 4 Dec 2004 19:38:18 -0000 1.6 *************** *** 224,228 **** { SymbolExp func = cast(function); ! Definition def = func.getSymbol().getDefinition(); if (def instanceof RetypedJavaMethod) --- 224,228 ---- { SymbolExp func = cast(function); ! Definition def = func.symbol.getDefinition(); if (def instanceof RetypedJavaMethod) Index: dispatch.java.bootstrap =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/dispatch.java.bootstrap,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** dispatch.java.bootstrap 26 Nov 2004 20:26:02 -0000 1.28 --- dispatch.java.bootstrap 4 Dec 2004 19:38:18 -0000 1.29 *************** *** 13,16 **** --- 13,19 ---- public class dispatch { + public static Expression createSymbolExp(VarSymbol symbol, bossa.util.Location loc) + { return null; } + public static Expression createCallExp(Expression function, Expression param1) { return null; } Index: FormalParameters.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/FormalParameters.java,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** FormalParameters.java 21 Nov 2004 23:24:36 -0000 1.44 --- FormalParameters.java 4 Dec 2004 19:38:18 -0000 1.45 *************** *** 120,124 **** } ! private java.util.Stack copies; public void setDeclaration (gnu.expr.Declaration declaration, --- 120,124 ---- } ! java.util.Stack copies; public void setDeclaration (gnu.expr.Declaration declaration, *************** *** 130,148 **** private Symbol symbol; - - static class AccessExp extends SymbolExp - { - AccessExp (Symbol symbol, Location location) - { - super(symbol, location); - } - - public boolean isAssignable () { return false; } - - public gnu.expr.Expression compile () - { - return new gnu.expr.CopyArgument(((Symbol) this.getSymbol()).copies); - } - } } --- 130,133 ---- |
From: Arjan B. <ar...@us...> - 2004-12-01 02:44:04
|
Update of /cvsroot/nice/Nice/src/nice/tools/typing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14421/F:/nice/src/nice/tools/typing Modified Files: PrimitiveType.java Types.java Log Message: Make nice.tools.typing not depend on bossa.syntax. Index: Types.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/typing/Types.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Types.java 1 Dec 2004 02:00:30 -0000 1.10 --- Types.java 1 Dec 2004 02:43:53 -0000 1.11 *************** *** 111,114 **** --- 111,120 ---- } + public static mlsub.typing.Monotype sureMonotype(mlsub.typing.Monotype type) + { + return new mlsub.typing.MonotypeConstructor + (PrimitiveType.sureTC, new mlsub.typing.Monotype[]{type}); + } + /**************************************************************** * Functional types *************** *** 149,153 **** return new Polytype (type.getConstraint(), ! bossa.syntax.Monotype.sure(type.getMonotype())); } --- 155,159 ---- return new Polytype (type.getConstraint(), ! Types.sureMonotype(type.getMonotype())); } Index: PrimitiveType.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/typing/PrimitiveType.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PrimitiveType.java 1 Dec 2004 02:00:30 -0000 1.1 --- PrimitiveType.java 1 Dec 2004 02:43:53 -0000 1.2 *************** *** 36,40 **** { charTC = tc; ! charType = sureMonotype(new MonotypeConstructor(tc, null)); return SpecialTypes.charType; } --- 36,40 ---- { charTC = tc; ! charType = Types.sureMonotype(new MonotypeConstructor(tc, null)); return SpecialTypes.charType; } *************** *** 43,47 **** { byteTC = tc; ! byteType = sureMonotype(new MonotypeConstructor(tc, null)); bytePolytype = new Polytype(byteType); return SpecialTypes.byteType; --- 43,47 ---- { byteTC = tc; ! byteType = Types.sureMonotype(new MonotypeConstructor(tc, null)); bytePolytype = new Polytype(byteType); return SpecialTypes.byteType; *************** *** 51,55 **** { shortTC = tc; ! shortType = sureMonotype(new MonotypeConstructor(tc, null)); shortPolytype = new Polytype(shortType); return SpecialTypes.shortType; --- 51,55 ---- { shortTC = tc; ! shortType = Types.sureMonotype(new MonotypeConstructor(tc, null)); shortPolytype = new Polytype(shortType); return SpecialTypes.shortType; *************** *** 59,63 **** { intTC = tc; ! intType = sureMonotype(new MonotypeConstructor(tc, null)); intPolytype = new Polytype(intType); return SpecialTypes.intType; --- 59,63 ---- { intTC = tc; ! intType = Types.sureMonotype(new MonotypeConstructor(tc, null)); intPolytype = new Polytype(intType); return SpecialTypes.intType; *************** *** 67,71 **** { longTC = tc; ! longType = sureMonotype(new MonotypeConstructor(tc, null)); longPolytype = new Polytype(longType); return SpecialTypes.longType; --- 67,71 ---- { longTC = tc; ! longType = Types.sureMonotype(new MonotypeConstructor(tc, null)); longPolytype = new Polytype(longType); return SpecialTypes.longType; *************** *** 75,79 **** { boolTC = tc; ! boolType = sureMonotype(new MonotypeConstructor(tc, null)); boolPolytype = new Polytype(boolType); return SpecialTypes.booleanType; --- 75,79 ---- { boolTC = tc; ! boolType = Types.sureMonotype(new MonotypeConstructor(tc, null)); boolPolytype = new Polytype(boolType); return SpecialTypes.booleanType; *************** *** 83,87 **** { doubleTC = tc; ! doubleType = sureMonotype(new MonotypeConstructor(tc, null)); return SpecialTypes.doubleType; } --- 83,87 ---- { doubleTC = tc; ! doubleType = Types.sureMonotype(new MonotypeConstructor(tc, null)); return SpecialTypes.doubleType; } *************** *** 90,94 **** { floatTC = tc; ! floatType = sureMonotype(new MonotypeConstructor(tc, null)); return SpecialTypes.floatType; } --- 90,94 ---- { floatTC = tc; ! floatType = Types.sureMonotype(new MonotypeConstructor(tc, null)); return SpecialTypes.floatType; } *************** *** 98,102 **** voidTC = tc; mlsub.typing.lowlevel.Engine.setTop(tc); ! voidType = sureMonotype(new MonotypeConstructor(tc, null)); voidPolytype = new Polytype(Constraint.True, voidType); return SpecialTypes.voidType; --- 98,102 ---- voidTC = tc; mlsub.typing.lowlevel.Engine.setTop(tc); ! voidType = Types.sureMonotype(new MonotypeConstructor(tc, null)); voidPolytype = new Polytype(Constraint.True, voidType); return SpecialTypes.voidType; *************** *** 141,150 **** } - private static mlsub.typing.Monotype sureMonotype(mlsub.typing.Monotype type) - { - return new mlsub.typing.MonotypeConstructor - (PrimitiveType.sureTC, new mlsub.typing.Monotype[]{type}); - } - public static TypeConstructor byteTC, charTC, intTC, longTC, boolTC, shortTC, doubleTC, floatTC, arrayTC, voidTC; --- 141,144 ---- *************** *** 157,161 **** if (objectPolytype == null) objectPolytype = new Polytype(mlsub.typing.Constraint.True, ! sureMonotype(TopMonotype.instance)); return objectPolytype; --- 151,155 ---- if (objectPolytype == null) objectPolytype = new Polytype(mlsub.typing.Constraint.True, ! Types.sureMonotype(TopMonotype.instance)); return objectPolytype; *************** *** 177,181 **** throwableType = new Polytype (Constraint.True, ! sureMonotype(new MonotypeConstructor(throwableTC, null))); } return throwableType; --- 171,175 ---- throwableType = new Polytype (Constraint.True, ! Types.sureMonotype(new MonotypeConstructor(throwableTC, null))); } return throwableType; |
From: Arjan B. <ar...@us...> - 2004-12-01 02:01:14
|
Update of /cvsroot/nice/Nice/src/nice/tools/typing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4921/F:/nice/src/nice/tools/typing Modified Files: Types.java Added Files: PrimitiveType.java Log Message: Moved the static part of PrimitiveType to nice.tools.typing and converted the rest. Index: Types.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/typing/Types.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Types.java 22 Nov 2004 23:21:05 -0000 1.9 --- Types.java 1 Dec 2004 02:00:30 -0000 1.10 *************** *** 20,24 **** import mlsub.typing.*; ! import bossa.syntax.PrimitiveType; public final class Types --- 20,24 ---- import mlsub.typing.*; ! public final class Types --- NEW FILE: PrimitiveType.java --- /**************************************************************************/ /* 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 nice.tools.typing; import bossa.util.*; import java.util.*; import mlsub.typing.*; import mlsub.typing.TypeConstructor; import mlsub.typing.MonotypeConstructor; import mlsub.typing.Polytype; import mlsub.typing.Constraint; import nice.tools.code.SpecialTypes; /** */ public final class PrimitiveType { public static gnu.bytecode.Type register(String name, TypeConstructor tc) { if(name.equals("nice.lang.char")) { charTC = tc; charType = sureMonotype(new MonotypeConstructor(tc, null)); return SpecialTypes.charType; } if(name.equals("nice.lang.byte")) { byteTC = tc; byteType = sureMonotype(new MonotypeConstructor(tc, null)); bytePolytype = new Polytype(byteType); return SpecialTypes.byteType; } if(name.equals("nice.lang.short")) { shortTC = tc; shortType = sureMonotype(new MonotypeConstructor(tc, null)); shortPolytype = new Polytype(shortType); return SpecialTypes.shortType; } if(name.equals("nice.lang.int")) { intTC = tc; intType = sureMonotype(new MonotypeConstructor(tc, null)); intPolytype = new Polytype(intType); return SpecialTypes.intType; } if(name.equals("nice.lang.long")) { longTC = tc; longType = sureMonotype(new MonotypeConstructor(tc, null)); longPolytype = new Polytype(longType); return SpecialTypes.longType; } if(name.equals("nice.lang.boolean")) { boolTC = tc; boolType = sureMonotype(new MonotypeConstructor(tc, null)); boolPolytype = new Polytype(boolType); return SpecialTypes.booleanType; } if(name.equals("nice.lang.double")) { doubleTC = tc; doubleType = sureMonotype(new MonotypeConstructor(tc, null)); return SpecialTypes.doubleType; } if(name.equals("nice.lang.float")) { floatTC = tc; floatType = sureMonotype(new MonotypeConstructor(tc, null)); return SpecialTypes.floatType; } if(name.equals("nice.lang.void")) { voidTC = tc; mlsub.typing.lowlevel.Engine.setTop(tc); voidType = sureMonotype(new MonotypeConstructor(tc, null)); voidPolytype = new Polytype(Constraint.True, voidType); return SpecialTypes.voidType; } if (name.equals("nice.lang.Array")) { arrayTC = tc; return nice.tools.code.SpecialArray.wrappedType(); } if (name.equals("nice.lang.Maybe")) { maybeTC = tc; mlsub.typing.NullnessKind.setMaybe(tc); // to differ with the null result, which signals error return gnu.bytecode.Type.pointer_type; } if (name.equals("nice.lang.Sure")) { sureTC = tc; mlsub.typing.NullnessKind.setSure(tc); // to differ with the null result, which signals error return gnu.bytecode.Type.pointer_type; } if (name.equals("nice.lang.Null")) { nullTC = tc; // to differ with the null result, which signals error return gnu.bytecode.Type.pointer_type; } if (name.equals("nice.lang.Type")) { // to differ with the null result, which signals error return gnu.bytecode.Type.pointer_type; } return null; } private static mlsub.typing.Monotype sureMonotype(mlsub.typing.Monotype type) { return new mlsub.typing.MonotypeConstructor (PrimitiveType.sureTC, new mlsub.typing.Monotype[]{type}); } public static TypeConstructor byteTC, charTC, intTC, longTC, boolTC, shortTC, doubleTC, floatTC, arrayTC, voidTC; public static mlsub.typing.Monotype byteType, charType, intType, longType, boolType, shortType, doubleType, floatType, voidType; public static Polytype voidPolytype, boolPolytype, bytePolytype, shortPolytype, intPolytype, longPolytype; private static Polytype objectPolytype; public static Polytype objectPolytype() { if (objectPolytype == null) objectPolytype = new Polytype(mlsub.typing.Constraint.True, sureMonotype(TopMonotype.instance)); return objectPolytype; } public static void reset() { objectPolytype = null; } public static TypeConstructor maybeTC, sureTC, nullTC; public static TypeConstructor classTC; public static TypeConstructor collectionTC; public static TypeConstructor throwableTC; private static Polytype throwableType; public static Polytype throwableType() { if (throwableType == null) { throwableType = new Polytype (Constraint.True, sureMonotype(new MonotypeConstructor(throwableTC, null))); } return throwableType; } } |
From: Arjan B. <ar...@us...> - 2004-12-01 02:00:56
|
Update of /cvsroot/nice/Nice/src/nice/tools/code In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4921/F:/nice/src/nice/tools/code Modified Files: Types.java Log Message: Moved the static part of PrimitiveType to nice.tools.typing and converted the rest. Index: Types.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/code/Types.java,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** Types.java 22 Nov 2004 23:21:04 -0000 1.62 --- Types.java 1 Dec 2004 02:00:13 -0000 1.63 *************** *** 16,20 **** import bossa.util.Debug; import bossa.util.Internal; ! import bossa.syntax.PrimitiveType; import gnu.bytecode.*; --- 16,20 ---- import bossa.util.Debug; import bossa.util.Internal; ! import nice.tools.typing.PrimitiveType; import gnu.bytecode.*; |
From: Arjan B. <ar...@us...> - 2004-12-01 02:00:53
|
Update of /cvsroot/nice/Nice/src/mlsub/typing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4921/F:/nice/src/mlsub/typing Modified Files: Enumeration.java Log Message: Moved the static part of PrimitiveType to nice.tools.typing and converted the rest. Index: Enumeration.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/Enumeration.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Enumeration.java 25 Nov 2004 19:28:16 -0000 1.16 --- Enumeration.java 1 Dec 2004 02:00:13 -0000 1.17 *************** *** 153,157 **** if (c.hasConstants() && ! c != bossa.syntax.PrimitiveType.nullTC.getKind()) { if(linkDbg && Typing.dbg) --- 153,157 ---- if (c.hasConstants() && ! c != nice.tools.typing.PrimitiveType.nullTC.getKind()) { if(linkDbg && Typing.dbg) |
From: Arjan B. <ar...@us...> - 2004-12-01 02:00:53
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4921/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Moved the static part of PrimitiveType to nice.tools.typing and converted the rest. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.278 retrieving revision 1.279 diff -C2 -d -r1.278 -r1.279 *** Parser.jj 28 Nov 2004 15:35:57 -0000 1.278 --- Parser.jj 1 Dec 2004 02:00:11 -0000 1.279 *************** *** 1090,1094 **** javaName=doted_string() { res.setImplementation(new JavaClass(res, javaName)); } ! | { res.setImplementation(new PrimitiveType(res)); } ) ";" ) --- 1090,1094 ---- javaName=doted_string() { res.setImplementation(new JavaClass(res, javaName)); } ! | { res.setImplementation(bossa.syntax.dispatch.createPrimitiveType(res)); } ) ";" ) |
From: Arjan B. <ar...@us...> - 2004-12-01 02:00:53
|
Update of /cvsroot/nice/Nice/src/bossa/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4921/F:/nice/src/bossa/modules Modified Files: Package.java Log Message: Moved the static part of PrimitiveType to nice.tools.typing and converted the rest. Index: Package.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/Package.java,v retrieving revision 1.124 retrieving revision 1.125 diff -C2 -d -r1.124 -r1.125 *** Package.java 26 Nov 2004 20:26:02 -0000 1.124 --- Package.java 1 Dec 2004 02:00:13 -0000 1.125 *************** *** 18,21 **** --- 18,22 ---- import gnu.expr.*; import nice.tools.code.Import; + import nice.tools.typing.PrimitiveType; import java.util.*; |
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4921/F:/nice/src/bossa/syntax Modified Files: AtomicConstraint.java ConstantExp.java Constructor.java CustomConstructor.java Monotype.java Pattern.java analyse.nice call.nice constant.nice enum.nice funexp.nice literalarray.nice methodbody.nice newarray.nice pattern.nice return.nice statementexp.nice tools.nice try.nice typecheck.nice typedef.nice Added Files: primitive.nice Removed Files: PrimitiveType.java Log Message: Moved the static part of PrimitiveType to nice.tools.typing and converted the rest. Index: Pattern.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Pattern.java,v retrieving revision 1.94 retrieving revision 1.95 diff -C2 -d -r1.94 -r1.95 *** Pattern.java 25 Nov 2004 19:28:18 -0000 1.94 --- Pattern.java 1 Dec 2004 02:00:31 -0000 1.95 *************** *** 23,26 **** --- 23,27 ---- import mlsub.typing.TypingEx; import nice.tools.typing.Types; + import nice.tools.typing.PrimitiveType; //import gnu.expr.*; Index: CustomConstructor.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/CustomConstructor.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** CustomConstructor.java 21 Nov 2004 23:24:36 -0000 1.24 --- CustomConstructor.java 1 Dec 2004 02:00:31 -0000 1.25 *************** *** 23,26 **** --- 23,27 ---- import gnu.bytecode.MiscAttr; import nice.tools.code.Gen; + import nice.tools.typing.PrimitiveType; /** Index: literalarray.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/literalarray.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** literalarray.nice 21 Nov 2004 18:33:17 -0000 1.3 --- literalarray.nice 1 Dec 2004 02:00:32 -0000 1.4 *************** *** 36,40 **** // Object[]. if (! notNull(type).trySimplify()) ! type = this.array(PrimitiveType.objectPolytype()); } --- 36,40 ---- // Object[]. if (! notNull(type).trySimplify()) ! type = this.array(nice.tools.typing.PrimitiveType.objectPolytype()); } *************** *** 44,48 **** (elementType.getConstraint(), bossa.syntax.Monotype.sure(new mlsub.typing.MonotypeConstructor ! (PrimitiveType.arrayTC, [elementType.getMonotype()]))); res.setNotSimplified(); return res; --- 44,48 ---- (elementType.getConstraint(), bossa.syntax.Monotype.sure(new mlsub.typing.MonotypeConstructor ! (nice.tools.typing.PrimitiveType.arrayTC, [elementType.getMonotype()]))); res.setNotSimplified(); return res; *************** *** 102,108 **** // since the bytecode type of both List<List<T>> and List<T[]> is // simply List. ! if (tc != PrimitiveType.arrayTC && tc != null && tc.isRigid() && ! mlsub.typing.Typing.testRigidLeq(tc, PrimitiveType.collectionTC)) { wrapAsCollection = true; --- 102,108 ---- // since the bytecode type of both List<List<T>> and List<T[]> is // simply List. ! if (tc != nice.tools.typing.PrimitiveType.arrayTC && tc != null && tc.isRigid() && ! mlsub.typing.Typing.testRigidLeq(tc, nice.tools.typing.PrimitiveType.collectionTC)) { wrapAsCollection = true; Index: funexp.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/funexp.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** funexp.nice 28 Jul 2004 20:48:28 -0000 1.2 --- funexp.nice 1 Dec 2004 02:00:32 -0000 1.3 *************** *** 71,75 **** _inferredReturnType = mlsub.typing.Polytype.bottom(); else ! _inferredReturnType = PrimitiveType.voidPolytype; } else --- 71,75 ---- _inferredReturnType = mlsub.typing.Polytype.bottom(); else ! _inferredReturnType = nice.tools.typing.PrimitiveType.voidPolytype; } else Index: return.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/return.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** return.nice 13 Aug 2004 21:04:41 -0000 1.3 --- return.nice 1 Dec 2004 02:00:32 -0000 1.4 *************** *** 45,49 **** mlsub.typing.Polytype returnType() { ! return PrimitiveType.voidPolytype; } --- 45,49 ---- mlsub.typing.Polytype returnType() { ! return nice.tools.typing.PrimitiveType.voidPolytype; } Index: enum.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/enum.nice,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** enum.nice 27 Nov 2004 16:52:52 -0000 1.5 --- enum.nice 1 Dec 2004 02:00:32 -0000 1.6 *************** *** 178,182 **** args.add(new Arguments.Argument(createStringConstantExp(name.toString()), new LocatedString("name",name.location))); ! args.add(new Arguments.Argument(new ConstantExp(PrimitiveType.intTC, ordinal, ordinal.toString(), name.location()), new LocatedString("ordinal", name.location))); --- 178,182 ---- args.add(new Arguments.Argument(createStringConstantExp(name.toString()), new LocatedString("name",name.location))); ! args.add(new Arguments.Argument(new ConstantExp(nice.tools.typing.PrimitiveType.intTC, ordinal, ordinal.toString(), name.location()), new LocatedString("ordinal", name.location))); Index: Constructor.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Constructor.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Constructor.java 21 Nov 2004 23:24:36 -0000 1.16 --- Constructor.java 1 Dec 2004 02:00:31 -0000 1.17 *************** *** 18,21 **** --- 18,22 ---- import mlsub.typing.Constraint; import mlsub.typing.Monotype; + import nice.tools.typing.PrimitiveType; /** Index: AtomicConstraint.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/AtomicConstraint.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** AtomicConstraint.java 16 Jun 2004 14:56:14 -0000 1.13 --- AtomicConstraint.java 1 Dec 2004 02:00:30 -0000 1.14 *************** *** 15,18 **** --- 15,19 ---- import bossa.util.*; import java.util.*; + import nice.tools.typing.PrimitiveType; /** Index: typecheck.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typecheck.nice,v retrieving revision 1.117 retrieving revision 1.118 diff -C2 -d -r1.117 -r1.118 *** typecheck.nice 13 Oct 2004 23:22:22 -0000 1.117 --- typecheck.nice 1 Dec 2004 02:00:32 -0000 1.118 *************** *** 520,524 **** Expression elseExp = e.elseExp; ! condition = condition.resolveOverloading(PrimitiveType.boolPolytype); checkBooleanCondition(condition); e.condition = condition; --- 520,524 ---- Expression elseExp = e.elseExp; ! condition = condition.resolveOverloading(nice.tools.typing.PrimitiveType.boolPolytype); checkBooleanCondition(condition); e.condition = condition; *************** *** 618,623 **** { try{ ! e.variable = e.variable.resolveOverloading(PrimitiveType.longPolytype); ! checkAssignment(PrimitiveType.longType, e.variable); } catch(TypingEx t){ --- 618,623 ---- { try{ ! e.variable = e.variable.resolveOverloading(nice.tools.typing.PrimitiveType.longPolytype); ! checkAssignment(nice.tools.typing.PrimitiveType.longType, e.variable); } catch(TypingEx t){ *************** *** 642,648 **** { Expression dim = knownDimensions[i] = ! knownDimensions[i].resolveOverloading(PrimitiveType.intPolytype); try{ ! checkAssignment(PrimitiveType.intType, dim); } catch(TypingEx ex){ --- 642,648 ---- { Expression dim = knownDimensions[i] = ! knownDimensions[i].resolveOverloading(nice.tools.typing.PrimitiveType.intPolytype); try{ ! checkAssignment(nice.tools.typing.PrimitiveType.intType, dim); } catch(TypingEx ex){ *************** *** 771,777 **** decl.value = value = value.noOverloading(); target.type = ensureMonomorphic(value.getType(), decl); ! if (target.type == PrimitiveType.byteType || ! target.type == PrimitiveType.shortType) ! target.type = PrimitiveType.intType; if (nice.tools.typing.Types.isVoid(target.type)) --- 771,777 ---- decl.value = value = value.noOverloading(); target.type = ensureMonomorphic(value.getType(), decl); ! if (target.type == nice.tools.typing.PrimitiveType.byteType || ! target.type == nice.tools.typing.PrimitiveType.shortType) ! target.type = nice.tools.typing.PrimitiveType.intType; if (nice.tools.typing.Types.isVoid(target.type)) *************** *** 838,842 **** if (whileExp != null) { ! l.whileExp = whileExp = whileExp.resolveOverloading(PrimitiveType.boolPolytype); checkBooleanCondition(whileExp); } --- 838,842 ---- if (whileExp != null) { ! l.whileExp = whileExp = whileExp.resolveOverloading(nice.tools.typing.PrimitiveType.boolPolytype); checkBooleanCondition(whileExp); } *************** *** 1005,1010 **** if (tc1 == tc2) return false; ! if (tc1 == PrimitiveType.maybeTC && ! (tc2 != PrimitiveType.maybeTC || tc2 != null)) return true; --- 1005,1010 ---- if (tc1 == tc2) return false; ! if (tc1 == nice.tools.typing.PrimitiveType.maybeTC && ! (tc2 != nice.tools.typing.PrimitiveType.maybeTC || tc2 != null)) return true; *************** *** 1026,1030 **** void checkBooleanCondition(Expression condition) { try { ! checkAssignment(PrimitiveType.boolType, condition); } catch(TypingEx t){ --- 1026,1030 ---- void checkBooleanCondition(Expression condition) { try { ! checkAssignment(nice.tools.typing.PrimitiveType.boolType, condition); } catch(TypingEx t){ *************** *** 1054,1063 **** { if (type.isMonomorphic()) ! Typing.leq(type.getMonotype(), PrimitiveType.sureTC); else try { Typing.enter(); notNull(type.getConstraint()).enter(); ! Typing.leq(type.getMonotype(), PrimitiveType.sureTC); Typing.implies(); } --- 1054,1063 ---- { if (type.isMonomorphic()) ! Typing.leq(type.getMonotype(), nice.tools.typing.PrimitiveType.sureTC); else try { Typing.enter(); notNull(type.getConstraint()).enter(); ! Typing.leq(type.getMonotype(), nice.tools.typing.PrimitiveType.sureTC); Typing.implies(); } Index: statementexp.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/statementexp.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** statementexp.nice 3 Sep 2004 18:07:27 -0000 1.3 --- statementexp.nice 1 Dec 2004 02:00:32 -0000 1.4 *************** *** 32,36 **** computeType() { ! type = PrimitiveType.voidPolytype; } --- 32,36 ---- computeType() { ! type = nice.tools.typing.PrimitiveType.voidPolytype; } Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** tools.nice 28 Nov 2004 01:00:47 -0000 1.66 --- tools.nice 1 Dec 2004 02:00:32 -0000 1.67 *************** *** 108,112 **** return null; ! if (tc == PrimitiveType.arrayTC) return (sym, notNull(arg2.representedType)); --- 108,112 ---- return null; ! if (tc == nice.tools.typing.PrimitiveType.arrayTC) return (sym, notNull(arg2.representedType)); *************** *** 248,257 **** // Retypings needed since java types are not strict. ! mlsub.typing.Polytype boolPolytype() = native PrimitiveType.boolPolytype; ! mlsub.typing.Polytype longPolytype() = native PrimitiveType.longPolytype; ! mlsub.typing.Polytype voidPolytype() = native PrimitiveType.voidPolytype; ! mlsub.typing.Monotype boolType() = native PrimitiveType.boolType; ! mlsub.typing.Monotype intType() = native PrimitiveType.intType; ! mlsub.typing.Monotype longType() = native PrimitiveType.longType; gnu.expr.QuoteExp trueExp() = native gnu.expr.QuoteExp.trueExp; gnu.expr.QuoteExp voidExp() = native gnu.expr.QuoteExp.voidExp; --- 248,257 ---- // Retypings needed since java types are not strict. ! mlsub.typing.Polytype boolPolytype() = native nice.tools.typing.PrimitiveType.boolPolytype; ! mlsub.typing.Polytype longPolytype() = native nice.tools.typing.PrimitiveType.longPolytype; ! mlsub.typing.Polytype voidPolytype() = native nice.tools.typing.PrimitiveType.voidPolytype; ! mlsub.typing.Monotype boolType() = native nice.tools.typing.PrimitiveType.boolType; ! mlsub.typing.Monotype intType() = native nice.tools.typing.PrimitiveType.intType; ! mlsub.typing.Monotype longType() = native nice.tools.typing.PrimitiveType.longType; gnu.expr.QuoteExp trueExp() = native gnu.expr.QuoteExp.trueExp; gnu.expr.QuoteExp voidExp() = native gnu.expr.QuoteExp.voidExp; Index: typedef.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typedef.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** typedef.nice 28 Nov 2004 01:00:47 -0000 1.2 --- typedef.nice 1 Dec 2004 02:00:32 -0000 1.3 *************** *** 125,129 **** tc = new mlsub.typing.TypeConstructor ("null", mlsub.typing.NullnessKind.instance, this.isConcrete(), true); ! PrimitiveType.registerPrimType(name, tc); } else --- 125,129 ---- tc = new mlsub.typing.TypeConstructor ("null", mlsub.typing.NullnessKind.instance, this.isConcrete(), true); ! nice.tools.typing.PrimitiveType.register(name, tc); } else *************** *** 131,139 **** 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; } --- 131,139 ---- tc = new mlsub.typing.TypeConstructor(name, variance, this.isConcrete(), true); if (name.equals("nice.lang.Throwable")) ! nice.tools.typing.PrimitiveType.throwableTC = tc; else if (name.equals("nice.lang.Collection")) ! nice.tools.typing.PrimitiveType.collectionTC = tc; else if (name.equals("nice.lang.Class")) ! nice.tools.typing.PrimitiveType.classTC = tc; } *************** *** 508,513 **** d.resolve(); ! if (d.getImplementation() instanceof PrimitiveType && ! !(this.getImplementation() instanceof PrimitiveType)) User.error(this, "A class can't extends a primitive"); } --- 508,513 ---- d.resolve(); ! if (d.getImplementation() instanceof PrimitiveTypeImplementation && ! !(this.getImplementation() instanceof PrimitiveTypeImplementation)) User.error(this, "A class can't extends a primitive"); } Index: methodbody.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/methodbody.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** methodbody.nice 27 Nov 2004 16:52:52 -0000 1.1 --- methodbody.nice 1 Dec 2004 02:00:32 -0000 1.2 *************** *** 452,457 **** for(int n = 0; n < notNull(parameters).length; n++) res[n] = formals[n].atNull() ? ! nice.tools.code.Types.javaType(PrimitiveType.nullTC) : ! formals[n].tc == bossa.syntax.PrimitiveType.arrayTC ? nice.tools.code.SpecialArray.unknownTypeArray() : nice.tools.code.Types.javaType(notNull(parameters)[n].getMonotype()); --- 452,457 ---- for(int n = 0; n < notNull(parameters).length; n++) res[n] = formals[n].atNull() ? ! nice.tools.code.Types.javaType(nice.tools.typing.PrimitiveType.nullTC) : ! formals[n].tc == nice.tools.typing.PrimitiveType.arrayTC ? nice.tools.code.SpecialArray.unknownTypeArray() : nice.tools.code.Types.javaType(notNull(parameters)[n].getMonotype()); Index: Monotype.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Monotype.java,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** Monotype.java 30 Jul 2004 19:08:45 -0000 1.36 --- Monotype.java 1 Dec 2004 02:00:31 -0000 1.37 *************** *** 17,20 **** --- 17,21 ---- import mlsub.typing.MonotypeVar; + import nice.tools.typing.PrimitiveType; /** Index: try.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/try.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** try.nice 28 Jul 2004 14:40:33 -0000 1.1 --- try.nice 1 Dec 2004 02:00:32 -0000 1.2 *************** *** 83,87 **** { try { ! mlsub.typing.Typing.leq(t, PrimitiveType.throwableTC); } catch (mlsub.typing.TypingEx e) { --- 83,87 ---- { try { ! mlsub.typing.Typing.leq(t, nice.tools.typing.PrimitiveType.throwableTC); } catch (mlsub.typing.TypingEx e) { Index: analyse.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/analyse.nice,v retrieving revision 1.114 retrieving revision 1.115 diff -C2 -d -r1.114 -r1.115 *** analyse.nice 14 Oct 2004 09:37:27 -0000 1.114 --- analyse.nice 1 Dec 2004 02:00:31 -0000 1.115 *************** *** 642,646 **** let type = new mlsub.typing.MonotypeConstructor ! (PrimitiveType.arrayTC, [res.getMonotype()]); return new mlsub.typing.Polytype --- 642,646 ---- let type = new mlsub.typing.MonotypeConstructor ! (nice.tools.typing.PrimitiveType.arrayTC, [res.getMonotype()]); return new mlsub.typing.Polytype *************** *** 654,658 **** { if (name.equals("Object") || name.equals("java.lang.Object")) ! return PrimitiveType.objectPolytype(); if (info.typeVars[name] instanceof MonotypeVar) --- 654,658 ---- { if (name.equals("Object") || name.equals("java.lang.Object")) ! return nice.tools.typing.PrimitiveType.objectPolytype(); if (info.typeVars[name] instanceof MonotypeVar) --- NEW FILE: primitive.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 primitive type. */ public class PrimitiveTypeImplementation extends ClassImplementation { resolveClass() {} printInterface(s) { s.print(" = native ;\n"); } } PrimitiveTypeImplementation createPrimitiveType(TypeDefinition definition) { ?gnu.bytecode.Type t = nice.tools.typing.PrimitiveType.register(definition.name.toString(), definition.getTC()); if (t == null) User.error(definition, definition.name + " is not a known primitive type"); definition.setJavaType(t); return new PrimitiveTypeImplementation(); } Index: pattern.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/pattern.nice,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** pattern.nice 21 Nov 2004 18:33:17 -0000 1.9 --- pattern.nice 1 Dec 2004 02:00:32 -0000 1.10 *************** *** 23,27 **** { if (ti.toString().equals("Object")) ! return new NotNullPattern(name, PrimitiveType.sureTC, name.location); return new TypePattern(name, ti, null, name.location(), exactlyAt: false); --- 23,27 ---- { if (ti.toString().equals("Object")) ! return new NotNullPattern(name, nice.tools.typing.PrimitiveType.sureTC, name.location); return new TypePattern(name, ti, null, name.location(), exactlyAt: false); *************** *** 37,41 **** if (sure && tc == null) ! return new NotNullPattern(name, PrimitiveType.sureTC, loc); if (tc == null) --- 37,41 ---- if (sure && tc == null) ! return new NotNullPattern(name, nice.tools.typing.PrimitiveType.sureTC, loc); if (tc == null) *************** *** 48,52 **** { if (ti.toString().equals("Object")) ! return new NotNullPattern(name, PrimitiveType.sureTC, ti.location); return new TypePattern(name, ti, additional, ti.location(), exactlyAt: exactly, runtimeTC: runtimeTC); --- 48,52 ---- { if (ti.toString().equals("Object")) ! return new NotNullPattern(name, nice.tools.typing.PrimitiveType.sureTC, ti.location); return new TypePattern(name, ti, additional, ti.location(), exactlyAt: exactly, runtimeTC: runtimeTC); *************** *** 67,74 **** additional, value.location(), atValue: value); ! if (value.tc == PrimitiveType.boolTC) return new BoolPattern(value.tc, additional, value.location(), atValue: value); ! if (value.tc == PrimitiveType.charTC) return new CharPattern(value.tc, additional, value.location(), atValue: value); --- 67,74 ---- additional, value.location(), atValue: value); ! if (value.tc == nice.tools.typing.PrimitiveType.boolTC) return new BoolPattern(value.tc, additional, value.location(), atValue: value); ! if (value.tc == nice.tools.typing.PrimitiveType.charTC) return new CharPattern(value.tc, additional, value.location(), atValue: value); *************** *** 125,129 **** // don't allow integer primitive types in @type and #type patterns ! if (!equal && Typing.testRigidLeq(tc, PrimitiveType.longTC)) User.error(this.location, "A pattern cannot have a primitive type that is different from the declaration."); --- 125,129 ---- // don't allow integer primitive types in @type and #type patterns ! if (!equal && Typing.testRigidLeq(tc, nice.tools.typing.PrimitiveType.longTC)) User.error(this.location, "A pattern cannot have a primitive type that is different from the declaration."); *************** *** 167,171 **** { if (domaintc != null) ! if ( Typing.testRigidLeq(domaintc, PrimitiveType.charTC)) return; --- 167,171 ---- { if (domaintc != null) ! if ( Typing.testRigidLeq(domaintc, nice.tools.typing.PrimitiveType.charTC)) return; *************** *** 180,191 **** if (domaintc != null) { ! if (Typing.testRigidLeq(domaintc, PrimitiveType.intTC)) { ! tc = PrimitiveType.intTC; return; } ! else if (Typing.testRigidLeq(domaintc, PrimitiveType.longTC)) { ! tc = PrimitiveType.longTC; return; } --- 180,191 ---- if (domaintc != null) { ! if (Typing.testRigidLeq(domaintc, nice.tools.typing.PrimitiveType.intTC)) { ! tc = nice.tools.typing.PrimitiveType.intTC; return; } ! else if (Typing.testRigidLeq(domaintc, nice.tools.typing.PrimitiveType.longTC)) { ! tc = nice.tools.typing.PrimitiveType.longTC; return; } *************** *** 253,258 **** matches(VariablePattern p, tag) = true; ! matches(NullPattern p, tag) = tag == PrimitiveType.nullTC; ! matches(NotNullPattern p, tag) = tag != PrimitiveType.nullTC; matches(TypePattern p, tag) { --- 253,258 ---- matches(VariablePattern p, tag) = true; ! matches(NullPattern p, tag) = tag == nice.tools.typing.PrimitiveType.nullTC; ! matches(NotNullPattern p, tag) = tag != nice.tools.typing.PrimitiveType.nullTC; matches(TypePattern p, tag) { *************** *** 266,271 **** } matches(ValuePattern p, tag) = false; ! matches(BoolPattern p, tag) = tag == PrimitiveType.boolTC; ! matches(IntComparePattern p, tag) = tag != null && mlsub.typing.Typing.testRigidLeq(tag, PrimitiveType.longTC); matches(EnumPattern p, tag) = (tag != null) && mlsub.typing.Typing.testRigidLeq(tag, p.tc); --- 266,271 ---- } matches(ValuePattern p, tag) = false; ! matches(BoolPattern p, tag) = tag == nice.tools.typing.PrimitiveType.boolTC; ! matches(IntComparePattern p, tag) = tag != null && mlsub.typing.Typing.testRigidLeq(tag, nice.tools.typing.PrimitiveType.longTC); matches(EnumPattern p, tag) = (tag != null) && mlsub.typing.Typing.testRigidLeq(tag, p.tc); *************** *** 488,492 **** { ConstantExp val = cast(symbol.getValue()); ! if (Typing.testRigidLeq(val.tc, PrimitiveType.longTC)) return createPattern(pattern.kind.prefix, pattern.name, val, null, pattern.location); } --- 488,492 ---- { ConstantExp val = cast(symbol.getValue()); ! if (Typing.testRigidLeq(val.tc, nice.tools.typing.PrimitiveType.longTC)) return createPattern(pattern.kind.prefix, pattern.name, val, null, pattern.location); } *************** *** 524,528 **** ConstantExp val = cast(symbol.getValue()); ! if (val.tc == PrimitiveType.floatTC) return pattern; --- 524,528 ---- ConstantExp val = cast(symbol.getValue()); ! if (val.tc == nice.tools.typing.PrimitiveType.floatTC) return pattern; *************** *** 598,602 **** { if (name[0] == '\'') ! return createPattern(new ConstantExp(PrimitiveType.charTC, new Character(name[1]), name, loc)); --- 598,602 ---- { if (name[0] == '\'') ! return createPattern(new ConstantExp(nice.tools.typing.PrimitiveType.charTC, new Character(name[1]), name, loc)); *************** *** 626,630 **** if (name.equals("NONNULL")) ! return new NotNullPattern(null, PrimitiveType.sureTC, loc); if (name.equals("NULL")) --- 626,630 ---- if (name.equals("NONNULL")) ! return new NotNullPattern(null, nice.tools.typing.PrimitiveType.sureTC, loc); if (name.equals("NULL")) Index: constant.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/constant.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** constant.nice 13 Oct 2004 23:22:22 -0000 1.2 --- constant.nice 1 Dec 2004 02:00:32 -0000 1.3 *************** *** 182,186 **** (type.getConstraint(), Monotype.sure(new mlsub.typing.MonotypeConstructor ! (PrimitiveType.classTC, [type.getMonotype()]))); } --- 182,186 ---- (type.getConstraint(), Monotype.sure(new mlsub.typing.MonotypeConstructor ! (nice.tools.typing.PrimitiveType.classTC, [type.getMonotype()]))); } --- PrimitiveType.java DELETED --- Index: call.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/call.nice,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** call.nice 13 Oct 2004 23:22:22 -0000 1.4 --- call.nice 1 Dec 2004 02:00:32 -0000 1.5 *************** *** 350,354 **** try{ ! mlsub.typing.Typing.leq(m.head(), PrimitiveType.sureTC); } catch(TypingEx ex) { --- 350,354 ---- try{ ! mlsub.typing.Typing.leq(m.head(), nice.tools.typing.PrimitiveType.sureTC); } catch(TypingEx ex) { Index: newarray.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/newarray.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** newarray.nice 28 Jul 2004 14:40:33 -0000 1.1 --- newarray.nice 1 Dec 2004 02:00:32 -0000 1.2 *************** *** 49,53 **** { nullVars = fill(new TypeConstructor[unknownDimensions + 1], int i => ! new TypeConstructor("n" + i, notNull(PrimitiveType.maybeTC).variance, false, false)); } --- 49,53 ---- { nullVars = fill(new TypeConstructor[unknownDimensions + 1], int i => ! new TypeConstructor("n" + i, notNull(nice.tools.typing.PrimitiveType.maybeTC).variance, false, false)); } *************** *** 114,118 **** { monotype = new mlsub.typing.MonotypeConstructor ! (PrimitiveType.arrayTC, [monotype]); if (nullVars != null) monotype = mlsub.typing.MonotypeConstructor.apply(nullVars[i], monotype); --- 114,118 ---- { monotype = new mlsub.typing.MonotypeConstructor ! (nice.tools.typing.PrimitiveType.arrayTC, [monotype]); if (nullVars != null) monotype = mlsub.typing.MonotypeConstructor.apply(nullVars[i], monotype); *************** *** 125,129 **** for (int i = 0; i < knownDimensions.length; i++) monotype = bossa.syntax.Monotype.sure ! (mlsub.typing.MonotypeConstructor.apply(PrimitiveType.arrayTC, monotype)); // set the Expression type --- 125,129 ---- for (int i = 0; i < knownDimensions.length; i++) monotype = bossa.syntax.Monotype.sure ! (mlsub.typing.MonotypeConstructor.apply(nice.tools.typing.PrimitiveType.arrayTC, monotype)); // set the Expression type Index: ConstantExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/ConstantExp.java,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** ConstantExp.java 2 Sep 2004 18:23:25 -0000 1.53 --- ConstantExp.java 1 Dec 2004 02:00:31 -0000 1.54 *************** *** 17,20 **** --- 17,21 ---- import mlsub.typing.Polytype; import gnu.expr.QuoteExp; + import nice.tools.typing.PrimitiveType; import bossa.util.*; |
From: Arjan B. <ar...@us...> - 2004-12-01 02:00:44
|
Update of /cvsroot/nice/Nice/src/bossa/link In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4921/F:/nice/src/bossa/link Modified Files: Dispatch.java ImportedAlternative.java Log Message: Moved the static part of PrimitiveType to nice.tools.typing and converted the rest. Index: ImportedAlternative.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/link/ImportedAlternative.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ImportedAlternative.java 7 Aug 2004 14:20:27 -0000 1.10 --- ImportedAlternative.java 1 Dec 2004 02:00:30 -0000 1.11 *************** *** 63,67 **** while ((p = bossa.syntax.dispatch.readPattern(rep, at)) != null) { ! if (p.getTC() == bossa.syntax.PrimitiveType.arrayTC) /* Special treatment for arrays: they are compiled into Object, --- 63,67 ---- while ((p = bossa.syntax.dispatch.readPattern(rep, at)) != null) { ! if (p.getTC() == nice.tools.typing.PrimitiveType.arrayTC) /* Special treatment for arrays: they are compiled into Object, Index: Dispatch.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/link/Dispatch.java,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** Dispatch.java 25 Nov 2004 19:28:19 -0000 1.73 --- Dispatch.java 1 Dec 2004 02:00:30 -0000 1.74 *************** *** 24,28 **** import mlsub.typing.MonotypeLeqCst; import mlsub.typing.lowlevel.Element; ! import gnu.bytecode.ClassType; --- 24,28 ---- import mlsub.typing.MonotypeLeqCst; import mlsub.typing.lowlevel.Element; ! import nice.tools.typing.PrimitiveType; import gnu.bytecode.ClassType; |
From: Arjan B. <ar...@us...> - 2004-11-28 19:36:35
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21031/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Changed the string representation of UnknownType to "unknown". (missing parser part) Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.277 retrieving revision 1.278 diff -C2 -d -r1.277 -r1.278 *** Parser.jj 28 Nov 2004 01:00:43 -0000 1.277 --- Parser.jj 28 Nov 2004 15:35:57 -0000 1.278 *************** *** 208,211 **** --- 208,212 ---- | < FALSE: "false" > | < ALIKE: "alike" > /* Nice specific */ + | < UNKNOWN: "unknown" > /* Nice specific */ //| < THIS: "this" > | < SUPER: "super" > *************** *** 811,815 **** { return res; } | ! "?" { return Monotype.create(mlsub.typing.UnknownMonotype.instance); } } --- 812,816 ---- { return res; } | ! ("unknown" | "?") { return Monotype.create(mlsub.typing.UnknownMonotype.instance); } } |
From: Arjan B. <ar...@us...> - 2004-11-28 14:00:37
|
Update of /cvsroot/nice/Nice/src/mlsub/typing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1719/F:/nice/src/mlsub/typing Modified Files: UnknownMonotype.java Log Message: Changed the string representation of UnknownType to "unknown". Index: UnknownMonotype.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/UnknownMonotype.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** UnknownMonotype.java 30 Jul 2004 19:08:45 -0000 1.1 --- UnknownMonotype.java 28 Nov 2004 14:00:23 -0000 1.2 *************** *** 38,42 **** void tag(int variance) {} ! public String toString() { return "?"; } /**************************************************************** --- 38,42 ---- void tag(int variance) {} ! public String toString() { return "unknown"; } /**************************************************************** |
From: Arjan B. <ar...@us...> - 2004-11-28 02:44:02
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14105/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Converted AbstractInterface. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.276 retrieving revision 1.277 diff -C2 -d -r1.276 -r1.277 *** Parser.jj 27 Nov 2004 16:52:52 -0000 1.276 --- Parser.jj 28 Nov 2004 01:00:43 -0000 1.277 *************** *** 1131,1135 **** [ "extends" extensions=interfaces() ] "{" ! { res = new AbstractInterface(name,parameters,typeParametersVariances, extensions); } ( --- 1131,1135 ---- [ "extends" extensions=interfaces() ] "{" ! { res = bossa.syntax.dispatch.createAbstractInterface(name,parameters,typeParametersVariances, extensions); } ( *************** *** 1154,1158 **** [ "finally" { _finally = true; } ] "implements" interfaceName=ident() ";" ! { return new AbstractInterfaceImplementation(className, interfaceName, _finally, _interface); } --- 1154,1158 ---- [ "finally" { _finally = true; } ] "implements" interfaceName=ident() ";" ! { return new AbstractInterfaceImplementation(className, /*Node.none*/4, className, interfaceName, _finally, _interface); } |
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 --- |
From: Arjan B. <ar...@us...> - 2004-11-27 19:07:13
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6140/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Converted MethodBodyDefinition. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.275 retrieving revision 1.276 diff -C2 -d -r1.275 -r1.276 *** Parser.jj 25 Nov 2004 19:28:12 -0000 1.275 --- Parser.jj 27 Nov 2004 16:52:52 -0000 1.276 *************** *** 1378,1382 **** ")" body = code() ! { return new MethodBodyDefinition(container,name,binders, parameters,body); } } --- 1378,1382 ---- ")" body = code() ! { return bossa.syntax.dispatch.createMethodBodyDefinition(container,name,binders, parameters,body); } } |
From: Arjan B. <ar...@us...> - 2004-11-27 18:46:46
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6140/F:/nice/src/bossa/syntax Modified Files: enum.nice tools.nice Added Files: methodbody.nice Removed Files: MethodBodyDefinition.java Log Message: Converted MethodBodyDefinition. Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** tools.nice 26 Nov 2004 20:26:02 -0000 1.64 --- tools.nice 27 Nov 2004 16:52:52 -0000 1.65 *************** *** 243,249 **** = 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(); List<Node> children(Node) = native Node.children; // Retypings needed since java types are not strict. --- 243,250 ---- = 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); ?FormalParameters getFormalParameters(VarSymbol) = native FormalParameters VarSymbol.getFormalParameters(); List<Node> children(Node) = native Node.children; + Pattern[] formals(MethodImplementation) = native MethodImplementation.formals; + LocatedString name(Definition) = native Definition.name; // Retypings needed since java types are not strict. Index: enum.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/enum.nice,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** enum.nice 26 Nov 2004 20:26:02 -0000 1.4 --- enum.nice 27 Nov 2004 16:52:52 -0000 1.5 *************** *** 78,82 **** if (! notNull(Definition.currentModule).interfaceFile()) // create the method implementation of family() ! globalDefs.add(new MethodBodyDefinition(impl, new LocatedString("family"), null, new LinkedList(), createReturnStmt(createLiteralArrayExp( elements.map(LocatedString elem => new IdentExp(elem))), true))); --- 78,82 ---- if (! notNull(Definition.currentModule).interfaceFile()) // create the method implementation of family() ! globalDefs.add(createMethodBodyDefinition(impl, new LocatedString("family"), null, new LinkedList(), createReturnStmt(createLiteralArrayExp( elements.map(LocatedString elem => new IdentExp(elem))), true))); --- MethodBodyDefinition.java DELETED --- --- NEW FILE: methodbody.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.*; /** Definition of an alternative for a method. */ public class MethodBodyDefinition extends MethodImplementation { ?Collection<LocatedString> binders; // Null if type parameters are not bound private ?List<VarSymbol> symbols = null; hasThis() { return this.formals.length >= 1 && String.valueOf(this.formals[0].name).equals("this"); } firstArgument() { if (formals[0].tc != null) return notNull(formals[0].tc); else // Either there is no specialization on the first parameter, or // it was equivalent to the declaration type and has been erased, // so we return the information in the declaration. return notNull(nice.tools.typing.Types.equivalent(notNull(declaration).getArgTypes()[0]). head()); } private void setDeclaration(MethodDeclaration d) { if (d == null) User.error(this, "Method " + name + " is not declared"); this.declaration = d; if (d instanceof JavaMethod) { d.registerForDispatch(); if (TypeConstructors.isInterface(formals[0].tc)) User.error(this, notNull(name) + " is a native method. Dispatch can only occur if the first argument is not an interface."); } else if (! (d instanceof NiceMethod)) User.error(this, "Implementations can only be made for methods, but " + d.getName() + " is a function.\nIt was defined at:\n" + d.location()); this.buildSymbols(); } /** Returns the symbol of the method this declaration belongs to. */ private ?VarSymbol findSymbol(List<VarSymbol> symbols) { if (symbols.isEmpty()) return null; ?mlsub.typing.TypeConstructor[] additionalTags = cast(Pattern.getAdditionalTC(formals)); boolean hasAdditionalTags = additionalTags.any( ? TypeConstructor tc => tc != null); // Try to remember what caused the error when no symbol could be found. let errorList = new ErrorList(); for(let i = symbols.iterator(); i.hasNext();){ VarSymbol s = i.next(); if(s.getMethodDeclaration() == null) { i.remove(); continue; } MethodDeclaration m = s.getMethodDeclaration(); if (m.isIgnored()) { i.remove(); continue; } if (m.getArity() != formals.length || !(m instanceof NiceMethod || m instanceof JavaMethod)) { i.remove(); continue; } try{ int level; if (bossa.util.Debug.overloading) level = mlsub.typing.Typing.enter("Trying declaration " + m + " for method body "+name); else level = mlsub.typing.Typing.enter(); try{ mlsub.typing.Polytype t = m.getType(); mlsub.typing.Constraint.enter(t.getConstraint()); mlsub.typing.Monotype[] domain = t.domain(); for (int p = 0; p < domain.length; p++) try { formals[p].inDomain(domain[p]); } catch (TypingEx e) { errorList.add(m, new LocatedString("Pattern " + formals[p] + " is incompatible with " + domain[p], formals[p].location())); throw e; } } finally{ if (Typing.leave() != level) Internal.error("Enter/Leave error"); } } catch(TypingEx e){ if (bossa.util.Debug.overloading) bossa.util.Debug.println("Not the right choice :"+e); i.remove(); } catch(mlsub.typing.BadSizeEx e){ i.remove(); } } /* If the method are ambigious and the implementation has additional tc's * then try to find the most specific declaration(s) using these tc's * TODO: combine this code with removeNonMinimal in OverloadedSymbolExp */ if (symbols.size() > 1 && hasAdditionalTags) { // FIXME change to MethodSymbol[] once converted to nice. VarSymbol[] tempSymbols = symbols.toArray(); int size = symbols.size(); symbols = new LinkedList(); int len = formals.length; boolean[] removed = new boolean[size]; for (int m1 = 0; m1 < size; m1++) { mlsub.typing.Monotype[] dom1 = tempSymbols[m1].getMethodDeclaration().getType().domain(); for (int m2 = 0; m2 < size; m2++) if (m1 != m2) { boolean remove = true; boolean additionalsEqual = true; mlsub.typing.Monotype[] dom2 = tempSymbols[m2].getMethodDeclaration().getType().domain(); for (int i = 0; i < len; i++) if (additionalTags[i] != null) { try { this.domainMonotypeLeq(dom2[i], dom1[i]); try { this.domainMonotypeLeq(dom1[i], dom2[i]); } catch (TypingEx e) { additionalsEqual = false; } } catch(TypingEx e) { remove = false; break; } } //may not remove a method that is equal for the arguments with an additional. removed[m1] = remove && !additionalsEqual; if (removed[m1]) break; } if (!removed[m1]) symbols.add(tempSymbols[m1]); } } // Check that the non-dispatched parameter names match the declaration outer: for(let it = symbols.iterator(); it.hasNext();) { MethodDeclaration m = it.next().getMethodDeclaration(); if( m instanceof NiceMethod) { FormalParameters params = m.formalParameters(); for (int i = params.hasThis() ? 1 : 0; i < formals.length; i++) if (formals[i].atAny() && formals[i].name != null && params.getName(i) != null && !notNull(formals[i].name).toString().equals(params.getName(i).toString())) { errorList.add(m, new LocatedString("Parameter " + formals[i] + " should be called " + params.getName(i), formals[i].location())); it.remove(); continue outer; } } } removeNonMinimal(symbols); if (symbols.size() == 1) return symbols[0]; if (symbols.isEmpty()) { errorList.report(); // Default message in case we could not produce a better one. User.error(this, "No method called " + name + " is compatible with these patterns"); } String methods = ""; for (s : symbols) { MethodDeclaration m = s.getMethodDeclaration(); methods += m + " defined " + m.location() + "\n"; } throw User.error (this, "There is an ambiguity about which version " + " of the overloaded method \"" + name + "\" this alternative belongs to.\n" + "Try to use more patterns.\n\n" + "Possible methods:\n" + methods); } private void domainMonotypeLeq(mlsub.typing.Monotype m1, mlsub.typing.Monotype m2) { if (m1 == m2) return; nice.tools.typing.Types.setMarkedKind(m1); nice.tools.typing.Types.setMarkedKind(m2); mlsub.typing.Typing.leq(nice.tools.typing.Types.rawType(m1), nice.tools.typing.Types.rawType(m2)); } doResolve() { //Resolution of the body is delayed to enable overloading Pattern.resolve(notNull(typeScope), Node.getGlobalScope(), formals); symbols = notNull(scope).lookup(name); } void lateBuildScope() { Pattern.resolveValues(formals); let s = this.findSymbol(notNull(symbols)); symbols = null; if (s==null) throw User.error(this, name+" is not declared"); if (s.getMethodDeclaration() == null) User.error(this, name+" is not a method"); MethodDeclaration decl = s.getMethodDeclaration(); this.setDeclaration(decl); // Get type parameters if (binders != null) { let cst = notNull(declaration).getType().getConstraint(); if (! mlsub.typing.Constraint.hasBinders(cst)) User.error(name, "Method " + name + " has no type parameters"); try{ notNull(typeScope).addMappingsLS(cast(binders), notNull(cst).binders()); } catch(mlsub.typing.BadSizeEx e){ User.error(name, "Method " + name + " expects " + e.expected + " type parameters"); } catch(TypeScope.DuplicateName e) { User.error(this, e); } } try{ for (f : formals) { let tc = f.getRuntimeTC(); if (tc != null) notNull(typeScope).addSymbol(tc); } } catch(TypeScope.DuplicateName e) { User.error(this, e); } if (! notNull(declaration).specializesMethods()) this.removeUnnecessaryDispatch(); } private void removeUnnecessaryDispatch() { boolean entered = false; if (mlsub.typing.Constraint.hasBinders(notNull(declaration).getType().getConstraint())) { mlsub.typing.Typing.enter(); entered = true; } try { try { mlsub.typing.Constraint.enter(notNull(declaration).getType().getConstraint()); Typing.implies(); mlsub.typing.Monotype[] domain = notNull(declaration).getType().domain(); for (int n = 0; n < formals.length; n++) { let tc = nice.tools.typing.Types.rawType(domain[n]).head(); if (formals[n].tc != null) formals[n] = formals[n].setDomainEq(tc != null && nice.tools.typing.Types.isSure(domain[n]) && Typing.testLeq(tc, formals[n].tc)); } } finally { if (entered) Typing.leave(); } } catch(TypingEx ex) { Internal.warning(ex.toString()); } } typecheck() { boolean errorFound = false; int level; if (bossa.util.Debug.typing) level = Typing.enter("METHOD BODY " + this + "\n\n"); else level = Typing.enter(); try { try { try { mlsub.typing.Constraint.enter(notNull(declaration).getType().getConstraint()); } catch(TypingEx e){ throw User.error(name, "the constraint will never be satisfied", ": "+e.getMessage()); } // Introduce the types of the arguments mlsub.typing.Monotype[] monotypes = MonoSymbol.getMonotype(parameters); for (int n = 0; n < formals.length; n++) { let runtimeTC = formals[n].getRuntimeTC(); if (runtimeTC == null) mlsub.typing.Typing.introduce(monotypes[n]); else mlsub.typing.Typing.introduce(runtimeTC); } mlsub.typing.Monotype[] domain = notNull(declaration).getType().domain(); for(int n = 0; n < formals.length; n++) { let tc = nice.tools.typing.Types.rawType(domain[n]).head(); if (formals[n].tc != null) formals[n].setDomainTC(tc); } // The arguments are specialized by the patterns try { Pattern.in(monotypes, formals); } catch(TypingEx e){ throw User.error(name,"The patterns are not correct", e); } // The arguments have types below the method declaration domain for (int i = 0; i < monotypes.length; i++) try { mlsub.typing.Typing.leq(monotypes[i], domain[i]); } catch(TypingEx e) { /* This type error originates from an inadequation between the pattern and the domain. The parameter types are just variables that connected the two. */ throw User.error(formals[i], "Pattern " + formals[i] + " is incompatible with type " + domain[i]); } try { nice.tools.code.Types.setBytecodeType(monotypes); Typing.implies(); } catch(TypingEx e) { throw User.error(name, "Type error in method body \""+name+"\":\n"+e); } Node.currentFunction = this; if (this.hasThis()) Node.thisExp = new SymbolExp(notNull(parameters)[0], this.location()); typecheck(body); } catch(UserError ex){ module.compilation().error(ex); errorFound = true; } } finally { Node.currentFunction = null; Node.thisExp = null; try { if (Typing.leave() != level) Internal.error("Unmatching enter/leave"); } catch(TypingEx e){ if (! errorFound) User.error(this, "Type error in method "+name, ": "+e); } } // If the method we implement specialize others, then we cannot // omit the patterns, as we do handle only a special case of those // more general methods. if (notNull(declaration).specializesMethods()) this.addPatterns(); } printInterface(s) { // Not exported } javaArgTypes() { gnu.bytecode.Type[] res = cast(new gnu.bytecode.Type[notNull(parameters).length]); for(int n = 0; n < notNull(parameters).length; n++) res[n] = formals[n].atNull() ? nice.tools.code.Types.javaType(PrimitiveType.nullTC) : formals[n].tc == bossa.syntax.PrimitiveType.arrayTC ? nice.tools.code.SpecialArray.unknownTypeArray() : nice.tools.code.Types.javaType(notNull(parameters)[n].getMonotype()); return res; } gnu.expr.Expression[] compiledArguments() { return notNull(parameters).map(VarSymbol s => s.compile()); } toString() = notNull(name) + "(" + Util.map("", ", ", "", formals) + ")"; } /** * Create a method alternative. * * @param name the name of the method. * @param binders * used to rebind the type parameters of the method definition. * Null if one doesn't want to rebind them. * @param newConstraint list of AtomicConstraint * @param formals list of Pattern * @param body s statement representing the body of the method. */ public MethodBodyDefinition createMethodBodyDefinition(?NiceClass container, LocatedString name, ?Collection<LocatedString> binders, List<Pattern> formals, Statement body) { let res = new MethodBodyDefinition(name, body, makeFormals(formals, container, notNull(name.location())), binders: binders); res.declaration = null; return res; } private Pattern[] makeFormals(List<Pattern> formals, ?NiceClass container, bossa.util.Location loc) { if (container == null) return formals.toArray(); List<Pattern> res = new ArrayList(); res.add(createPattern(new LocatedString("this", loc), new TypeIdent(container.getName()))); res.addAll(formals); return res.toArray(); } private class ErrorList { private List<LocatedString> errors = new ArrayList(); boolean multipleErrors = false; void add(MethodDeclaration method, LocatedString message) { errors.add(message); } void report() { if (errors.size() == 1) { let message = errors[0]; throw new UserError(message.location(), message.toString()); } } } |
From: Arjan B. <ar...@us...> - 2004-11-26 20:26:14
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6195/F:/nice/src/bossa/syntax Modified Files: AST.java Definition.java dispatch.java.bootstrap enum.nice globalvar.nice tools.nice Added Files: ast.nice Log Message: Converted AST. Index: Definition.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Definition.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Definition.java 25 Nov 2004 19:28:18 -0000 1.25 --- Definition.java 26 Nov 2004 20:26:02 -0000 1.26 *************** *** 78,96 **** } - boolean isGlobalVarDeclaration() - { - return false; - } - - boolean isEnumDefinition() - { - return false; - } - - TypeDefinition getEnumClass() - { - return null; - } - /**************************************************************** * Name and location of the definition --- 78,81 ---- Index: AST.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/AST.java,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** AST.java 25 Nov 2004 19:28:17 -0000 1.61 --- AST.java 26 Nov 2004 20:26:01 -0000 1.62 *************** *** 2,6 **** /* N I C E */ /* A high-level object-oriented research language */ ! /* (c) Daniel Bonniot 2000 */ /* */ /* This program is free software; you can redistribute it and/or modify */ --- 2,6 ---- /* 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 */ *************** *** 21,39 **** @see Definition - - @version $Date$ - @author Daniel Bonniot (d.b...@ma...) */ ! public class AST extends Node { ! public AST(Module module, List defs) { ! super(defs,Node.global); ! if (children == null) ! children = new LinkedList(); ! ! this.module = module; ! ! findElements(); } --- 21,30 ---- @see Definition */ ! public abstract class AST extends Node { ! AST(List children, int propagate) { ! super(children, propagate); } *************** *** 43,193 **** } ! private void findElements() ! { ! ArrayList classes = new ArrayList(children.size()); ! ArrayList methods = new ArrayList(children.size()); ! ArrayList globals = new ArrayList(10); ! ArrayList customConstructors = new ArrayList(10); ! ArrayList methodImplementations = new ArrayList(10); ! ! for(Iterator i = children.iterator(); i.hasNext();) ! { ! Definition node = (Definition)i.next(); ! if (node instanceof TypeDefinition) ! classes.add(node); ! else if (node instanceof CustomConstructor) ! { ! customConstructors.add(node); ! methods.add(node); ! } ! else if (node instanceof MethodDeclaration) ! methods.add(node); ! else if (node instanceof MethodBodyDefinition) ! methodImplementations.add(node); ! else if (node.isEnumDefinition()) ! classes.add(node.getEnumClass()); ! else if (node.isGlobalVarDeclaration()) ! globals.add(node); ! else if (node instanceof DefaultMethodImplementation) ! methods.add(((DefaultMethodImplementation) node).getDeclaration()); ! } ! ! this.classes = (TypeDefinition[]) ! classes.toArray(new TypeDefinition[classes.size()]); ! ! this.methods = (MethodDeclaration[]) ! methods.toArray(new MethodDeclaration[methods.size()]); ! ! this.globals = (Definition[]) ! globals.toArray(new Definition[globals.size()]); ! ! this.customConstructors = (CustomConstructor[]) ! customConstructors.toArray(new CustomConstructor[customConstructors.size()]); ! ! this.methodImplementations = (MethodBodyDefinition[]) ! methodImplementations.toArray(new MethodBodyDefinition[methodImplementations.size()]); ! } ! ! public void buildScope() ! { ! buildScope(module); ! } ! ! private void resolve(Node n) ! { ! try{ ! n.doResolve(); ! } ! catch(UserError ex){ ! module.compilation().error(ex); ! } ! } ! ! public void resolveScoping() ! { ! Node.setModule(module); ! ! // Resolve custom constructors early, classes depend on them ! for(int i = 0; i < customConstructors.length; i++) ! resolve(customConstructors[i]); ! ! // Classes are then resolved, since code can depend on them ! for(int i = 0; i < classes.length; i++) ! resolve(classes[i]); ! ! // Resolve all the rest ! for(Iterator i = children.iterator();i.hasNext();) ! { ! Node n = (Node) i.next(); ! resolve(n); ! } ! ! module.compilation().exitIfErrors(); ! } ! ! public void typedResolve() ! { ! Node.setModule(module); ! ! for (int i = 0; i < methods.length; i++) ! try{ ! methods[i].typedResolve(); ! } ! catch(UserError ex){ ! module.compilation().error(ex); ! } ! ! for (int i = 0; i < methodImplementations.length; i++) ! try{ ! methodImplementations[i].lateBuildScope(); ! } ! catch(UserError ex){ ! module.compilation().error(ex); ! } ! ! module.compilation().exitIfErrors(); ! } ! ! public void localResolve() ! { ! Node.setModule(module); ! ! for (Iterator i = children.iterator(); i.hasNext();) ! { ! Definition d = (Definition) i.next(); ! try{ ! d.resolveBody(); ! } ! catch(UserError ex){ ! module.compilation().error(ex); ! } ! } ! ! module.compilation().exitIfErrors(); ! ! for (int i = 0; i < classes.length; i++) ! classes[i].precompile(); ! } ! ! public void typechecking(boolean compiling) ! { ! Node.setModule(module); ! ! // Classes are typechecked first, since code can depend on them. ! for (int i = 0; i < classes.length; i++) ! classes[i].typecheckClass(); ! if (! compiling) ! { ! for (int i = 0; i < methods.length; i++) ! methods[i].typecheckCompiled(); ! return; ! } ! doTypecheck(); ! module.compilation().exitIfErrors(); ! } public void printInterface(java.io.PrintWriter s) --- 34,46 ---- } ! abstract public void buildScope(); ! abstract public void resolveScoping(); ! abstract public void typedResolve(); ! abstract public void localResolve(); ! abstract public void typechecking(boolean compiling); public void printInterface(java.io.PrintWriter s) *************** *** 197,228 **** } ! /** ! @param generateCode ! false if the current module was already compiled and up-to-date. ! */ ! public void compile(boolean generateCode) ! { ! if (! generateCode) ! { ! for (int i = 0; i < classes.length; i++) ! classes[i].recompile(); ! } ! else ! { ! // Globals are compiled first, so that we can find out their ! // dependencies, and initialize them in the right order. ! for (int i = 0; i < globals.length; i++) ! globals[i].compile(); ! ! for (Iterator i = children.iterator();i.hasNext();) ! ((Definition) i.next()).compile(); ! } ! } - public String toString() - { - return "Abstract Syntax Tree (" + numberOfDeclarations() +" declarations)"; - } - public int numberOfDeclarations() { --- 50,55 ---- } ! abstract public void compile(boolean generateCode); public int numberOfDeclarations() { *************** *** 230,239 **** } - private Module module; - private TypeDefinition[] classes; - private MethodDeclaration[] methods; - private MethodBodyDefinition[] methodImplementations; - private Definition[] globals; - private CustomConstructor[] customConstructors; } --- 57,60 ---- Index: dispatch.java.bootstrap =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/dispatch.java.bootstrap,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** dispatch.java.bootstrap 25 Nov 2004 19:28:18 -0000 1.27 --- dispatch.java.bootstrap 26 Nov 2004 20:26:02 -0000 1.28 *************** *** 95,98 **** --- 95,101 ---- { return null; } + public static AST createAST(Module module, List defs) + { return null; } + static bossa.util.UserError unknownIdent(LocatedString ident) { Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** tools.nice 25 Nov 2004 19:28:19 -0000 1.63 --- tools.nice 26 Nov 2004 20:26:02 -0000 1.64 *************** *** 245,248 **** --- 245,249 ---- MethodBodyDefinition MethodBodyDefinition(NiceClass, LocatedString, ?Collection<LocatedString>, List<Pattern>, Statement) = native new MethodBodyDefinition(NiceClass, LocatedString, Collection, List, Statement); ?FormalParameters getFormalParameters(VarSymbol) = native FormalParameters VarSymbol.getFormalParameters(); + List<Node> children(Node) = native Node.children; // Retypings needed since java types are not strict. Index: enum.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/enum.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** enum.nice 25 Nov 2004 19:28:18 -0000 1.3 --- enum.nice 26 Nov 2004 20:26:02 -0000 1.4 *************** *** 34,40 **** } - isEnumDefinition() = true; - getEnumClass() = classDef; - resolve() { --- 34,37 ---- Index: globalvar.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/globalvar.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** globalvar.nice 7 Nov 2004 01:07:26 -0000 1.1 --- globalvar.nice 26 Nov 2004 20:26:02 -0000 1.2 *************** *** 25,30 **** boolean constant; - isGlobalVarDeclaration() = true; - resolve() { --- 25,28 ---- --- NEW FILE: ast.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.*; /** The Abstract Syntax Tree : a collection of definitions. @see Definition */ public class CAST extends AST { private Module module; private ArrayList<TypeDefinition> classes = new ArrayList(); private ArrayList<MethodDeclaration> methods = new ArrayList(); private ArrayList<MethodBodyDefinition> methodImplementations = new ArrayList(); private ArrayList<GlobalVarDeclaration> globals = new ArrayList(); private ArrayList<CustomConstructor> customConstructors = new ArrayList(); void findElements() { for (node : children) { if (node instanceof TypeDefinition) classes.add(node); else if (node instanceof CustomConstructor) { customConstructors.add(node); methods.add(node); } else if (node instanceof MethodDeclaration) methods.add(node); else if (node instanceof MethodBodyDefinition) methodImplementations.add(node); else if (node instanceof EnumDefinition) classes.add(node.classDef); else if (node instanceof GlobalVarDeclaration) globals.add(node); else if (node instanceof DefaultMethodImplementation) methods.add(node.getDeclaration()); } } buildScope() { this.buildScope(module); } private void resolve(Node n) { try { n.doResolve(); } catch(UserError ex) { module.compilation().error(ex); } } resolveScoping() { Node.setModule(module); // Resolve custom constructors early, classes depend on them for (cc : customConstructors) this.resolve(cc); // Classes are then resolved, since code can depend on them for (c : classes) this.resolve(c); // Resolve all the rest for (node : children) this.resolve(node); module.compilation().exitIfErrors(); } typedResolve() { Node.setModule(module); for (m : methods) try { m.typedResolve(); } catch(UserError ex) { module.compilation().error(ex); } for (mi : methodImplementations) try { mi.lateBuildScope(); } catch(UserError ex) { module.compilation().error(ex); } module.compilation().exitIfErrors(); } localResolve() { Node.setModule(module); for (d : children) try { assert (d instanceof Definition); d.resolveBody(); } catch(UserError ex) { module.compilation().error(ex); } module.compilation().exitIfErrors(); for (c : classes) c.precompile(); } typechecking(compiling) { Node.setModule(module); // Classes are typechecked first, since code can depend on them. for (c : classes) c.typecheckClass(); if (! compiling) { for (m : methods) m.typecheckCompiled(); return; } this.doTypecheck(); module.compilation().exitIfErrors(); } /** @param generateCode false if the current module was already compiled and up-to-date. */ compile(generateCode) { if (! generateCode) { for (c : classes) c.recompile(); } else { // Globals are compiled first, so that we can find out their // dependencies, and initialize them in the right order. for (g : globals) g.compile(); for (d : children) { assert (d instanceof Definition); d.compile(); } } } toString() = "Abstract Syntax Tree (" + this.numberOfDeclarations() +" declarations)"; } public AST createAST(Module module, ?List<Definition> defs) { let res = new CAST(defs || new ArrayList(), Node.global, module: module); res.findElements(); return res; } |
From: Arjan B. <ar...@us...> - 2004-11-26 20:26:12
|
Update of /cvsroot/nice/Nice/src/bossa/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6195/F:/nice/src/bossa/modules Modified Files: Package.java Log Message: Converted AST. Index: Package.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/Package.java,v retrieving revision 1.123 retrieving revision 1.124 diff -C2 -d -r1.123 -r1.124 *** Package.java 25 Nov 2004 19:28:19 -0000 1.123 --- Package.java 26 Nov 2004 20:26:02 -0000 1.124 *************** *** 120,124 **** definitions = new ArrayList(); source.getDefinitions(definitions, shouldReload); ! this.ast = new AST(this, definitions); definitions = null; compilation.addNumberOfDeclarations(ast.numberOfDeclarations()); --- 120,124 ---- definitions = new ArrayList(); source.getDefinitions(definitions, shouldReload); ! this.ast = bossa.syntax.dispatch.createAST(this, definitions); definitions = null; compilation.addNumberOfDeclarations(ast.numberOfDeclarations()); |
From: Francis B. <fb...@us...> - 2004-11-26 14:55:09
|
Update of /cvsroot/nice/Nice/src/nice/tools/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1388/src/nice/tools/doc Modified Files: htmlwriter.nice Added Files: utilities.nice Log Message: Just trying to rationalise the source code a bit Index: htmlwriter.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/doc/htmlwriter.nice,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** htmlwriter.nice 25 Nov 2004 19:28:17 -0000 1.26 --- htmlwriter.nice 26 Nov 2004 14:54:56 -0000 1.27 *************** *** 375,445 **** } - /** Converts a String that may contain characters such as '<' to one that will display - * properly in html. Submitted by S. Bayer to http://www.rgagnon.com/javadetails/java-0306.html, - * although I've made some changes. - */ - String htmlEncode(String s) { - StringBuffer sb = new StringBuffer(s.length()); - //true if last char was blank - this is for handling non-breaking spaces - boolean lastWasBlankChar = false; - - for (int i = 0; i < s.length(); i++) { - char c = s.charAt(i); - if (c == ' ') { - // blank gets extra work, - // this solves the problem you get if you replace all - // blanks with , if you do that you lose - // word breaking - if (lastWasBlankChar) { - lastWasBlankChar = false; - sb.append(" "); - } - else { - lastWasBlankChar = true; - sb.append(' '); - } - } - else { - lastWasBlankChar = false; - // HTML Special Chars - if (c == '"') - sb.append("""); - else if (c == '&') - sb.append("&"); - else if (c == '<') - sb.append("<"); - else if (c == '>') - sb.append(">"); - else if (c == '\n') - // Handle Newline - sb.append("<br/>"); - else { - //char and int are not related in nice, so we can't do a direct cast - //hence, we use int(c) instead of (int)c - int ci = int(c); - /*This was originally 160 in S. Bayer version, but I couldn't see the sense of that - *so I changed it to 128, as 127 is the maximum value of an ascii character - */ - if(ci < 128) - // nothing special only 7 Bit - sb.append(c); - else { - // Not 7 Bit use the unicode system - sb.append("&#"); - sb.append(ci); - sb.append(';'); - } - } - } - } - return sb.toString(); - } - - /** Convenience method that converts a LocatedString to a String and then htmlEncodes it. - * @param s the string to encode - */ - String htmlEncode(LocatedString s) { - return htmlEncode(s.toString()); - } /** Returns a string containing everything required up to and including the <body> tag --- 375,378 ---- *************** *** 499,532 **** } - /** - * Checks a filename to make sure it doesn't contain funny characters. - */ - String escapeFilename(String filename) { - // Make sure we don't generate another index.html, as it would overwrite - // the index (with care to case-insensitive filesystems) - if (filename.equalsIgnoreCase("index")) - // XXX: we should make sure this is unique - return "_index"; - - char[] chars = filename.toCharArray(); - StringBuffer buf = new StringBuffer(); - for(char c : chars) { - if(!Character.isLetterOrDigit(c)) { - buf.append('$'); - buf.append(hexEncode(int(c))); - } - else { - buf.append(c); - } - } - return buf.toString(); - } - - String hexEncode(int i) { - String num = Integer.toHexString(i); - for(int pad = num.length(); pad < 4; pad++) - num = "0" + num; - return num.toUpperCase(); - } /** --- 432,435 ---- *************** *** 624,626 **** return buffer.toString(); ! } \ No newline at end of file --- 527,529 ---- return buffer.toString(); ! } --- NEW FILE: utilities.nice --- package nice.tools.doc; /* * Provides miscellaneous methods for tasks such as htmlencoding and * escaping filenames * @author Francis Barber * @date 26/11/2004 */ /** * Checks a filename to make sure it doesn't contain funny characters. */ String escapeFilename(String filename) { // Make sure we don't generate another index.html, as it would overwrite // the index (with care to case-insensitive filesystems) if (filename.equalsIgnoreCase("index")) // XXX: we should make sure this is unique return "_index"; char[] chars = filename.toCharArray(); StringBuffer buf = new StringBuffer(); for(char c : chars) { if(!Character.isLetterOrDigit(c)) { buf.append('$'); buf.append(hexEncode(int(c))); } else { buf.append(c); } } return buf.toString(); } String hexEncode(int i) { String num = Integer.toHexString(i); for(int pad = num.length(); pad < 4; pad++) num = "0" + num; return num.toUpperCase(); } /** Converts a String that may contain characters such as '<' to one that will display * properly in html. Submitted by S. Bayer to http://www.rgagnon.com/javadetails/java-0306.html, * although I've made some changes. */ String htmlEncode(String s) { StringBuffer sb = new StringBuffer(s.length()); //true if last char was blank - this is for handling non-breaking spaces boolean lastWasBlankChar = false; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c == ' ') { // blank gets extra work, // this solves the problem you get if you replace all // blanks with , if you do that you lose // word breaking if (lastWasBlankChar) { lastWasBlankChar = false; sb.append(" "); } else { lastWasBlankChar = true; sb.append(' '); } } else { lastWasBlankChar = false; // HTML Special Chars if (c == '"') sb.append("""); else if (c == '&') sb.append("&"); else if (c == '<') sb.append("<"); else if (c == '>') sb.append(">"); else if (c == '\n') // Handle Newline sb.append("<br/>"); else { //char and int are not related in nice, so we can't do a direct cast //hence, we use int(c) instead of (int)c int ci = int(c); /*This was originally 160 in S. Bayer version, but I couldn't see the sense of that *so I changed it to 128, as 127 is the maximum value of an ascii character */ if(ci < 128) // nothing special only 7 Bit sb.append(c); else { // Not 7 Bit use the unicode system sb.append("&#"); sb.append(ci); sb.append(';'); } } } } return sb.toString(); } /** Convenience method that converts a LocatedString to a String and then htmlEncodes it. * @param s the string to encode */ String htmlEncode(LocatedString s) { return htmlEncode(s.toString()); } |
From: Arjan B. <ar...@us...> - 2004-11-25 19:30:22
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7969/F:/nice/src/bossa/syntax Added Files: TypeDefinition.java Log Message: Converted ClassDefinition. (patch by Luc Perrin) --- NEW FILE: TypeDefinition.java --- /**************************************************************************/ /* 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 gnu.bytecode.Type; import mlsub.typing.Interface; import mlsub.typing.TypeConstructor; /** Abstract syntax for a type definition. */ public abstract class TypeDefinition extends MethodContainer { TypeDefinition(LocatedString name, int propagate, Constraint classConstraint) { super(name, propagate, classConstraint); } public abstract ClassImplementation getImplementation( ); public abstract void setImplementation( ClassImplementation impl ); public abstract void precompile(); public abstract void typecheckClass(); public abstract void recompile(); public abstract mlsub.typing.Polytype getConstrainedType(); public abstract mlsub.typing.Interface getAssociatedInterface(); public abstract TypeScope getLocalScope(); public abstract TypeConstructor getTC(); public abstract void setJavaType(Type javaType); public abstract Type getJavaType(); public abstract boolean isConcrete(); public abstract void addInterfaceImplementation(Interface interfaceITF); } |
From: Arjan B. <ar...@us...> - 2004-11-25 19:28:58
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7541/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Converted ClassDefinition. (patch by Luc Perrin) Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.274 retrieving revision 1.275 diff -C2 -d -r1.274 -r1.275 *** Parser.jj 21 Nov 2004 18:33:17 -0000 1.274 --- Parser.jj 25 Nov 2004 19:28:12 -0000 1.275 *************** *** 1006,1012 **** // The constraint prefixing the class keyword is optional // It is useful for complex constraints ! ClassDefinition classDefinition(Constraint cst, List definitions, boolean storeDocString): { ! ClassDefinition res; LocatedString name; MethodContainer.Constraint parameters = null; --- 1006,1012 ---- // The constraint prefixing the class keyword is optional // It is useful for complex constraints ! TypeDefinition typeDefinition(Constraint cst, List definitions, boolean storeDocString): { ! TypeDefinition res; LocatedString name; MethodContainer.Constraint parameters = null; *************** *** 1025,1029 **** [ "implements" imp=interfaces() ] [ "finally" "implements" abs=interfaces() ] ! { res = ClassDefinition.makeInterface (name, parameters, typeParametersVariances, ext, imp, abs); } | --- 1025,1029 ---- [ "implements" imp=interfaces() ] [ "finally" "implements" abs=interfaces() ] ! { res = bossa.syntax.dispatch.makeInterface (name, parameters, typeParametersVariances, ext, imp, abs); } | *************** *** 1040,1044 **** [ "implements" imp=interfaces() ] [ "finally" "implements" abs=interfaces() ] ! { res = ClassDefinition.makeClass (name, isFinal,isAbstract, --- 1040,1044 ---- [ "implements" imp=interfaces() ] [ "finally" "implements" abs=interfaces() ] ! { res = bossa.syntax.dispatch.makeClass (name, isFinal,isAbstract, *************** *** 1564,1568 **** | LOOKAHEAD ( "abstract" "interface" ) res=interfaceDefinition(cst, definitions) ! | res=classDefinition(cst, definitions, storeDocString) | res=methodDeclaration(cst, false) ) --- 1564,1568 ---- | LOOKAHEAD ( "abstract" "interface" ) res=interfaceDefinition(cst, definitions) ! | res=typeDefinition(cst, definitions, storeDocString) | res=methodDeclaration(cst, false) ) |
From: Arjan B. <ar...@us...> - 2004-11-25 19:28:58
|
Update of /cvsroot/nice/Nice/src/nice/tools/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7541/F:/nice/src/nice/tools/doc Modified Files: document.nice htmlwriter.nice Log Message: Converted ClassDefinition. (patch by Luc Perrin) Index: htmlwriter.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/doc/htmlwriter.nice,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** htmlwriter.nice 10 Oct 2004 13:19:32 -0000 1.25 --- htmlwriter.nice 25 Nov 2004 19:28:17 -0000 1.26 *************** *** 16,20 **** //println("Formal Parameters: " + m.formalParameters()); ! import bossa.syntax.*; import java.util.*; import java.text.*; --- 16,20 ---- //println("Formal Parameters: " + m.formalParameters()); ! import bossa.syntax; import java.util.*; import java.text.*; *************** *** 41,45 **** } ! write(ClassDefinition.Class c, packageName) { // Here we handle classes --- 41,45 ---- } ! write(TypeDefinition c, packageName) { // Here we handle classes *************** *** 66,71 **** //Print hierarchy ! ArrayList<ClassDefinition.Class> list = new ArrayList(); ! ?ClassDefinition.Class superClass = c.getSuperClassDefinition(); while(superClass != null) { list.add(superClass); --- 66,71 ---- //Print hierarchy ! ArrayList<TypeDefinition> list = new ArrayList(); ! ?ClassDefinition superClass = c.getSuperClassDefinition(); while(superClass != null) { list.add(superClass); *************** *** 91,99 **** //Implemented interfaces ! ClassDefinition.Interface[?] interfaces = c.getImplementedInterfaces(); if(interfaces != null && interfaces.length > 0) { writer.write("<b>Implemented interfaces:</b>\n"); writer.write("<ul>\n"); ! interfaces.foreach(ClassDefinition.Interface i => writer.write("<li>" + htmlEncode(i.getName()) + "</li>\n")); writer.write("</ul>\n"); --- 91,99 ---- //Implemented interfaces ! InterfaceDefinition[?] interfaces = c.getImplementedInterfaces(); if(interfaces != null && interfaces.length > 0) { writer.write("<b>Implemented interfaces:</b>\n"); writer.write("<ul>\n"); ! interfaces.foreach(InterfaceDefinition i => writer.write("<li>" + htmlEncode(i.getName()) + "</li>\n")); writer.write("</ul>\n"); *************** *** 247,251 **** for(Definition d : p.getDefinitions().definitions()) { //we only display information about these types ! if(d instanceof ClassDefinition.Class || d instanceof MethodDeclaration || d instanceof DefaultMethodImplementation || --- 247,251 ---- for(Definition d : p.getDefinitions().definitions()) { //we only display information about these types ! if(d instanceof TypeDefinition || d instanceof MethodDeclaration || d instanceof DefaultMethodImplementation || *************** *** 307,311 **** //we need to separate class, methods, and global variables ! (ArrayList<ClassDefinition.Class> classes, ArrayList<MethodDeclaration> methods, ArrayList<GlobalVarDeclaration> globalVars) = separateDefinitions(p.getDefinitions().definitions()); --- 307,311 ---- //we need to separate class, methods, and global variables ! (ArrayList<TypeDefinition> classes, ArrayList<MethodDeclaration> methods, ArrayList<GlobalVarDeclaration> globalVars) = separateDefinitions(p.getDefinitions().definitions()); *************** *** 315,319 **** writer.write("<b>Classes:</b>\n"); writer.write("<ul>\n"); ! for(ClassDefinition.Class c : classes) { String s = c.getName().toString(); int index = s.lastIndexOf('.'); --- 315,319 ---- writer.write("<b>Classes:</b>\n"); writer.write("<ul>\n"); ! for(TypeDefinition c : classes) { String s = c.getName().toString(); int index = s.lastIndexOf('.'); *************** *** 534,545 **** * method declarations, and global variable declarations. */ ! (ArrayList<ClassDefinition.Class>, ArrayList<MethodDeclaration>, ArrayList<GlobalVarDeclaration>) separateDefinitions(List<Definition> definitions) { ! ArrayList<ClassDefinition.Class> classes = new ArrayList(); ArrayList<MethodDeclaration> methods = new ArrayList(); ArrayList<GlobalVarDeclaration> globalVars = new ArrayList(); for(Definition d : definitions) { ! if(d instanceof ClassDefinition.Class) { classes.add(d); } --- 534,545 ---- * method declarations, and global variable declarations. */ ! (ArrayList<TypeDefinition>, ArrayList<MethodDeclaration>, ArrayList<GlobalVarDeclaration>) separateDefinitions(List<Definition> definitions) { ! ArrayList<TypeDefinition> classes = new ArrayList(); ArrayList<MethodDeclaration> methods = new ArrayList(); ArrayList<GlobalVarDeclaration> globalVars = new ArrayList(); for(Definition d : definitions) { ! if(d instanceof TypeDefinition) { classes.add(d); } *************** *** 568,572 **** StringBuffer buffer = new StringBuffer(); //we need to separate class, methods, and global variables ! (ArrayList<ClassDefinition.Class> classes, ArrayList<MethodDeclaration> methods, ArrayList<GlobalVarDeclaration> globalVars) = separateDefinitions(definitions); --- 568,572 ---- StringBuffer buffer = new StringBuffer(); //we need to separate class, methods, and global variables ! (ArrayList<TypeDefinition> classes, ArrayList<MethodDeclaration> methods, ArrayList<GlobalVarDeclaration> globalVars) = separateDefinitions(definitions); *************** *** 582,586 **** buffer.append(" <span id=\"" file.getName() "Classes\" style=\"display: none;\">\n"); buffer.append(" <ul>\n"); ! for(ClassDefinition.Class c : classes) { String s = c.getName().toString(); int index = s.lastIndexOf('.'); --- 582,586 ---- buffer.append(" <span id=\"" file.getName() "Classes\" style=\"display: none;\">\n"); buffer.append(" <ul>\n"); ! for(TypeDefinition c : classes) { String s = c.getName().toString(); int index = s.lastIndexOf('.'); Index: document.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/doc/document.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** document.nice 31 Jul 2004 08:10:05 -0000 1.3 --- document.nice 25 Nov 2004 19:28:16 -0000 1.4 *************** *** 7,11 **** */ ! import bossa.syntax.*; class Documenter { --- 7,11 ---- */ ! import bossa.syntax; class Documenter { *************** *** 37,41 **** } ! document(ClassDefinition.Class c) { // Here we handle classes --- 37,41 ---- } ! document(TypeDefinition c) { // Here we handle classes *************** *** 47,53 **** println(" extends " + superClass.getName()); ! ClassDefinition.Interface[?] interfaces = c.getImplementedInterfaces(); if (interfaces != null) ! interfaces.foreach(ClassDefinition.Interface i => println(" implements " + i.getName())); } --- 47,53 ---- println(" extends " + superClass.getName()); ! InterfaceDefinition[?] interfaces = c.getImplementedInterfaces(); if (interfaces != null) ! interfaces.foreach(InterfaceDefinition i => println(" implements " + i.getName())); } |
From: Arjan B. <ar...@us...> - 2004-11-25 19:28:57
|
Update of /cvsroot/nice/Nice/src/mlsub/typing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7541/F:/nice/src/mlsub/typing Modified Files: Enumeration.java Log Message: Converted ClassDefinition. (patch by Luc Perrin) Index: Enumeration.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/Enumeration.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Enumeration.java 14 Oct 2004 20:35:34 -0000 1.15 --- Enumeration.java 25 Nov 2004 19:28:16 -0000 1.16 *************** *** 367,371 **** TypeConstructor sol) { ! bossa.syntax.ClassDefinition def = bossa.syntax.ClassDefinition.get(sol); if (def == null) --- 367,371 ---- TypeConstructor sol) { ! bossa.syntax.TypeDefinition def = bossa.syntax.dispatch.getTypeDefinition(sol); if (def == null) |
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); |