nice-commit Mailing List for The Nice Programming Language (Page 28)
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: Daniel B. <bo...@us...> - 2004-12-17 17:38:13
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29221/src/bossa/syntax Modified Files: customConstructor.nice Log Message: Removed an explicit use of the 'dispatch' class in Nice code. Index: customConstructor.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/customConstructor.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** customConstructor.nice 16 Dec 2004 16:21:07 -0000 1.2 --- customConstructor.nice 17 Dec 2004 17:38:01 -0000 1.3 *************** *** 36,40 **** new mlsub.typing.FunType(this.getArgTypes(), nice.tools.typing.PrimitiveType.voidType)); notNull(classe).addConstructorCallSymbol( ! dispatch.createConstructorCallSymbol(this, name, type)); } --- 36,40 ---- new mlsub.typing.FunType(this.getArgTypes(), nice.tools.typing.PrimitiveType.voidType)); notNull(classe).addConstructorCallSymbol( ! createConstructorCallSymbol(this, name, type)); } |
From: Arjan B. <ar...@us...> - 2004-12-17 04:09:53
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31273/F:/nice/src/bossa/syntax Modified Files: tools.nice Log Message: Missing retyping. Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -d -r1.75 -r1.76 *** tools.nice 16 Dec 2004 23:40:00 -0000 1.75 --- tools.nice 17 Dec 2004 04:09:42 -0000 1.76 *************** *** 285,288 **** --- 285,289 ---- ?mlsub.typing.TypeSymbol lookup(TypeMap, LocatedString) = native mlsub.typing.TypeSymbol TypeMap.lookup(LocatedString); ?mlsub.typing.TypeSymbol lookup(TypeMap, String) = native mlsub.typing.TypeSymbol TypeMap.lookup(String); + void substitute(bossa.syntax.FormalParameters, Map<java.lang.String, bossa.syntax.Monotype>) = native void FormalParameters.substitute(Map); // Retypings needed since java types are not strict. |
From: Arjan B. <ar...@us...> - 2004-12-16 23:40:16
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6714/F:/nice/src/bossa/syntax Modified Files: analyse.nice tools.nice Removed Files: TypeMaper.java Log Message: Converted TypeMaper. Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.74 retrieving revision 1.75 diff -C2 -d -r1.74 -r1.75 *** tools.nice 16 Dec 2004 16:21:07 -0000 1.74 --- tools.nice 16 Dec 2004 23:40:00 -0000 1.75 *************** *** 171,174 **** --- 171,193 ---- } + /** + A mapping from type names to type symbols. + + */ + public class TypeMaper implements TypeMap + { + nice.tools.ast.SymbolTable<mlsub.typing.TypeSymbol> inner; + TypeScope global; + + lookup(LocatedString name) = this.lookup(name.toString(), name.location()); + + lookup(String name) = this.lookup(name, null); + + public ?mlsub.typing.TypeSymbol lookup(String name, ?bossa.util.Location loc) + { + return inner.get(name) || global.lookup(name, loc); + } + } + // For bootstrap void _printStackTraceWithSourceInfo(Throwable t) = *************** *** 264,267 **** --- 283,288 ---- bossa.syntax.Monotype[] substitute(Map<TypeIdent,bossa.syntax.Monotype>,bossa.syntax.Monotype[]) = native bossa.syntax.Monotype[] bossa.syntax.Monotype.substitute(Map,bossa.syntax.Monotype[]); Monotype[?] types(FormalParameters) = native Monotype[] FormalParameters.types(); + ?mlsub.typing.TypeSymbol lookup(TypeMap, LocatedString) = native mlsub.typing.TypeSymbol TypeMap.lookup(LocatedString); + ?mlsub.typing.TypeSymbol lookup(TypeMap, String) = native mlsub.typing.TypeSymbol TypeMap.lookup(String); // Retypings needed since java types are not strict. --- TypeMaper.java DELETED --- Index: analyse.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/analyse.nice,v retrieving revision 1.117 retrieving revision 1.118 diff -C2 -d -r1.117 -r1.118 *** analyse.nice 7 Dec 2004 17:33:57 -0000 1.117 --- analyse.nice 16 Dec 2004 23:40:00 -0000 1.118 *************** *** 25,31 **** Expression analyse(Expression, VarScope, TypeScope); - TypeMaper typeMaper(SymbolTable<TypeSymbol>,TypeScope) = - native new TypeMaper(SymbolTable, TypeScope); - // Implementation --- 25,28 ---- *************** *** 36,40 **** return new Info(vars: new SymbolTable(), typeVars: t, outerVarScope: varScope, outerTypeScope: typeScope, ! typeMap: typeMaper(t, typeScope)); } --- 33,37 ---- return new Info(vars: new SymbolTable(), typeVars: t, outerVarScope: varScope, outerTypeScope: typeScope, ! typeMap: new TypeMaper(inner: t, global: typeScope)); } |
From: Arjan B. <ar...@us...> - 2004-12-16 20:18:57
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28629/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Converted DefaultMethodImplementation. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.284 retrieving revision 1.285 diff -C2 -d -r1.284 -r1.285 *** Parser.jj 16 Dec 2004 16:21:06 -0000 1.284 --- Parser.jj 16 Dec 2004 20:18:46 -0000 1.285 *************** *** 1416,1422 **** { Statement body; } body=code() { statements.add(body); } ! { res = NiceMethod.WithDefault.create (name, cst, returnType, parameters, ! body != null ? bossa.syntax.dispatch.createBlock(statements) : null, contract, isOverride); } --- 1416,1422 ---- { Statement body; } body=code() { statements.add(body); } ! { res = bossa.syntax.dispatch.createMethodWithDefault (name, cst, returnType, parameters, ! bossa.syntax.dispatch.createBlock(statements), contract, isOverride); } |
From: Arjan B. <ar...@us...> - 2004-12-16 20:18:56
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28629/F:/nice/src/bossa/syntax Modified Files: NiceMethod.java dispatch.java.bootstrap Added Files: defaultMethod.nice Removed Files: DefaultMethodImplementation.java Log Message: Converted DefaultMethodImplementation. Index: dispatch.java.bootstrap =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/dispatch.java.bootstrap,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** dispatch.java.bootstrap 16 Dec 2004 16:21:07 -0000 1.33 --- dispatch.java.bootstrap 16 Dec 2004 20:18:47 -0000 1.34 *************** *** 13,16 **** --- 13,19 ---- public class dispatch { + public static Definition createMethodWithDefault(LocatedString name, Constraint constraint, Monotype returnType, FormalParameters parameters, Statement body, Contract contract, boolean isOverride) + { return null; } + static Monotype createMonotypeConstructor(mlsub.typing.TypeConstructor tc, TypeParameters parameters, bossa.util.Location loc) { return null; } --- DefaultMethodImplementation.java DELETED --- Index: NiceMethod.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/NiceMethod.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** NiceMethod.java 13 Oct 2004 15:44:09 -0000 1.43 --- NiceMethod.java 16 Dec 2004 20:18:46 -0000 1.44 *************** *** 130,134 **** isOverride); else ! return NiceMethod.WithDefault.create (name, constraint, returnType, params, body, contract, isOverride); } --- 130,134 ---- isOverride); else ! return dispatch.createMethodWithDefault (name, constraint, returnType, params, body, contract, isOverride); } *************** *** 343,407 **** } - /**************************************************************** - * Method with default implementation - ****************************************************************/ - - public static class WithDefault extends NiceMethod - { - /** - @param name the name of the method - @param constraint the constraint - @param returnType the return type - @param parameters the formal parameters - @param body the body of the function - */ - public static Definition create - (LocatedString name, - Constraint constraint, - Monotype returnType, - FormalParameters parameters, - Statement body, - Contract contract, boolean isOverride) - { - if (body == null) - return new NiceMethod - (name, constraint, returnType, parameters, contract, isOverride); - - return new DefaultMethodImplementation - (name, constraint, returnType, parameters, contract, isOverride, body); - } - - public WithDefault - (LocatedString name, - Constraint constraint, Monotype returnType, - FormalParameters parameters, - Contract contract, boolean isOverride, - DefaultMethodImplementation impl) - { - super(name, constraint, returnType, parameters, contract, isOverride); - this.implementation = impl; - } - - DefaultMethodImplementation implementation; - - void innerTypecheck() throws TypingEx - { - super.innerTypecheck(); - implementation.innerTypecheck(); - } - - protected gnu.expr.Expression computeCode() - { - // We need to store the result before compiling the implementation. - code = super.computeCode(); - - // Compile the implementation before returning. This is used to detect - // dependencies between global variables through default method - // implementations, so that the global variables can be initialized in - // the proper order. - implementation.getRefExp(); - - return code; - } - } } --- 343,345 ---- --- NEW FILE: defaultMethod.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.*; /** Method with default implementation. */ public class MethodWithDefault extends NiceMethod { DefaultMethodImplementation implementation; innerTypecheck() { super; implementation.innerTypecheck(); } computeCode() { // We need to store the result before compiling the implementation. code = super; // Compile the implementation before returning. This is used to detect // dependencies between global variables through default method // implementations, so that the global variables can be initialized in // the proper order. implementation.getRefExp(); return notNull(code); } } public Definition createMethodWithDefault (LocatedString name, Constraint constraint, Monotype returnType, FormalParameters parameters, Statement body, Contract contract, boolean isOverride) { if (body == null) return new NiceMethod(name, constraint, returnType, parameters, contract, isOverride); return createDefaultMethodImplementation(name, constraint, returnType, parameters, contract, isOverride, body); } /** The default implementation of a method. */ public class DefaultMethodImplementation extends MethodImplementation { firstArgument() { return notNull(nice.tools.typing.Types.equivalent(notNull(declaration).getArgTypes()[0]).head()); } doResolve() { notNull(this.declaration).docString = this.docString; //scope = declaration.scope; typeScope = notNull(declaration).typeScope; notNull(declaration).doResolve(); this.buildSymbols(); // Do not reset scope and typeScope to null. } void typedResolve() { notNull(declaration).typedResolve(); } void innerTypecheck() { // 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(); Node.currentFunction = this; if (this.hasThis()) Node.thisExp = createSymbolExp(notNull(parameters)[0], this.location()); try { typecheck(body); } finally { Node.currentFunction = null; Node.thisExp = null; } } printInterface(s) { notNull(declaration).printInterface(s); } javaArgTypes() = notNull(declaration).javaArgTypes(); } DefaultMethodImplementation createDefaultMethodImplementation (LocatedString name, Constraint constraint, Monotype returnType, FormalParameters parameters, Contract contract, boolean isOverride, Statement body) { let res = new DefaultMethodImplementation(name, body, parameters.asList().mapToArray(FormalParameters.Parameter param => createPattern(param.getName() || new LocatedString("_", name.location())))); res.declaration = new MethodWithDefault(name, constraint, returnType, parameters, contract, isOverride, implementation: res); res.addChild(res.declaration); return res; } |
From: Arjan B. <ar...@us...> - 2004-12-16 16:21:18
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5485/F:/nice/src/bossa/syntax Modified Files: Alike.java customConstructor.nice dispatch.java.bootstrap enum.nice loop.nice monotype.nice tools.nice try.nice Removed Files: MonotypeConstructor.java Log Message: Converted MonotypeConstructor. Index: loop.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/loop.nice,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** loop.nice 7 Dec 2004 17:33:57 -0000 1.6 --- loop.nice 16 Dec 2004 16:21:07 -0000 1.7 *************** *** 135,139 **** List<Monotype> tparams = new ArrayList(1); tparams.add(vartype); ! itertype = new MonotypeConstructor(new TypeIdent(new LocatedString("Iterator", loc)), new TypeParameters(tparams), loc); notNull(itertype).nullness = Monotype.sure; --- 135,139 ---- List<Monotype> tparams = new ArrayList(1); tparams.add(vartype); ! itertype = createMonotypeConstructor(new TypeIdent(new LocatedString("Iterator", loc)), new TypeParameters(tparams), loc); notNull(itertype).nullness = Monotype.sure; Index: monotype.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/monotype.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** monotype.nice 15 Dec 2004 03:45:59 -0000 1.1 --- monotype.nice 16 Dec 2004 16:21:07 -0000 1.2 *************** *** 16,19 **** --- 16,102 ---- /** + A monotype, build by application of + a type constructor to type parameters. + + */ + public class MonotypeConstructor extends Monotype + { + public ?TypeIdent tc = null; + // used when the lowlevel TC is know in advance + private ?mlsub.typing.TypeConstructor lowlevelTC = null; + TypeParameters parameters; + ?Location loc; + + Monotype cloneType() = new MonotypeConstructor(tc:tc,parameters:parameters,loc:loc); + + rawResolve(typeMap) + { + if (lowlevelTC == null) + { + let newTC = notNull(this.tc).resolveToTC(typeMap); + if (! (newTC instanceof TypeConstructor)) + throw User.error(notNull(this.tc), notNull(this.tc)+" should be a type constructor"); + lowlevelTC = newTC; + } + + mlsub.typing.Monotype[] resolvedParams = parameters.resolve(typeMap); + + try{ + return new mlsub.typing.MonotypeConstructor(lowlevelTC, resolvedParams); + } + catch(mlsub.typing.BadSizeEx e){ + // See if this is a class with default type parameters + let res = getTypeWithTC(notNull(lowlevelTC), resolvedParams); + if (res == null) + throw User.error(this, (tc!=null ? "Class "+tc : notNull(lowlevelTC).toString()) + + Util.has(e.expected, "type parameter", e.actual)); + + return res; + } + } + + substitute(map) + { + let TypeIdent newTC = cast(map.get(notNull(tc))) || notNull(tc); + + Monotype res = createMonotypeConstructor + (newTC, + new TypeParameters(Monotype.substitute(map, notNull(parameters.content))), + loc); + res.nullness = this.nullness; + return res; + } + + containsAlike() = Monotype.containsAlike(notNull(parameters.content)); + + public ?TypeIdent getTC() = tc; + + public TypeParameters getTP() = parameters; + + location() = loc || notNull(tc).location(); + + toString() + { + return this.nullnessString() + + (lowlevelTC != null ? notNull(lowlevelTC).toString() : notNull(tc).toString()) + + parameters; + } + + } + + public MonotypeConstructor createMonotypeConstructor(TypeIdent tc, ?TypeParameters parameters, + ?Location loc) + { + return new MonotypeConstructor(tc: tc, + parameters: parameters || new TypeParameters([]), loc: loc); + } + + Monotype createMonotypeConstructor(mlsub.typing.TypeConstructor tc, TypeParameters parameters, + Location loc) + { + return new MonotypeConstructor(lowlevelTC: tc, parameters: parameters, loc: loc); + } + + /** Functional type. Index: Alike.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Alike.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Alike.java 28 May 2003 12:57:25 -0000 1.7 --- Alike.java 16 Dec 2004 16:21:07 -0000 1.8 *************** *** 54,58 **** return this; ! Monotype res = new MonotypeConstructor ((mlsub.typing.TypeConstructor) tc, new TypeParameters(Monotype.substitute(map, parameters)), --- 54,58 ---- return this; ! Monotype res = dispatch.createMonotypeConstructor ((mlsub.typing.TypeConstructor) tc, new TypeParameters(Monotype.substitute(map, parameters)), Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** tools.nice 15 Dec 2004 03:45:59 -0000 1.73 --- tools.nice 16 Dec 2004 16:21:07 -0000 1.74 *************** *** 193,196 **** --- 193,197 ---- List<VarSymbol> findJavaMethods(?gnu.bytecode.ClassType, String) = native List JavaClasses.findJavaMethods(gnu.bytecode.ClassType,java.lang.String); TypeParameters TypeParameters(List<Monotype>) = native new bossa.syntax.TypeParameters(List); + TypeParameters TypeParameters(Monotype[]) = native new bossa.syntax.TypeParameters(Monotype[]); ?String explainNoMatch(Arguments, List<VarSymbol>) = native String Arguments.explainNoMatch(List); Map<VarSymbol,mlsub.typing.Polytype> types(Arguments) = native Arguments.types; *************** *** 252,257 **** ?String getParentFor(AtomicConstraint, mlsub.typing.TypeConstructor) = native String AtomicConstraint.getParentFor(mlsub.typing.TypeConstructor); mlsub.typing.AtomicConstraint resolve(AtomicConstraint, TypeScope) = native mlsub.typing.AtomicConstraint AtomicConstraint.resolve(TypeScope); ! bossa.syntax.Monotype substitute(bossa.syntax.Monotype,Map<String,bossa.syntax.Monotype>) = native bossa.syntax.Monotype bossa.syntax.Monotype.substitute(Map); ! List<bossa.syntax.Monotype> substitute(Map<String,bossa.syntax.Monotype>,Collection<bossa.syntax.Monotype>) = native List bossa.syntax.Monotype.substitute(Map,Collection); boolean containsAlike(List<bossa.syntax.Monotype>) = native boolean bossa.syntax.Monotype.containsAlike(List); mlsub.typing.Monotype[] rawResolve(TypeMap,Collection<bossa.syntax.Monotype>) = native mlsub.typing.Monotype[] bossa.syntax.Monotype.rawResolve(TypeMap, Collection); --- 253,258 ---- ?String getParentFor(AtomicConstraint, mlsub.typing.TypeConstructor) = native String AtomicConstraint.getParentFor(mlsub.typing.TypeConstructor); mlsub.typing.AtomicConstraint resolve(AtomicConstraint, TypeScope) = native mlsub.typing.AtomicConstraint AtomicConstraint.resolve(TypeScope); ! bossa.syntax.Monotype substitute(bossa.syntax.Monotype,Map<TypeIdent,bossa.syntax.Monotype>) = native bossa.syntax.Monotype bossa.syntax.Monotype.substitute(Map); ! List<bossa.syntax.Monotype> substitute(Map<TypeIdent,bossa.syntax.Monotype>,Collection<bossa.syntax.Monotype>) = native List bossa.syntax.Monotype.substitute(Map,Collection); boolean containsAlike(List<bossa.syntax.Monotype>) = native boolean bossa.syntax.Monotype.containsAlike(List); mlsub.typing.Monotype[] rawResolve(TypeMap,Collection<bossa.syntax.Monotype>) = native mlsub.typing.Monotype[] bossa.syntax.Monotype.rawResolve(TypeMap, Collection); *************** *** 261,265 **** List<FormalParameters.Parameter> asList(FormalParameters) = native List FormalParameters.asList(); boolean containsAlike(Monotype[]) = native boolean Monotype.containsAlike(Monotype[]); ! bossa.syntax.Monotype[] substitute(Map<String,bossa.syntax.Monotype>,bossa.syntax.Monotype[]) = native bossa.syntax.Monotype[] bossa.syntax.Monotype.substitute(Map,bossa.syntax.Monotype[]); Monotype[?] types(FormalParameters) = native Monotype[] FormalParameters.types(); --- 262,266 ---- List<FormalParameters.Parameter> asList(FormalParameters) = native List FormalParameters.asList(); boolean containsAlike(Monotype[]) = native boolean Monotype.containsAlike(Monotype[]); ! bossa.syntax.Monotype[] substitute(Map<TypeIdent,bossa.syntax.Monotype>,bossa.syntax.Monotype[]) = native bossa.syntax.Monotype[] bossa.syntax.Monotype.substitute(Map,bossa.syntax.Monotype[]); Monotype[?] types(FormalParameters) = native Monotype[] FormalParameters.types(); Index: enum.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/enum.nice,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** enum.nice 7 Dec 2004 17:33:57 -0000 1.7 --- enum.nice 16 Dec 2004 16:21:07 -0000 1.8 *************** *** 67,71 **** let classDef = makeClass (name,true,false, null, new ArrayList(), ! new MonotypeConstructor(new TypeIdent(new LocatedString("nice.lang.Enum", name.location())), null, name.location()), interfaces, null); let impl = createNiceClass(classDef); --- 67,71 ---- let classDef = makeClass (name,true,false, null, new ArrayList(), ! createMonotypeConstructor(new TypeIdent(new LocatedString("nice.lang.Enum", name.location())), null, name.location()), interfaces, null); let impl = createNiceClass(classDef); Index: dispatch.java.bootstrap =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/dispatch.java.bootstrap,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** dispatch.java.bootstrap 11 Dec 2004 23:58:02 -0000 1.32 --- dispatch.java.bootstrap 16 Dec 2004 16:21:07 -0000 1.33 *************** *** 13,16 **** --- 13,19 ---- public class dispatch { + static Monotype createMonotypeConstructor(mlsub.typing.TypeConstructor tc, TypeParameters parameters, bossa.util.Location loc) + { return null; } + public static Expression createIdentExp(LocatedString i) { return null; } Index: try.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/try.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** try.nice 1 Dec 2004 02:00:32 -0000 1.2 --- try.nice 16 Dec 2004 16:21:07 -0000 1.3 *************** *** 101,105 **** public new ACatch(TypeIdent tc, LocatedString varName, Statement body) { ! Monotype type = new MonotypeConstructor(tc, null, tc.location()); type.nullness = Monotype.sure; --- 101,105 ---- public new ACatch(TypeIdent tc, LocatedString varName, Statement body) { ! Monotype type = createMonotypeConstructor(tc, null, tc.location()); type.nullness = Monotype.sure; Index: customConstructor.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/customConstructor.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** customConstructor.nice 11 Dec 2004 23:58:02 -0000 1.1 --- customConstructor.nice 16 Dec 2004 16:21:07 -0000 1.2 *************** *** 158,162 **** TypeSymbol[] syms = cst.getBinderArray(); ! Monotype[?] params = cast(new Monotype[syms.length]); for (int i = 0; i < syms.length; i++) --- 158,162 ---- TypeSymbol[] syms = cst.getBinderArray(); ! Monotype[] params = cast(new Monotype[syms.length]); for (int i = 0; i < syms.length; i++) *************** *** 167,171 **** } ! let res = new MonotypeConstructor (classe, new TypeParameters(params), classe.location()); res.nullness = Monotype.sure; --- 167,171 ---- } ! let res = createMonotypeConstructor (classe, new TypeParameters(params), classe.location()); res.nullness = Monotype.sure; --- MonotypeConstructor.java DELETED --- |
From: Arjan B. <ar...@us...> - 2004-12-16 16:21:15
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5485/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Converted MonotypeConstructor. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.283 retrieving revision 1.284 diff -C2 -d -r1.283 -r1.284 *** Parser.jj 15 Dec 2004 03:45:58 -0000 1.283 --- Parser.jj 16 Dec 2004 16:21:06 -0000 1.284 *************** *** 674,678 **** last=getToken(0); ! return new MonotypeConstructor(t,new TypeParameters(p), makeLocation(first, last)); } --- 674,678 ---- last=getToken(0); ! return bossa.syntax.dispatch.createMonotypeConstructor(t,new TypeParameters(p), makeLocation(first, last)); } *************** *** 761,765 **** tp.add(res); Location loc = res.location(); ! res = new MonotypeConstructor (new TypeIdent(new LocatedString("nice.lang.Array", loc)), new TypeParameters(tp), --- 761,765 ---- tp.add(res); Location loc = res.location(); ! res = bossa.syntax.dispatch.createMonotypeConstructor (new TypeIdent(new LocatedString("nice.lang.Array", loc)), new TypeParameters(tp), *************** *** 935,939 **** // they should be checked [ "<" params = monotypes() ">" ] ! { return new MonotypeConstructor(name, params == null ? null : new TypeParameters(params), name.location()); } } --- 935,939 ---- // they should be checked [ "<" params = monotypes() ">" ] ! { return bossa.syntax.dispatch.createMonotypeConstructor(name, params == null ? null : new TypeParameters(params), name.location()); } } |
From: Arjan B. <ar...@us...> - 2004-12-16 00:30:38
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14154/F:/nice/src/bossa/syntax Modified Files: NiceUtils.java Added Files: inline.nice Removed Files: InlinedMethod.java Log Message: Converted InlinedMethod. Index: NiceUtils.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/NiceUtils.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NiceUtils.java 5 Nov 2004 14:57:57 -0000 1.2 --- NiceUtils.java 16 Dec 2004 00:30:29 -0000 1.3 *************** *** 25,28 **** --- 25,74 ---- } + static ClassLoader inlineLoader; + + static + { + String inlinedMethodsRepository = System.getProperty("nice.inlined"); + if (inlinedMethodsRepository != null) + { + inlineLoader = new nice.tools.util.DirectoryClassLoader + (new java.io.File[]{ new java.io.File(inlinedMethodsRepository) }, + null) + { + protected Class loadClass(String name, boolean resolve) + throws ClassNotFoundException + { + /* Change the default behviour, which is to look up the + parent classloader first. Instead, look it up after this one, + so that the inlined methods are found here, but the + interfaces they implement are found in the system classloader, + so that the casts for using them succeed. + */ + Class res = findLoadedClass(name); + + if (res == null) + try { + res = this.findClass(name); + } + catch (ClassNotFoundException ex) {} + + if (res == null) + { + ClassLoader parent = getParent(); + // A JVM may represent the system classloader by null. + if (parent == null) + parent = ClassLoader.getSystemClassLoader(); + res = parent.loadClass(name); + } + + if (resolve && res != null) + resolveClass(res); + + return res; + } + }; + } + } + } --- NEW FILE: inline.nice --- /**************************************************************************/ /* N I C E */ /* A simple imperative 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 method that is compiled by inlining code. The inlining class can be defined by the user. It keeps the core compiler small, while having very good efficiency. It has to be a subclass of <code>gnu.mapping.Procedure</code>, and should implement interface <code>gnu.expr.Inlineable</code> to be actually inlined. */ public class InlinedMethod extends MethodDeclaration { private LocatedString inlineProcedure; private ?String parameter; private ?gnu.mapping.Procedure procedure = null; typecheck() { super; this.getProcedure(); } private gnu.mapping.Procedure getProcedure() { if (this.procedure != null) // Already done. return notNull(this.procedure); ?Class refClass = null; try{ refClass = this.findClass(inlineProcedure.toString()); } catch(ClassNotFoundException e){ User.error(inlineProcedure, "Inlined method " + inlineProcedure + " was not found"); } ?java.lang.reflect.Method m = null; try{ m = notNull(refClass).getMethod("create", [String.class]); if (! java.lang.reflect.Modifier.isStatic(notNull(m).getModifiers())) throw new NoSuchMethodException(); } catch(NoSuchMethodException e){ User.error(inlineProcedure, "Inlined method " + inlineProcedure + " has no static create(String)"); } ?Object o = null; try{ o = notNull(m).invoke(null, [cast(parameter)]); } catch(java.lang.reflect.InvocationTargetException e){ Throwable realEx = e.getTargetException(); User.error(inlineProcedure, "Inlined method " + inlineProcedure + ": " + realEx); } catch(IllegalAccessException e){ User.error(inlineProcedure, "Inlined method " + inlineProcedure + ": could not call create method", e.getMessage()); } if (!(o instanceof gnu.mapping.Procedure)) User.error(inlineProcedure, "Inlined method " + inlineProcedure + " should be a subclass of gnu.mapping.Procedure"); if (!(o instanceof gnu.expr.Inlineable)) User.warning(inlineProcedure, "Inlined method " + inlineProcedure + " cannot be inlined, but will be called anyway"); this.procedure = cast(o); return notNull(this.procedure); } private Class findClass(String name) { if (NiceUtils.inlineLoader == null) return Class.forName(name); else return notNull(NiceUtils.inlineLoader).loadClass(name); } computeCode() { return new gnu.expr.QuoteExp(this.getProcedure()); } getCode() { return nice.tools.code.Gen.wrapInLambda(this.getProcedure()); } checkSpecialRequirements(arguments) { let proc = this.getProcedure(); if (proc instanceof bossa.syntax.Macro) proc.checkSpecialRequirements(arguments); } printInterface(s) { s.print(this.toString() + " = inline " + inlineProcedure + (parameter!=null ? "(\""+parameter+"\");\n" : ";\n")); } } --- InlinedMethod.java DELETED --- |
From: Arjan B. <ar...@us...> - 2004-12-15 15:55:54
|
Update of /cvsroot/nice/Nice/testsuite/compiler/methods In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24115/F:/nice/testsuite/compiler/methods Modified Files: overriding.testsuite Log Message: Testcase for bug in coverage testing of an override. Index: overriding.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/methods/overriding.testsuite,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** overriding.testsuite 13 Oct 2004 15:05:21 -0000 1.9 --- overriding.testsuite 15 Dec 2004 15:55:44 -0000 1.10 *************** *** 259,260 **** --- 259,267 ---- assert ! foo(null); assert foo(5); + + /// PASS bug + /// Toplevel + class A {} + class B extends A {} + void foo(?A x) {} + override void foo(?B x) {} |
From: Arjan B. <ar...@us...> - 2004-12-15 03:46:09
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2818/F:/nice/src/bossa/syntax Modified Files: symbol.nice tools.nice Added Files: monotype.nice Removed Files: FunType.java Log Message: Converted FunType. Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** tools.nice 14 Dec 2004 22:49:12 -0000 1.72 --- tools.nice 15 Dec 2004 03:45:59 -0000 1.73 *************** *** 260,263 **** --- 260,266 ---- List<FormalParameters.Parameter> getRequiredParameters(FormalParameters) = native List FormalParameters.getRequiredParameters(); List<FormalParameters.Parameter> asList(FormalParameters) = native List FormalParameters.asList(); + boolean containsAlike(Monotype[]) = native boolean Monotype.containsAlike(Monotype[]); + bossa.syntax.Monotype[] substitute(Map<String,bossa.syntax.Monotype>,bossa.syntax.Monotype[]) = native bossa.syntax.Monotype[] bossa.syntax.Monotype.substitute(Map,bossa.syntax.Monotype[]); + Monotype[?] types(FormalParameters) = native Monotype[] FormalParameters.types(); // Retypings needed since java types are not strict. --- NEW FILE: monotype.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.*; /** Functional type. */ public class FunType extends bossa.syntax.Monotype { private bossa.syntax.Monotype[] in; private bossa.syntax.Monotype out; rawResolve(typeMap) { return new mlsub.typing.FunType (bossa.syntax.Monotype.resolve(notNull(typeMap), in), out.resolve(typeMap)); } substitute(map) { bossa.syntax.Monotype res = new bossa.syntax.FunType (in: bossa.syntax.Monotype.substitute(map,in), out: out.substitute(map)); res.nullness = this.nullness; return res; } containsAlike() = Monotype.containsAlike(in) || out.containsAlike(); location() = out.location(); toString() { return "(" + Util.map("", ", ", "", in) + (nullness == maybe ? ")?->" : ")->") + out; } toStringExtern() = "(" + Util.map("", ", ", "", in) + ")->" + out.toStringExtern(); } public FunType createFunType(?List<bossa.syntax.Monotype> in, bossa.syntax.Monotype out) { return new FunType(in: (in != null ? in.toArray() : []), out: out); } public FunType createFunType_(bossa.syntax.Monotype[?] in, bossa.syntax.Monotype out) { return new FunType(in: (in != null ? in : []), out: out); } --- FunType.java DELETED --- Index: symbol.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/symbol.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** symbol.nice 21 Nov 2004 23:24:37 -0000 1.1 --- symbol.nice 15 Dec 2004 03:45:59 -0000 1.2 *************** *** 138,142 **** { this(name, parameters: parameters, arity: parameters.size, syntacticType: ! new Polytype(constraint, new FunType(parameters.types(), returnType))); } --- 138,142 ---- { this(name, parameters: parameters, arity: parameters.size, syntacticType: ! new Polytype(constraint, createFunType(parameters.types(), returnType))); } *************** *** 200,204 **** FormalParameters parameters = declaration.formalParameters(); this(name, declaration: declaration, parameters: parameters, arity: parameters.size, ! syntacticType: new Polytype(constraint, new FunType(parameters.types(), returnType))); } --- 200,204 ---- FormalParameters parameters = declaration.formalParameters(); this(name, declaration: declaration, parameters: parameters, arity: parameters.size, ! syntacticType: new Polytype(constraint, createFunType(parameters.types(), returnType))); } |
From: Arjan B. <ar...@us...> - 2004-12-15 03:46:08
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2818/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Converted FunType. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.282 retrieving revision 1.283 diff -C2 -d -r1.282 -r1.283 *** Parser.jj 11 Dec 2004 23:58:00 -0000 1.282 --- Parser.jj 15 Dec 2004 03:45:58 -0000 1.283 *************** *** 693,697 **** codomain = monotype() { ! FunType res = new FunType(domain, codomain); res.nullness = maybe ? res.maybe : res.absent; return res; --- 693,697 ---- codomain = monotype() { ! FunType res = bossa.syntax.dispatch.createFunType(domain, codomain); res.nullness = maybe ? res.maybe : res.absent; return res; *************** *** 733,737 **** else domain = new Monotype[]{ res }; ! res = new FunType(domain, codomain); res.nullness = maybe ? res.maybe : res.absent; } ] --- 733,737 ---- else domain = new Monotype[]{ res }; ! res = bossa.syntax.dispatch.createFunType_(domain, codomain); res.nullness = maybe ? res.maybe : res.absent; } ] |
From: Arjan B. <ar...@us...> - 2004-12-14 22:49:24
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30864/F:/nice/src/bossa/syntax Modified Files: importedconstructor.nice niceclass.nice tools.nice Added Files: constructor.nice Removed Files: Constructor.java Log Message: Converted Constructor. --- Constructor.java DELETED --- Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** tools.nice 14 Dec 2004 18:58:08 -0000 1.71 --- tools.nice 14 Dec 2004 22:49:12 -0000 1.72 *************** *** 217,221 **** MonoSymbol[?] getMonoSymbols(FormalParameters) = native MonoSymbol[] FormalParameters.getMonoSymbols(); mlsub.typing.AtomicConstraint[?] AtomicConstraint_substitute(java.util.Map<mlsub.typing.TypeSymbol,mlsub.typing.TypeSymbol>, AtomicConstraint[?]) = native mlsub.typing.AtomicConstraint[] mlsub.typing.AtomicConstraint.substitute(java.util.Map, mlsub.typing.AtomicConstraint[]); - NiceClass classe(Constructor) = native Constructor.classe; FormalParameters parameters(MethodDeclaration) = native MethodDeclaration.parameters; ?gnu.expr.Expression getInitializer(NiceClass) = native gnu.expr.Expression NiceClass.getInitializer(); --- 217,220 ---- *************** *** 257,260 **** --- 256,263 ---- boolean containsAlike(List<bossa.syntax.Monotype>) = native boolean bossa.syntax.Monotype.containsAlike(List); mlsub.typing.Monotype[] rawResolve(TypeMap,Collection<bossa.syntax.Monotype>) = native mlsub.typing.Monotype[] bossa.syntax.Monotype.rawResolve(TypeMap, Collection); + List<String> noMatchByName(Arguments, FormalParameters) = native List Arguments.noMatchByName(FormalParameters); + List<FormalParameters.Parameter> missingArgs(Arguments, FormalParameters) = native List Arguments.missingArgs(FormalParameters); + List<FormalParameters.Parameter> getRequiredParameters(FormalParameters) = native List FormalParameters.getRequiredParameters(); + List<FormalParameters.Parameter> asList(FormalParameters) = native List FormalParameters.asList(); // Retypings needed since java types are not strict. Index: importedconstructor.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/importedconstructor.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** importedconstructor.nice 25 Nov 2004 19:28:18 -0000 1.2 --- importedconstructor.nice 14 Dec 2004 22:49:12 -0000 1.3 *************** *** 102,111 **** null : notNull(classDef.classConstraint).shallowClone(); ! let res = new ImportedConstructor(def, ! gnu.bytecode.Attribute.get(method, "default") != null, ! def.getDefinition().location(), FormalParameters.readBytecodeAttribute(attr, notNull(JavaClasses.compilation).parser), ! constraint, returnType, method: method); TypeConstructors.addConstructor(res.classe.getDefinition().getTC(), res); --- 102,112 ---- null : notNull(classDef.classConstraint).shallowClone(); ! let res = new ImportedConstructor( ! new LocatedString("<init>",def.getDefinition().location()), ! constraint, returnType, FormalParameters.readBytecodeAttribute(attr, notNull(JavaClasses.compilation).parser), ! classe: def, isDefault: gnu.bytecode.Attribute.get(method, "default") != null, ! method: method); TypeConstructors.addConstructor(res.classe.getDefinition().getTC(), res); Index: niceclass.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/niceclass.nice,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** niceclass.nice 4 Dec 2004 19:38:18 -0000 1.7 --- niceclass.nice 14 Dec 2004 22:49:12 -0000 1.8 *************** *** 551,558 **** notNull(constructorMethod)[i] = new DefaultConstructor ! (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]); } --- 551,558 ---- notNull(constructorMethod)[i] = new DefaultConstructor ! (new LocatedString("<init>",definition.location()), values, cst, Monotype.resolve(definition.getLocalScope(), values.types()), Monotype.sure(new mlsub.typing.MonotypeConstructor(definition.getTC(), definition.getTypeParameters())), ! classe: this, isDefault: true, fields: fields, parent: parent); TypeConstructors.addConstructor(definition.getTC(), notNull(constructorMethod)[i]); } --- NEW FILE: constructor.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package bossa.syntax; import bossa.util.*; //import mlsub.typing.Constraint; //import mlsub.typing.Monotype; /** An object constructor. */ abstract class Constructor extends MethodDeclaration { NiceClass classe; final boolean isDefault; gnu.expr.Expression getInitializationCode(boolean implicitThis); void addConstructorCallSymbol() { let type = new mlsub.typing.Polytype(this.getType().getConstraint(), new mlsub.typing.FunType(this.getArgTypes(), nice.tools.typing.PrimitiveType.voidType)); classe.addConstructorCallSymbol(createConstructorCallSymbol(this, name, type)); } printInterface(s) { throw new Error("Should not be called"); } explainWhyMatchFails(arguments) { if (! isDefault) return super; String name = classe.getName().toString(); StringBuffer res = new StringBuffer(); res.append("Class ").append(name); //Arguments where none expected if (parameters.size == 0) { res.append(" has no fields. Therefore its constructor takes no arguments."); return res.toString(); } //No such field List<String> nonmatching = notNull(arguments).noMatchByName(parameters); if (!nonmatching.isEmpty()) { res.append(" has no field named "+nonmatching[0]); return res.toString(); } //Required fields missing, or else too many arguments // - three different messages depending on whether //an explanation of the syntax is necessary res = new StringBuffer(); List<FormalParameters.Parameter> missing = notNull(arguments).missingArgs(parameters); List<FormalParameters.Parameter> fieldsToList; if (notNull(arguments).size() == 0) { res.append("Fields of class ").append(name) .append(" require initial values.\n"); res.append(this.syntaxExample()) .append("Class ").append(name).append(" has the following fields:\n"); fieldsToList = parameters.asList(); } else if (missing.size() > 0) { res.append("The following fields require initial values:\n"); fieldsToList = missing; } else { res.append("Too many arguments when constructing new instance of class ") .append(name) .append(".\n") .append("The constructor accepts the following arguments:\n" ); fieldsToList = parameters.asList(); } for (field : fieldsToList) { res.append(" ") .append(field) .append("\n"); } return res.toString(); } private String syntaxExample() { String name = classe.getName().toString(); StringBuffer res = new StringBuffer(); res.append("Use the following syntax:\n") .append(" new ").append(name).append("("); let Iterator<FormalParameters.Parameter> params = parameters.getRequiredParameters().iterator(); int paramCount = 0; int len = name.length(); while(params.hasNext()) { FormalParameters.Parameter param = params.next(); if (paramCount != 0) res.append(", "); if (paramCount == 3 && params.hasNext()) { res.append('\n'); for(int i = 0; i < len; i++) {res.append(' ');} res.append(" "); paramCount = 0; } if (param instanceof FormalParameters.NamedParameter) res.append(param.getName()).append(": value"); else res.append("value"); paramCount++; } res.append(")\n\n"); return res.toString(); } } |
From: Arjan B. <ar...@us...> - 2004-12-14 20:18:14
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28329/F:/nice/src/bossa/syntax Modified Files: Arguments.java constant.nice ident.nice Removed Files: PackageExp.java Log Message: Converted PackageExp. Index: constant.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/constant.nice,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** constant.nice 8 Dec 2004 20:00:58 -0000 1.4 --- constant.nice 14 Dec 2004 20:18:05 -0000 1.5 *************** *** 282,286 **** return root; ! let res = new PackageExp(fullName); res.setLocation(name.location()); return res; --- 282,286 ---- return root; ! let res = createPackageExp(fullName); res.setLocation(name.location()); return res; Index: Arguments.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Arguments.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** Arguments.java 21 Nov 2004 23:24:36 -0000 1.28 --- Arguments.java 14 Dec 2004 20:18:05 -0000 1.29 *************** *** 140,155 **** } - PackageExp packageExp() - { - // case where the parameters is a package, or a package prefix - if(arguments.length == 1) - { - Expression param0 = getExp(0); - if(param0 instanceof PackageExp) - return (PackageExp) param0; - } - return null; - } - gnu.bytecode.ClassType staticClass() { --- 140,143 ---- Index: ident.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/ident.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ident.nice 7 Dec 2004 17:33:57 -0000 1.1 --- ident.nice 14 Dec 2004 20:18:05 -0000 1.2 *************** *** 62,63 **** --- 62,115 ---- return res; } + + /** + Temporary expression to represent a package or a package prefix. + + For instance, in java.lang.System.exit(0), + java and java.lang is represented by a package exp. + */ + class PackageExp extends Expression + { + StringBuffer name; + + LocatedString locatedName() + { + return new LocatedString(name.toString(), this.location()); + } + + toString() = "PackageExp " + name; + + private void error() + { + User.error(this, + name + " is neither a valid expression nor a valid package"); + } + + computeType() + { + this.error(); + } + + compile() + { + this.error(); + return cast(null); + } + } + + PackageExp createPackageExp(String name) + { + return new PackageExp(name: new StringBuffer(name)); + } + + ?PackageExp packageExp(Arguments args) + { + // case where the parameters is a package, or a package prefix + if (args.size() == 1) + { + Expression param0 = args.getExp(0); + if (param0 instanceof PackageExp) + return param0; + } + return null; + } --- PackageExp.java DELETED --- |
From: Arjan B. <ar...@us...> - 2004-12-14 18:58:18
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9072/F:/nice/src/bossa/syntax Modified Files: tools.nice tuple.nice Removed Files: TupleType.java Log Message: Converted TupleType. (by Luc Perrin) Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** tools.nice 8 Dec 2004 23:03:37 -0000 1.70 --- tools.nice 14 Dec 2004 18:58:08 -0000 1.71 *************** *** 253,256 **** --- 253,260 ---- ?String getParentFor(AtomicConstraint, mlsub.typing.TypeConstructor) = native String AtomicConstraint.getParentFor(mlsub.typing.TypeConstructor); mlsub.typing.AtomicConstraint resolve(AtomicConstraint, TypeScope) = native mlsub.typing.AtomicConstraint AtomicConstraint.resolve(TypeScope); + bossa.syntax.Monotype substitute(bossa.syntax.Monotype,Map<String,bossa.syntax.Monotype>) = native bossa.syntax.Monotype bossa.syntax.Monotype.substitute(Map); + List<bossa.syntax.Monotype> substitute(Map<String,bossa.syntax.Monotype>,Collection<bossa.syntax.Monotype>) = native List bossa.syntax.Monotype.substitute(Map,Collection); + boolean containsAlike(List<bossa.syntax.Monotype>) = native boolean bossa.syntax.Monotype.containsAlike(List); + mlsub.typing.Monotype[] rawResolve(TypeMap,Collection<bossa.syntax.Monotype>) = native mlsub.typing.Monotype[] bossa.syntax.Monotype.rawResolve(TypeMap, Collection); // Retypings needed since java types are not strict. Index: tuple.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tuple.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tuple.nice 28 Jul 2004 14:40:33 -0000 1.1 --- tuple.nice 14 Dec 2004 18:58:08 -0000 1.2 *************** *** 16,22 **** /** ! Creation of a tuple. */ public class TupleExp extends bossa.syntax.Expression { --- 16,47 ---- /** ! A tuple of types. */ + public class TupleType extends bossa.syntax.Monotype + { + List<Monotype> types; + Location location; + + rawResolve(typeMap) = new mlsub.typing.TupleType + (bossa.syntax.Monotype.rawResolve(notNull(typeMap), types)); + substitute(map) + { + bossa.syntax.Monotype res = new bossa.syntax.TupleType + ( types : bossa.syntax.Monotype.substitute(map, types), location : location); + res.nullness = this.nullness; + return res; + } + + containsAlike() = bossa.syntax.Monotype.containsAlike(types); + + location() = location; + + toString() = Util.map("(", ", " ,")", types); + } + + /** + Creation of a tuple. + */ public class TupleExp extends bossa.syntax.Expression { --- TupleType.java DELETED --- |
From: Arjan B. <ar...@us...> - 2004-12-14 00:18:49
|
Update of /cvsroot/nice/Nice/testsuite/compiler/classes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7122/F:/nice/testsuite/compiler/classes Modified Files: specialization.testsuite Log Message: Testcase for bug #1084559. Index: specialization.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/classes/specialization.testsuite,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** specialization.testsuite 20 Nov 2004 00:39:42 -0000 1.4 --- specialization.testsuite 14 Dec 2004 00:18:40 -0000 1.5 *************** *** 55,56 **** --- 55,63 ---- int x; } + + /// PASS bug + /// Toplevel + class A<T> {} + class B extends A<String> { + void foo() {} + } |
From: Arjan B. <ar...@us...> - 2004-12-11 23:58:12
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27768/F:/nice/src/bossa/syntax Modified Files: dispatch.java.bootstrap Added Files: customConstructor.nice Removed Files: CustomConstructor.java Log Message: Converted CustomConstructor. --- CustomConstructor.java DELETED --- --- NEW FILE: customConstructor.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 user defined constructor, in a source program. */ public class CustomConstructor extends UserOperator { LocatedString className; Statement body; ?NiceClass classe = null; private ?VarScope thisScope = null; private ?TypeScope thisTypeScope = null; ?gnu.expr.Expression initializationCode = null; ?gnu.expr.Expression initializationCodeImplicitThis = null; private boolean generatingCode = false; void addConstructorCallSymbol() { mlsub.typing.Polytype type = new mlsub.typing.Polytype (this.getType().getConstraint(), new mlsub.typing.FunType(this.getArgTypes(), nice.tools.typing.PrimitiveType.voidType)); notNull(classe).addConstructorCallSymbol( dispatch.createConstructorCallSymbol(this, name, type)); } resolve() { super; let tc = Node.getGlobalTypeScope().globalLookup(className); TypeConstructors.addConstructor(tc, this); classe = NiceClass.get(tc); if (classe == null) User.error(this, "It is impossible to add a constructor to class " + tc); this.addConstructorCallSymbol(); // Save the scopes, since we need them later, but they get null'ed. thisScope = scope; thisTypeScope = typeScope; } resolveBody() { resolveCCThis(body, this, notNull(classe)); body = analyseMethodBody(body, notNull(thisScope), notNull(thisTypeScope), this.getSymbols(), false); } innerTypecheck() { super; typecheck(body); } printInterface(s) { // Constructors are not printed, they are loaded from the bytecode. } compile() { // Make sure the constructor is generated. this.getCode(); } private Map<String, Monotype> typeParamMap(TypeSymbol[] source, mlsub.typing.Monotype[] destination) { Map<String, Monotype> res = new HashMap(source.length); for (int i = 0; i < source.length; i++) res.put(source[i].toString(), Monotype.create(destination[i])); return res; } computeCode() { if (generatingCode) User.error(this, "recursive custom constructor calls not allowed"); generatingCode = true; let lambda = nice.tools.code.Gen.createCustomConstructor (cast(this.javaReturnType()), this.javaArgTypes(), this.getSymbols()); nice.tools.code.Gen.setMethodBody(lambda, body.generateCode()); notNull(classe).getClassExp().addMethod(lambda); generatingCode = false; // In the bytecode, we want to use the same type parameter names // as the class definition, even if the source of this custom constructor // renamed them locally. let cst = this.getType().getConstraint(); if (mlsub.typing.Constraint.hasBinders(cst)) parameters.substitute (this.typeParamMap(notNull(cst).binders(), notNull(classe).getTypeParameters())); lambda.addBytecodeAttribute(parameters.asBytecodeAttribute()); initializationCode = new gnu.expr.QuoteExp(new gnu.expr.InitializeProc(lambda)); initializationCodeImplicitThis = new gnu.expr.QuoteExp(new gnu.expr.InitializeProc(lambda, true)); return new gnu.expr.QuoteExp(new gnu.expr.InstantiateProc(lambda)); } getConstructorInvocation(boolean) { this.getCode(); return notNull(initializationCode); } gnu.expr.Expression getInitializationCode(boolean implicitThis) { this.getCode(); if (implicitThis) return notNull(initializationCodeImplicitThis); else return notNull(initializationCode); } } public CustomConstructor createCustomConstructor(LocatedString className, Constraint cst, FormalParameters params, Statement body) { return new CustomConstructor(new LocatedString("<init>", className.location()), cst, getCCReturnType(className, cst), params, Contract.noContract, className: className, body: body); } private Monotype getCCReturnType(LocatedString className, Constraint cst) { let classe = new TypeIdent(className); classe.nullness = Monotype.sure; if (cst == Constraint.True) return classe; TypeSymbol[] syms = cst.getBinderArray(); Monotype[?] params = cast(new Monotype[syms.length]); for (int i = 0; i < syms.length; i++) { if (! (syms[i] instanceof mlsub.typing.MonotypeVar)) User.error(classe, syms[i] + " is not a type"); notNull(params)[i] = Monotype.create(cast(syms[i])); } let res = new MonotypeConstructor (classe, new TypeParameters(params), classe.location()); res.nullness = Monotype.sure; return res; } Index: dispatch.java.bootstrap =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/dispatch.java.bootstrap,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** dispatch.java.bootstrap 11 Dec 2004 19:41:03 -0000 1.31 --- dispatch.java.bootstrap 11 Dec 2004 23:58:02 -0000 1.32 *************** *** 37,42 **** { return null; } - static void resolveCCThis(Statement stmt, bossa.util.Located thisloc, NiceClass classe) {} - static Pattern resolveGlobalConstants(Pattern pattern) { return null; } --- 37,40 ---- |
From: Arjan B. <ar...@us...> - 2004-12-11 23:58:12
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27768/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Converted CustomConstructor. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.281 retrieving revision 1.282 diff -C2 -d -r1.281 -r1.282 *** Parser.jj 8 Dec 2004 20:00:57 -0000 1.281 --- Parser.jj 11 Dec 2004 23:58:00 -0000 1.282 *************** *** 1114,1118 **** ) { ! return CustomConstructor.make(name, cst, params, bossa.syntax.dispatch.createBlock(statements)); } } --- 1114,1118 ---- ) { ! return bossa.syntax.dispatch.createCustomConstructor(name, cst, params, bossa.syntax.dispatch.createBlock(statements)); } } |
From: Arjan B. <ar...@us...> - 2004-12-11 19:41:12
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7992/F:/nice/src/bossa/syntax Modified Files: dispatch.java.bootstrap Log Message: Removed superfluous methods from dispatch.java.bootstrap. Index: dispatch.java.bootstrap =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/dispatch.java.bootstrap,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** dispatch.java.bootstrap 7 Dec 2004 17:33:57 -0000 1.30 --- dispatch.java.bootstrap 11 Dec 2004 19:41:03 -0000 1.31 *************** *** 37,43 **** { return null; } - static List removeNonMinimal(List l) - { return null; } - static void resolveCCThis(Statement stmt, bossa.util.Located thisloc, NiceClass classe) {} --- 37,40 ---- *************** *** 51,72 **** { return null; } - public static Pattern createPattern(LocatedString name, TypeIdent ti) - { return null; } - public static Pattern createPattern(LocatedString name, mlsub.typing.TypeConstructor tc, boolean sure) { return null; } - public static Pattern createPattern(TypeIdent tc, LocatedString name, boolean exactly, TypeIdent additional, mlsub.typing.TypeConstructor runtimeTC) - { return null; } - - public static Pattern createPattern(ConstantExp value) - { return null; } - - public static Pattern createPattern(ConstantExp value, TypeIdent additional) - { return null; } - - public static Pattern createPattern(String kind, LocatedString name, ConstantExp value, LocatedString refName, bossa.util.Location loc) - { return null; } - public static boolean leq(Pattern a, Pattern b) { return false; } --- 48,54 ---- *************** *** 75,81 **** { return false; } - static Statement analyse(Statement s, VarScope v, TypeScope t, boolean r) - { return null; } - static Statement analyseMethodBody(Statement s, VarScope varScope, TypeScope typeScope, MonoSymbol[] params, boolean mustReturnAValue) { return null; } --- 57,60 ---- *************** *** 109,126 **** } - static bossa.util.UserError assignmentError - (bossa.util.Located responsible, - String target, - String targetType, - Expression value) - { return null; } - public static void _printStackTraceWithSourceInfo(Throwable t) {} } - class UnknownIdentException extends bossa.util.UserError - { - LocatedString ident; - } - class Info {} --- 88,93 ---- |
From: Arjan B. <ar...@us...> - 2004-12-08 23:04:21
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14725/F:/nice/src/bossa/syntax Modified Files: tools.nice typedef.nice Added Files: constraint.nice Removed Files: ImplementsCst.java MonotypeLeqCst.java TypeConstructorLeqCst.java Log Message: Converted AtomicConstraint subclasses. --- TypeConstructorLeqCst.java DELETED --- Index: typedef.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typedef.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** typedef.nice 1 Dec 2004 02:00:32 -0000 1.3 --- typedef.nice 8 Dec 2004 23:03:37 -0000 1.4 *************** *** 407,412 **** 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]))); } --- 407,412 ---- bossa.syntax.Monotype v = bossa.syntax.Monotype.create(mvar); ! atoms.add(new MonotypeLeqCst(m1: bossa.syntax.Monotype.create(params[i]), m2: v)); ! atoms.add(new MonotypeLeqCst(m1: v, m2: bossa.syntax.Monotype.create(params[i]))); } --- ImplementsCst.java DELETED --- Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** tools.nice 6 Dec 2004 23:32:23 -0000 1.69 --- tools.nice 8 Dec 2004 23:03:37 -0000 1.70 *************** *** 251,254 **** --- 251,256 ---- 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); + ?String getParentFor(AtomicConstraint, mlsub.typing.TypeConstructor) = native String AtomicConstraint.getParentFor(mlsub.typing.TypeConstructor); + mlsub.typing.AtomicConstraint resolve(AtomicConstraint, TypeScope) = native mlsub.typing.AtomicConstraint AtomicConstraint.resolve(TypeScope); // Retypings needed since java types are not strict. --- NEW FILE: constraint.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.*; /** Syntactic inequality between monotypes. */ public class MonotypeLeqCst extends AtomicConstraint { Monotype m1; Monotype m2; resolve(ts) { return new mlsub.typing.MonotypeLeqCst (m1.resolve(ts), m2.resolve(ts)); } toString() = m1 + " <: " + m2; } /** Inequality between TypeConstructors. */ public class TypeConstructorLeqCst extends AtomicConstraint { mlsub.typing.TypeConstructor t1; TypeIdent t2; resolve(ts) { // If t2 resolve to an interface definition, // this constraint meant t1 implements t2 let s = t2.resolveToTypeSymbol(ts); if (s instanceof mlsub.typing.Interface) return new mlsub.typing.ImplementsCst(t1, s); if (!(s instanceof mlsub.typing.TypeConstructor)) throw User.error(t2, t2 + " is not a class"); let c2 = getTypeDefinition(s); if (c2 != null) { let associatedInterface = c2.getAssociatedInterface(); if (associatedInterface!=null) return new mlsub.typing.ImplementsCst(t1, associatedInterface); } return new mlsub.typing.TypeConstructorLeqCst(t1, s); } toString() = t1 + " <: " + t2; getParentFor(tc) { if (this.t1 == tc) return t2.toString(); else return null; } } /** A type constructor implements an interface. */ public class ImplementsCst extends AtomicConstraint { TypeIdent tc; TypeIdent itf; resolve(scope) { TypeConstructor stc = tc.resolveToTC(scope); TypeSymbol sitf = itf.resolveToTypeSymbol(scope); if (! (sitf instanceof Interface)) throw User.error(itf, itf+" should be an interface"); return new mlsub.typing.ImplementsCst(stc, sitf); } toString() = tc + ":" + itf; } --- MonotypeLeqCst.java DELETED --- |
From: Arjan B. <ar...@us...> - 2004-12-08 20:01:10
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6059/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Converted char and boolean ConstantExp. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.280 retrieving revision 1.281 diff -C2 -d -r1.280 -r1.281 *** Parser.jj 7 Dec 2004 17:33:56 -0000 1.280 --- Parser.jj 8 Dec 2004 20:00:57 -0000 1.281 *************** *** 1606,1611 **** { Token t; } { ! t = "true" { return ConstantExp.makeBoolean(true, makeLocation(t)); } ! | t = "false" { return ConstantExp.makeBoolean(false, makeLocation(t)); } } --- 1606,1611 ---- { Token t; } { ! t = "true" { return bossa.syntax.dispatch.createBooleanConstant(true, makeLocation(t)); } ! | t = "false" { return bossa.syntax.dispatch.createBooleanConstant(false, makeLocation(t)); } } *************** *** 1638,1642 **** { t = <CHARACTER_LITERAL> ! { return ConstantExp.makeChar (new LocatedString(t.image.substring(1, t.image.length() - 1), makeLocation(t))); --- 1638,1642 ---- { t = <CHARACTER_LITERAL> ! { return bossa.syntax.dispatch.createCharConstant (new LocatedString(t.image.substring(1, t.image.length() - 1), makeLocation(t))); |
From: Arjan B. <ar...@us...> - 2004-12-08 20:01:09
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6059/F:/nice/src/bossa/syntax Modified Files: ConstantExp.java constant.nice pattern.nice Log Message: Converted char and boolean ConstantExp. Index: constant.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/constant.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** constant.nice 1 Dec 2004 02:00:32 -0000 1.3 --- constant.nice 8 Dec 2004 20:00:58 -0000 1.4 *************** *** 45,48 **** --- 45,84 ---- } + class BooleanConstantExp extends ConstantExp + { + private gnu.expr.QuoteExp compiledValue; + + isFalse() = compiledValue == gnu.expr.QuoteExp.falseExp; + isTrue() = compiledValue == gnu.expr.QuoteExp.trueExp; + + compile() = compiledValue; + } + + public ConstantExp createBooleanConstant(boolean value, Location location) + { + return new BooleanConstantExp(nice.tools.typing.PrimitiveType.boolTC, + value, value ? "true" : "false", location, + compiledValue: notNull(value ? gnu.expr.QuoteExp.trueExp : gnu.expr.QuoteExp.falseExp)); + } + + class CharConstantExp extends ConstantExp + { + longValue() + { + Character val = cast(this.value); + return int(val.charValue()); + } + } + + public ConstantExp createCharConstant(LocatedString value) + { + let s = unescapeLiteral(value.toString()); + if (s.length() != 1) + User.error(value, "Invalid character constant: " + value); + + return new CharConstantExp(nice.tools.typing.PrimitiveType.charTC, + s[0], "'" + s + "'", value.location()); + } + /** The void constant. Index: pattern.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/pattern.nice,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** pattern.nice 1 Dec 2004 02:00:32 -0000 1.10 --- pattern.nice 8 Dec 2004 20:00:58 -0000 1.11 *************** *** 150,155 **** addValues(values) { ! values.add(ConstantExp.makeBoolean(true, this.location)); ! values.add(ConstantExp.makeBoolean(false, this.location)); } --- 150,155 ---- addValues(values) { ! values.add(createBooleanConstant(true, this.location)); ! values.add(createBooleanConstant(false, this.location)); } *************** *** 598,603 **** { if (name[0] == '\'') ! return createPattern(new ConstantExp(nice.tools.typing.PrimitiveType.charTC, ! new Character(name[1]), name, loc)); if (name[0] == '-') --- 598,603 ---- { if (name[0] == '\'') ! return createPattern(new CharConstantExp(nice.tools.typing.PrimitiveType.charTC, ! name[1], name, loc)); if (name[0] == '-') *************** *** 632,636 **** if (name.equals("true") || name.equals("false") ) ! return createPattern(ConstantExp.makeBoolean(name.equals("true"), loc)); ?TypeSymbol sym = Node.getGlobalTypeScope().lookup(name); --- 632,636 ---- if (name.equals("true") || name.equals("false") ) ! return createPattern(createBooleanConstant(name.equals("true"), loc)); ?TypeSymbol sym = Node.getGlobalTypeScope().lookup(name); Index: ConstantExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/ConstantExp.java,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** ConstantExp.java 1 Dec 2004 02:00:31 -0000 1.54 --- ConstantExp.java 8 Dec 2004 20:00:58 -0000 1.55 *************** *** 68,72 **** public boolean isNumber() { ! return this.value instanceof Number && !(this.value instanceof Character); } --- 68,72 ---- public boolean isNumber() { ! return this.value instanceof Number; } *************** *** 105,155 **** ****************************************************************/ - public static ConstantExp makeChar(LocatedString value) - { - String s = value.toString(); - char c; - - findChar: - if (s.length() != 0 && s.charAt(0) == '\\') - // \ escape sequence. See JLS 3.10.6 - { - if (s.length() == 2) - { - char c2 = s.charAt(1); - switch(c2) - { - case 'b' : c = '\b'; break findChar; - case 't' : c = '\t'; break findChar; - case 'n' : c = '\n'; break findChar; - case 'f' : c = '\f'; break findChar; - case 'r' : c = '\r'; break findChar; - case '\"': c = '\"'; break findChar; - case '\'': c = '\''; break findChar; - case '\\': c = '\\'; break findChar; - } - } - - try{ - int code = Integer.parseInt(s.substring(1), 8); - if(code<0 || code>255) - throw new NumberFormatException(); - c = (char) code; - } - catch(NumberFormatException e){ - throw User.error(value, "Invalid escape sequence: " + value); - } - } - else - { - if(s.length()!=1) - User.error(value, "Invalid character constant: " + value); - - c = s.charAt(0); - } - - return new ConstantExp(PrimitiveType.charTC, new Character(c), - "'" + s + "'", value.location()); - } - private static ConstantExp makeInt(long value, boolean isLong, Location location) --- 105,108 ---- *************** *** 285,334 **** } - /**************************************************************** - * Booleans - ****************************************************************/ - - public static ConstantExp makeBoolean(boolean value, Location location) - { - return new ConstantExp.Boolean(value, location); - } - - private static class Boolean extends ConstantExp - { - Boolean(boolean value, Location location) - { - super(PrimitiveType.boolTC, value ? "true" : "false", location); - compiledValue = value ? QuoteExp.trueExp : QuoteExp.falseExp; - } - - boolean isFalse() - { - return compiledValue == QuoteExp.falseExp; - } - - boolean isTrue() - { - return compiledValue == QuoteExp.trueExp; - } - - protected gnu.expr.Expression compile() - { - return compiledValue; - } - - public boolean equals(Object other) - { - return other instanceof ConstantExp.Boolean && - (isTrue() == ((ConstantExp.Boolean)other).isTrue()); - } - - private QuoteExp compiledValue; - } - public long longValue() { - if (value instanceof Character) - return ((Character)value).charValue(); - return ((Number)value).longValue(); } --- 238,243 ---- *************** *** 336,342 **** public boolean equals(Object other) { - if (other instanceof ConstantExp.Boolean) - return false; - return other instanceof ConstantExp && value.equals(((ConstantExp)other).value); --- 245,248 ---- |
From: Arjan B. <ar...@us...> - 2004-12-08 01:10:42
|
Update of /cvsroot/nice/Nice/testsuite/compiler/classes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31914/F:/nice/testsuite/compiler/classes Modified Files: native.testsuite Log Message: Testcase for bug where a retyping of a constructor makes static fields/functions not accessable. Index: native.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/classes/native.testsuite,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** native.testsuite 30 Nov 2003 14:24:35 -0000 1.8 --- native.testsuite 8 Dec 2004 01:10:27 -0000 1.9 *************** *** 56,57 **** --- 56,63 ---- /// package b import a {} + + /// PASS bug + // retyping of constructor should not break usage of static fields/functions + String str = String.valueOf(true); + /// Toplevel + String String(char[]) = native new String(char[]); |
From: Arjan B. <ar...@us...> - 2004-12-07 17:59:33
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26604/F:/nice/src/bossa/syntax Removed Files: DuplicateIdentEx.java Log Message: Removed unused class. --- DuplicateIdentEx.java DELETED --- |
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19096/F:/nice/src/bossa/syntax Modified Files: Contract.java analyse.nice assign.nice dispatch.java.bootstrap enum.nice loop.nice Added Files: ident.nice Removed Files: IdentExp.java Log Message: Converted IdentExp. Index: analyse.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/analyse.nice,v retrieving revision 1.116 retrieving revision 1.117 diff -C2 -d -r1.116 -r1.117 *** analyse.nice 4 Dec 2004 19:38:18 -0000 1.116 --- analyse.nice 7 Dec 2004 17:33:57 -0000 1.117 *************** *** 478,482 **** Expression analyseIdent(IdentExp e, Info info, boolean assigned) { ! if (!e.infix) // infix symbols can only come from the global scope { ?VarSymbol sym = info.lookup(notNull(e.ident).toString()); --- 478,482 ---- Expression analyseIdent(IdentExp e, Info info, boolean assigned) { ! if (!e.isInfix()) // infix symbols can only come from the global scope { ?VarSymbol sym = info.lookup(notNull(e.ident).toString()); *************** *** 508,512 **** ?List<VarSymbol> symbols; ! if (e.infix) symbols = cast(notNull(Node.getGlobalScope()).lookup(e.ident)); else --- 508,512 ---- ?List<VarSymbol> symbols; ! if (e.isInfix()) symbols = cast(notNull(Node.getGlobalScope()).lookup(e.ident)); else Index: loop.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/loop.nice,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** loop.nice 13 Oct 2004 20:42:21 -0000 1.5 --- loop.nice 7 Dec 2004 17:33:57 -0000 1.6 *************** *** 140,149 **** } ! let getiter = createCallExp(new IdentExp(new LocatedString("forIterator", loc)), container); let iter = new LocatedString(loc.uniqueIdentifier("for_in_iter_"), loc); let init = new LocalVariable(iter, itertype, true, getiter); ! let iterexp = new IdentExp(iter); ! let cond = createCallExp(new IdentExp(new LocatedString("hasNext", loc)), iterexp); ! let getvar = createCallExp(new IdentExp(new LocatedString("next", loc)), iterexp); let assign = new LocalVariable(varName, vartype, true, getvar); let loop = createWhileLoop(cond, createBlock(new LinkedList([assign, body]))); --- 140,149 ---- } ! let getiter = createCallExp(createIdentExp(new LocatedString("forIterator", loc)), container); let iter = new LocatedString(loc.uniqueIdentifier("for_in_iter_"), loc); let init = new LocalVariable(iter, itertype, true, getiter); ! let iterexp = createIdentExp(iter); ! let cond = createCallExp(createIdentExp(new LocatedString("hasNext", loc)), iterexp); ! let getvar = createCallExp(createIdentExp(new LocatedString("next", loc)), iterexp); let assign = new LocalVariable(varName, vartype, true, getvar); let loop = createWhileLoop(cond, createBlock(new LinkedList([assign, body]))); Index: assign.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/assign.nice,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** assign.nice 13 Oct 2004 23:22:22 -0000 1.4 --- assign.nice 7 Dec 2004 17:33:57 -0000 1.5 *************** *** 45,49 **** return createCallExp( ! new IdentExp(new LocatedString("set", to.function.location())), new Arguments(args)); } --- 45,49 ---- return createCallExp( ! createIdentExp(new LocatedString("set", to.function.location())), new Arguments(args)); } Index: enum.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/enum.nice,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** enum.nice 1 Dec 2004 02:00:32 -0000 1.6 --- enum.nice 7 Dec 2004 17:33:57 -0000 1.7 *************** *** 80,84 **** globalDefs.add(createMethodBodyDefinition(impl, new LocatedString("family"), null, new LinkedList(), createReturnStmt(createLiteralArrayExp( ! elements.map(LocatedString elem => new IdentExp(elem))), true))); //generate the prettyprint string --- 80,84 ---- globalDefs.add(createMethodBodyDefinition(impl, new LocatedString("family"), null, new LinkedList(), createReturnStmt(createLiteralArrayExp( ! elements.map(createIdentExp)), true))); //generate the prettyprint string Index: dispatch.java.bootstrap =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/dispatch.java.bootstrap,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** dispatch.java.bootstrap 4 Dec 2004 19:38:18 -0000 1.29 --- dispatch.java.bootstrap 7 Dec 2004 17:33:57 -0000 1.30 *************** *** 13,16 **** --- 13,19 ---- public class dispatch { + public static Expression createIdentExp(LocatedString i) + { return null; } + public static Expression createSymbolExp(VarSymbol symbol, bossa.util.Location loc) { return null; } Index: Contract.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Contract.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Contract.java 13 Oct 2004 20:42:21 -0000 1.10 --- Contract.java 7 Dec 2004 17:33:57 -0000 1.11 *************** *** 73,77 **** private Expression symbol(String name, Located loc) { ! return new IdentExp(new LocatedString(name, loc.location())); } --- 73,77 ---- private Expression symbol(String name, Located loc) { ! return dispatch.createIdentExp(new LocatedString(name, loc.location())); } --- NEW FILE: ident.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.*; /** Identifier supposed to be a variable (not a type). */ public class IdentExp extends Expression { final LocatedString ident; private boolean infix = false; /** Resolve to a ClassExp or a PackageExp if ident is not known. */ boolean enableClassExp = false; /** Force production of overloaded symbol exp, even if there is just one case. */ boolean alwaysOverloadedSymbol = false; computeType() { Internal.error(this, "computeType in IdentExp (" + this + ")"); } compile() { throw Internal.error("compile in IdentExp"); } toString() = ident.toString(); toString(param) { if (param == Printable.parsable) return "`" + ident.toString() + "`"; return this.toString(); } /** This ident is the function part of an infix call. */ boolean isInfix() = infix; void setInfix() { infix = true; } } public Expression createIdentExp(LocatedString i) { let res = new IdentExp(ident: i); res.setLocation(i.location()); return res; } --- IdentExp.java DELETED --- |
From: Arjan B. <ar...@us...> - 2004-12-07 17:34:07
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19096/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Converted IdentExp. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.279 retrieving revision 1.280 diff -C2 -d -r1.279 -r1.280 *** Parser.jj 1 Dec 2004 02:00:11 -0000 1.279 --- Parser.jj 7 Dec 2004 17:33:56 -0000 1.280 *************** *** 39,57 **** public class Parser { ! private static IdentExp symb(String name, Token t, boolean quoted) { ! return new IdentExp(new LocatedString(name, makeLocation(t),quoted)); } ! private static IdentExp symb(String name, Token t) { return symb(name,t,true); } ! private static IdentExp symb(Token t) { return symb(t.image,t); } ! private static IdentExp symb(String name, Location loc) { ! return new IdentExp(new LocatedString(name, loc)); } --- 39,57 ---- public class Parser { ! private static Expression symb(String name, Token t, boolean quoted) { ! return bossa.syntax.dispatch.createIdentExp(new LocatedString(name, makeLocation(t),quoted)); } ! private static Expression symb(String name, Token t) { return symb(name,t,true); } ! private static Expression symb(Token t) { return symb(t.image,t); } ! private static Expression symb(String name, Location loc) { ! return bossa.syntax.dispatch.createIdentExp(new LocatedString(name, loc)); } *************** *** 839,843 **** { monotypes.add(type); statements.add(bossa.syntax.dispatch.createLocalVariable(id, type, false, null)); ! return new IdentExp(id); } | { Token first,last; } first="(" --- 839,843 ---- { monotypes.add(type); statements.add(bossa.syntax.dispatch.createLocalVariable(id, type, false, null)); ! return bossa.syntax.dispatch.createIdentExp(id); } | { Token first,last; } first="(" *************** *** 880,884 **** makeLocation(first, last)); } else { ident = id; } ! Expression exp = bossa.syntax.dispatch.createAssignExp(new TupleExp(parts),new IdentExp(ident)); exp.setLocation(makeLocation(first,last)); statements.add(bossa.syntax.dispatch.createExpressionStmt(exp)); --- 880,884 ---- makeLocation(first, last)); } else { ident = id; } ! Expression exp = bossa.syntax.dispatch.createAssignExp(new TupleExp(parts),bossa.syntax.dispatch.createIdentExp(ident)); exp.setLocation(makeLocation(first,last)); statements.add(bossa.syntax.dispatch.createExpressionStmt(exp)); *************** *** 1660,1668 **** } ! IdentExp identExp(): { LocatedString i; } { i=identOrBackquoted() ! { return new IdentExp(i); } } --- 1660,1668 ---- } ! Expression identExp(): { LocatedString i; } { i=identOrBackquoted() ! { return bossa.syntax.dispatch.createIdentExp(i); } } *************** *** 1746,1750 **** makeLocation(first, last)); } else { name = ident; } ! Expression exp = bossa.syntax.dispatch.createAssignExp(new TupleExp(parts),new IdentExp(name)); exp.setLocation(makeLocation(first,last)); statements.add(bossa.syntax.dispatch.createExpressionStmt(exp)); --- 1746,1750 ---- makeLocation(first, last)); } else { name = ident; } ! Expression exp = bossa.syntax.dispatch.createAssignExp(new TupleExp(parts),bossa.syntax.dispatch.createIdentExp(name)); exp.setLocation(makeLocation(first,last)); statements.add(bossa.syntax.dispatch.createExpressionStmt(exp)); *************** *** 2514,2522 **** ( //first look for a ident without matching a monotype LOOKAHEAD( doted_string() ( "," | ")" ) ) id=doted_string() ! { return new IdentExp(id); } | //then look for a monotype without matching a tuplePart LOOKAHEAD( monotype() ident() ) type=monotype() id=ident() { statements.add(bossa.syntax.dispatch.createLocalVariable(id, type, false, null)); ! return new IdentExp(id); } | //otherwise it's localtuple part "(" { List parts = new LinkedList(); Expression part; } --- 2514,2522 ---- ( //first look for a ident without matching a monotype LOOKAHEAD( doted_string() ( "," | ")" ) ) id=doted_string() ! { return bossa.syntax.dispatch.createIdentExp(id); } | //then look for a monotype without matching a tuplePart LOOKAHEAD( monotype() ident() ) type=monotype() id=ident() { statements.add(bossa.syntax.dispatch.createLocalVariable(id, type, false, null)); ! return bossa.syntax.dispatch.createIdentExp(id); } | //otherwise it's localtuple part "(" { List parts = new LinkedList(); Expression part; } |