nice-commit Mailing List for The Nice Programming Language (Page 99)
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: <bo...@us...> - 2003-06-19 18:34:02
|
Update of /cvsroot/nice/Nice/testsuite/compiler/enums In directory sc8-pr-cvs1:/tmp/cvs-serv27242/testsuite/compiler/enums Added Files: serializazion.testsuite Log Message: Checks that serialization/deserialization preserves the identity of enum values. --- NEW FILE: serializazion.testsuite --- /// PASS let filename = "color.ser"; let outf = new FileOutputStream(filename); let outs = new ObjectOutputStream(outf); outs.writeObject(red); outf.close(); let inf = new FileInputStream(filename); let ins = new ObjectInputStream(inf); let Color color = ins.readObject(); assert color == red; /// Toplevel import java.io.*; enum Color {red, blue, green} |
From: <bo...@us...> - 2003-06-19 18:32:58
|
Update of /cvsroot/nice/Nice/testsuite/compiler/enums In directory sc8-pr-cvs1:/tmp/cvs-serv27079/testsuite/compiler/enums Log Message: Directory /cvsroot/nice/Nice/testsuite/compiler/enums added to the repository |
From: <ar...@us...> - 2003-06-19 16:02:05
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv3637/F:/nice/src/bossa/syntax Modified Files: Pattern.java Log Message: added a simple kind of enums. Index: Pattern.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Pattern.java,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** Pattern.java 19 Jun 2003 15:32:00 -0000 1.58 --- Pattern.java 19 Jun 2003 16:02:02 -0000 1.59 *************** *** 131,135 **** --- 131,152 ---- patternType = new MonotypeConstructor(tc, def.getTypeParameters()); } + + private static VarSymbol findRefSymbol(LocatedString refName) + { + VarSymbol symbol = null; + for (Iterator it = Node.getGlobalScope().lookup(refName).iterator(); it.hasNext();) + { + Object sym = it.next(); + if (sym instanceof GlobalVarDeclaration.GlobalVarSymbol || + sym instanceof EnumDefinition.EnumSymbol ) + symbol = (VarSymbol)sym; + } + + if (symbol == null) + User.error(refName, "" + refName + " is not declared"); + return symbol; + } + void resolveGlobalConstants(VarScope scope, TypeScope typeScope) { *************** *** 137,153 **** return; ! GlobalVarDeclaration.GlobalVarSymbol symbol = null; ! for (Iterator it = scope.lookup(refName).iterator(); it.hasNext();) { ! Object sym = it.next(); ! if (sym instanceof GlobalVarDeclaration.GlobalVarSymbol) ! symbol = (GlobalVarDeclaration.GlobalVarSymbol)sym; } ! if (symbol == null || !symbol.constant) ! User.error(refName, "" + refName + " is not declared as global constant"); ! if (symbol.getValue() instanceof ConstantExp) { ConstantExp val = (ConstantExp)symbol.getValue(); --- 154,176 ---- return; ! VarSymbol sym = findRefSymbol(refName); ! if (sym instanceof EnumDefinition.EnumSymbol) { ! EnumDefinition.EnumSymbol symbol = (EnumDefinition.EnumSymbol)sym; ! NewExp val = (NewExp)symbol.getValue(); ! ! symbol.getDefinition().resolve(); ! tc = val.tc; ! atValue = new ConstantExp(null, tc, symbol, ! refName.toString(), location); ! return; } ! GlobalVarDeclaration.GlobalVarSymbol symbol = (GlobalVarDeclaration.GlobalVarSymbol)sym; if (symbol.getValue() instanceof ConstantExp) { + if (!symbol.constant) + User.error(refName, "" + refName + " is not constant"); + ConstantExp val = (ConstantExp)symbol.getValue(); *************** *** 166,177 **** symbol.getDefinition().resolve(); ! if (val.tc != null) ! { ! tc = val.tc; ! atValue = new ConstantExp(null, tc, symbol, refName.toString(), location); - } - else - Internal.error("can't find tc of globalvarsymbol of "+refName); } else --- 189,195 ---- symbol.getDefinition().resolve(); ! tc = val.tc; ! atValue = new ConstantExp(null, tc, symbol, refName.toString(), location); } else *************** *** 186,190 **** } } ! /**************************************************************** * Type checking --- 204,208 ---- } } ! /**************************************************************** * Type checking *************** *** 328,331 **** --- 346,352 ---- return that.tc == PrimitiveType.boolTC; + if (this.atEnum() && that.atEnum()) + return this.atValue.toString().compareTo(that.atValue.toString()) < 0; + if (that.atNonBoolValue()) return this.atNonBoolValue() && this.atValue.equals(that.atValue); *************** *** 349,353 **** return false; ! if (atNonBoolValue()) return false; --- 370,374 ---- return false; ! if (atNonBoolValue() && !atEnum()) return false; *************** *** 392,396 **** User.error(location, "A pattern cannot have a primitive type that is different from the declaration."); } ! /**************************************************************** * Printing --- 413,432 ---- User.error(location, "A pattern cannot have a primitive type that is different from the declaration."); } ! ! public List getEnumValues () ! { ! List res = new LinkedList(); ! if (!atEnum()) ! return res; ! ! List symbols = ((EnumDefinition)((EnumDefinition.EnumSymbol)atValue.value).getDefinition()).symbols; ! for (Iterator it = symbols.iterator(); it.hasNext(); ) ! { ! EnumDefinition.EnumSymbol sym = (EnumDefinition.EnumSymbol)it.next(); ! res.add(new ConstantExp(null, tc, sym, sym.name.toString(), location)); ! } ! ! return res; ! } /**************************************************************** * Printing *************** *** 503,525 **** LocatedString refName = new LocatedString(name.substring(1), Location.nowhere()); - GlobalVarDeclaration.GlobalVarSymbol symbol = null; - for (Iterator it = Node.getGlobalScope().lookup(refName).iterator(); it.hasNext();) - { - Object sym = it.next(); - if (sym instanceof GlobalVarDeclaration.GlobalVarSymbol) - symbol = (GlobalVarDeclaration.GlobalVarSymbol)sym; - } ! if (symbol == null) ! Internal.error("can't find globalvarsymbol of "+refName); ! ! NewExp val = (NewExp)symbol.getValue(); ! ! symbol.getDefinition().resolve(); ! if (val.tc != null) ! return new Pattern(new ConstantExp(null, val.tc, symbol, ! refName.toString(), refName.location())); else ! Internal.error("can't find tc of globalvarsymbol of "+refName); } } --- 539,560 ---- LocatedString refName = new LocatedString(name.substring(1), Location.nowhere()); ! VarSymbol sym = findRefSymbol(refName); ! NewExp val; ! if (sym instanceof GlobalVarDeclaration.GlobalVarSymbol ) ! { ! GlobalVarDeclaration.GlobalVarSymbol symbol = (GlobalVarDeclaration.GlobalVarSymbol)sym; ! val = (NewExp)symbol.getValue(); ! symbol.getDefinition().resolve(); ! } else ! { ! EnumDefinition.EnumSymbol symbol = (EnumDefinition.EnumSymbol) sym; ! val = (NewExp)symbol.getValue(); ! symbol.getDefinition().resolve(); ! } ! ! return new Pattern(new ConstantExp(null, val.tc, sym, ! refName.toString(), refName.location())); } } *************** *** 619,621 **** --- 654,657 ---- public boolean atString() { return atValue instanceof StringConstantExp; } public boolean atReference() { return atValue != null && atValue.value instanceof VarSymbol; } + public boolean atEnum() { return atReference() && atValue.value instanceof EnumDefinition.EnumSymbol; } } |
From: <ar...@us...> - 2003-06-19 15:57:28
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv2812/F:/nice/src/bossa/syntax Modified Files: AST.java Added Files: EnumDefinition.java Log Message: added a simple kind of enums. --- NEW FILE: EnumDefinition.java --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2003 */ /* */ /* 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.*; import nice.tools.code.Types; import gnu.bytecode.*; import gnu.expr.Declaration; import java.util.*; /** */ public class EnumDefinition extends Definition { public EnumDefinition(LocatedString name, List/*LocatedString*/ elements) { super(name, Node.global); shortName = name.toString(); classDef = ClassDefinition.makeClass (name,true,false, null, new ArrayList(0),null,null,null); NiceClass impl = new NiceClass(classDef); impl.setFields(new ArrayList(0)); classDef.setImplementation(impl); addChild(classDef); this.elements = elements; symbols = new LinkedList(); for (Iterator it = elements.iterator(); it.hasNext(); ) { Monotype type = new TypeIdent(name); type.nullness = Monotype.absent; symbols.add(new EnumSymbol(name, (LocatedString)it.next(), type)); } addChildren(symbols); } class EnumSymbol extends MonoSymbol { EnumSymbol(LocatedString enumName, LocatedString name, Monotype type) { super(name, type); this.value = new NewExp(new TypeIdent(enumName), Arguments.noArguments()); } boolean isAssignable() { return false; } Declaration getDeclaration() { Declaration res = super.getDeclaration(); if (res == null) { res = module.addGlobalVar(name.toString(), Types.javaType(type), true); setDeclaration(res); } return res; } Expression getValue() { return value; } Definition getDefinition() { return EnumDefinition.this; } Expression value; } public Collection associatedDefinitions() { return null; } void resolve() { for (Iterator it = symbols.iterator(); it.hasNext(); ) { EnumSymbol symbol = (EnumSymbol)it.next(); symbol.value = bossa.syntax.dispatch.analyse(symbol.value, scope, typeScope); } } /**************************************************************** * Type checking ****************************************************************/ void typecheck() { for (Iterator it = symbols.iterator(); it.hasNext(); ) { EnumSymbol symbol = (EnumSymbol)it.next(); try{ symbol.value = symbol.value.resolveOverloading(symbol.getType()); bossa.syntax.dispatch.typecheck(symbol.value); Typing.leq(symbol.value.getType(),symbol.getType()); } catch(TypingEx e){ Internal.error(this,"Typing error in enum:"); } } } /**************************************************************** * Module interface ****************************************************************/ public void printInterface(java.io.PrintWriter s) { s.print(toString()+"\n"); } /**************************************************************** * Code generation ****************************************************************/ public void compile() { for (Iterator it = symbols.iterator(); it.hasNext(); ) { EnumSymbol symbol = (EnumSymbol)it.next(); gnu.expr.Declaration declaration = symbol.getDeclaration(); declaration.setFlag(Declaration.IS_CONSTANT); declaration.noteValue(symbol.value.compile()); } } /**************************************************************** * Printing ****************************************************************/ public String toString() { return "enum " + shortName + Util.map(" {", " , ", " }", elements); } String shortName; ClassDefinition classDef; List elements; List symbols; } Index: AST.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/AST.java,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** AST.java 14 Jun 2003 14:20:38 -0000 1.44 --- AST.java 19 Jun 2003 15:57:23 -0000 1.45 *************** *** 50,53 **** --- 50,55 ---- else if (node instanceof MethodDeclaration) methods.add(node); + else if (node instanceof EnumDefinition) + classes.add(((EnumDefinition)node).classDef); } |
From: <ar...@us...> - 2003-06-19 15:57:28
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1:/tmp/cvs-serv2812/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: added a simple kind of enums. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.188 retrieving revision 1.189 diff -C2 -d -r1.188 -r1.189 *** Parser.jj 16 Jun 2003 15:12:08 -0000 1.188 --- Parser.jj 19 Jun 2003 15:57:23 -0000 1.189 *************** *** 148,151 **** --- 148,152 ---- | < IMPLEMENTS: "implements" > | < EXTENDS: "extends" > + | < ENUM: "enum" > // Packages *************** *** 1231,1234 **** --- 1232,1250 ---- } + EnumDefinition enumDefinition(): + { + LocatedString name, elem; + List elements = new LinkedList(); + } + { + [ "public" | "private" ] + "enum" + name=ident() + "{" elem=ident() { elements.add(elem); } + ( "," elem =ident() { elements.add(elem); } )+ + "}" + { return new EnumDefinition(name, elements); } + } + /***********************************************************************/ /* Methods */ *************** *** 1548,1551 **** --- 1564,1570 ---- res=globalVariable() | + LOOKAHEAD(2) + res=enumDefinition() + | LOOKAHEAD ( "abstract" "interface" ) res=interfaceDefinition() |
From: <ar...@us...> - 2003-06-19 15:57:27
|
Update of /cvsroot/nice/Nice/src/bossa/link In directory sc8-pr-cvs1:/tmp/cvs-serv2812/F:/nice/src/bossa/link Modified Files: Dispatch.java Log Message: added a simple kind of enums. Index: Dispatch.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/link/Dispatch.java,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** Dispatch.java 19 Jun 2003 15:32:00 -0000 1.56 --- Dispatch.java 19 Jun 2003 15:57:23 -0000 1.57 *************** *** 290,294 **** Alternative first = null; ConstantExp[] values = (ConstantExp[]) valit.next(); ! for (Iterator i = sortedTypeMatches.iterator(); i.hasNext() && !failed;) { Alternative a = (Alternative) i.next(); --- 290,295 ---- Alternative first = null; ConstantExp[] values = (ConstantExp[]) valit.next(); ! outer: ! for (Iterator i = sortedTypeMatches.iterator(); i.hasNext();) { Alternative a = (Alternative) i.next(); *************** *** 305,308 **** --- 306,310 ---- "\nboth\n" + first.printLocated() + "\nand\n" + a.printLocated() + "\nmatch."); + break outer; } } *************** *** 314,317 **** --- 316,320 ---- "no alternative matches " + toString(tags, values, isValue)); + break; } } *************** *** 516,529 **** for (int pos = 0; pos < len; pos++) { ! ConstantExp[] valuesAtPos = new ConstantExp[alternatives.size()]; ! int valueCount = 0; for (Iterator i = alternatives.iterator(); i.hasNext(); ) { Pattern pat = ((Alternative)i.next()).getPatterns()[pos]; ! if (pat.atNonBoolValue()) { isValue[pos] = true; ! valuesAtPos[valueCount++] = pat.atValue; } } if (valueCount > 0) { --- 519,541 ---- for (int pos = 0; pos < len; pos++) { ! List valuesAtPosList = new LinkedList(); for (Iterator i = alternatives.iterator(); i.hasNext(); ) { Pattern pat = ((Alternative)i.next()).getPatterns()[pos]; ! if (pat.atNonBoolValue()) ! { isValue[pos] = true; ! if (pat.atEnum()) ! for (Iterator it = pat.getEnumValues().iterator(); it.hasNext(); ) ! valuesAtPosList.add(it.next()); ! ! else ! valuesAtPosList.add(pat.atValue); } } + int valueCount = valuesAtPosList.size(); + ConstantExp[] valuesAtPos = new ConstantExp[valueCount]; + valuesAtPosList.toArray(valuesAtPos); + if (valueCount > 0) { |
From: <ar...@us...> - 2003-06-19 15:57:27
|
Update of /cvsroot/nice/Nice/testsuite/compiler/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv2812/F:/nice/testsuite/compiler/syntax Added Files: enum.testsuite Log Message: added a simple kind of enums. --- NEW FILE: enum.testsuite --- /// PASS assert foo(blue); /// Toplevel enum Color {red, blue, green} boolean foo(Color); foo(=red) = false; foo(=blue) = true; foo(=green) = false; /// PASS /// package a /// Toplevel enum Color {red, blue, green} boolean foo(Color); foo(=red) = false; foo(=blue) = true; foo(=green) = false; /// package b import a assert foo(blue); /// FAIL /// Toplevel enum Color {red, blue, green} void foo(Color); foo(=red) = {}; foo(=blue) = {}; /// PASS assert foo(blue); /// Toplevel enum Color {red, blue, green} boolean foo(Color); foo(x) = false; foo(=blue) = true; foo(=green) = false; /// FAIL /// Toplevel enum Single { thing } /// PASS /// package a /// Toplevel enum Color {red, blue, green} boolean foo(Color); foo(x) = false; /// package b import a assert foo(green); /// Toplevel foo(=red) = false; foo(=blue) = false; foo(=green) = true; |
From: <bo...@us...> - 2003-06-19 15:32:03
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv30616/src/bossa/syntax Modified Files: TupleExp.java Pattern.java OverloadedSymbolExp.java MethodBodyDefinition.java Log Message: Use the Types.rawType, since this is higher-level, and better documenting. Index: TupleExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/TupleExp.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** TupleExp.java 29 May 2003 14:17:19 -0000 1.19 --- TupleExp.java 19 Jun 2003 15:32:00 -0000 1.20 *************** *** 72,76 **** Monotype m = expectedType.getMonotype(); // get rid of the nullness part ! m = ((MonotypeConstructor) m).getTP()[0]; // Get the expected component types --- 72,76 ---- Monotype m = expectedType.getMonotype(); // get rid of the nullness part ! m = Types.rawType((MonotypeConstructor) m); // Get the expected component types Index: Pattern.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Pattern.java,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** Pattern.java 18 Jun 2003 18:12:46 -0000 1.57 --- Pattern.java 19 Jun 2003 15:32:00 -0000 1.58 *************** *** 221,225 **** // the argument is not null Typing.leq(mc.getTC(), PrimitiveType.sureTC); ! Monotype type = mc.getTP()[0]; if (constraint != null) --- 221,225 ---- // the argument is not null Typing.leq(mc.getTC(), PrimitiveType.sureTC); ! Monotype type = Types.rawType(mc); if (constraint != null) Index: OverloadedSymbolExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/OverloadedSymbolExp.java,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** OverloadedSymbolExp.java 28 May 2003 12:57:26 -0000 1.54 --- OverloadedSymbolExp.java 19 Jun 2003 15:32:00 -0000 1.55 *************** *** 24,27 **** --- 24,29 ---- import mlsub.typing.Monotype; + import nice.tools.code.Types; + /** A symbol, for which overloading resolution has yet to be done. *************** *** 362,368 **** { // remove nullness marker ! Monotype[] m = ((FunType) ! ((mlsub.typing.MonotypeConstructor) t.getMonotype()).getTP()[0]) ! .domain(); Monotype[] dom; --- 364,368 ---- { // remove nullness marker ! Monotype[] m = ((FunType) Types.rawType(t.getMonotype())).domain(); Monotype[] dom; Index: MethodBodyDefinition.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MethodBodyDefinition.java,v retrieving revision 1.130 retrieving revision 1.131 diff -C2 -d -r1.130 -r1.131 *** MethodBodyDefinition.java 18 Jun 2003 18:12:46 -0000 1.130 --- MethodBodyDefinition.java 19 Jun 2003 15:32:00 -0000 1.131 *************** *** 303,308 **** Types.setMarkedKind(m1); Types.setMarkedKind(m2); ! Typing.leq(((MonotypeConstructor) m1.equivalent()).getTP()[0], ! ((MonotypeConstructor) m2.equivalent()).getTP()[0]); } void doResolve() --- 303,307 ---- Types.setMarkedKind(m1); Types.setMarkedKind(m2); ! Typing.leq(Types.rawType(m1), Types.rawType(m2)); } void doResolve() |
From: <bo...@us...> - 2003-06-19 15:32:03
|
Update of /cvsroot/nice/Nice/src/bossa/link In directory sc8-pr-cvs1:/tmp/cvs-serv30616/src/bossa/link Modified Files: Dispatch.java Log Message: Use the Types.rawType, since this is higher-level, and better documenting. Index: Dispatch.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/link/Dispatch.java,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** Dispatch.java 12 Jun 2003 18:06:31 -0000 1.55 --- Dispatch.java 19 Jun 2003 15:32:00 -0000 1.56 *************** *** 380,384 **** MonotypeConstructor mc = (MonotypeConstructor) arg; marker = mc.getTC(); ! raw = mc.getTP()[0]; } else --- 380,384 ---- MonotypeConstructor mc = (MonotypeConstructor) arg; marker = mc.getTC(); ! raw = nice.tools.code.Types.rawType(mc); } else |
From: <bo...@us...> - 2003-06-19 15:32:03
|
Update of /cvsroot/nice/Nice/src/mlsub/typing In directory sc8-pr-cvs1:/tmp/cvs-serv30616/src/mlsub/typing Modified Files: TypeConstructorLeqMonotypeCst.java Log Message: Use the Types.rawType, since this is higher-level, and better documenting. Index: TypeConstructorLeqMonotypeCst.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/TypeConstructorLeqMonotypeCst.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TypeConstructorLeqMonotypeCst.java 22 Aug 2002 18:02:03 -0000 1.2 --- TypeConstructorLeqMonotypeCst.java 19 Jun 2003 15:32:00 -0000 1.3 *************** *** 60,64 **** { // Use the raw type of t2, after the nullness marker. ! Typing.leq(t1, ((MonotypeConstructor) t2.equivalent()).getTP()[0]); } --- 60,64 ---- { // Use the raw type of t2, after the nullness marker. ! Typing.leq(t1, nice.tools.code.Types.rawType(t2)); } |
From: <bo...@us...> - 2003-06-19 15:32:03
|
Update of /cvsroot/nice/Nice/src/nice/tools/code In directory sc8-pr-cvs1:/tmp/cvs-serv30616/src/nice/tools/code Modified Files: Types.java Log Message: Use the Types.rawType, since this is higher-level, and better documenting. Index: Types.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/code/Types.java,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** Types.java 24 May 2003 14:16:53 -0000 1.49 --- Types.java 19 Jun 2003 15:32:00 -0000 1.50 *************** *** 651,654 **** --- 651,660 ---- } + /** return the type with nullness markers removed */ + public static Monotype rawType(MonotypeConstructor mc) + { + return mc.getTP()[0]; + } + /** @return the domain of a functional polytype with nullness marker */ public static Monotype[] domain(Polytype type) |
From: <bo...@us...> - 2003-06-19 13:07:54
|
Update of /cvsroot/nice/Nice In directory sc8-pr-cvs1:/tmp/cvs-serv2351 Modified Files: Makefile Log Message: Add src/ to the sourcepath for building ant (for generic solution than the previous change). Index: Makefile =================================================================== RCS file: /cvsroot/nice/Nice/Makefile,v retrieving revision 1.121 retrieving revision 1.122 diff -C2 -d -r1.121 -r1.122 *** Makefile 19 Jun 2003 12:53:11 -0000 1.121 --- Makefile 19 Jun 2003 13:07:50 -0000 1.122 *************** *** 145,150 **** stdlib/nice/lang/Native.java stdlib/nice/lang/inline/*.java \ src/mlsub/compilation/Module.java \ ! src/bossa/modules/Package.java src/bossa/modules/CompilationListener.java \ ! src/bossa/util/*.java \ src/gnu/expr/*.java src/gnu/mapping/*.java \ src/nice/tools/code/*.java src/mlsub/typing/*.java \ --- 145,149 ---- stdlib/nice/lang/Native.java stdlib/nice/lang/inline/*.java \ src/mlsub/compilation/Module.java \ ! src/bossa/modules/Package.java src/bossa/util/*.java \ src/gnu/expr/*.java src/gnu/mapping/*.java \ src/nice/tools/code/*.java src/mlsub/typing/*.java \ *************** *** 162,166 **** ant: @echo "Building the Ant task definition..." ! @${javac} -classpath "/usr/share/java/ant.jar:./external/ant.jar:./classes:./classes.old" -d classes src/nice/tools/ant/Nicec.java ||\ echo "Compilation of the Ant task definition failed.\nAnt should be in the classpath, or linked to by ./external/ant.jar" --- 161,165 ---- ant: @echo "Building the Ant task definition..." ! @${javac} -sourcepath src -classpath "/usr/share/java/ant.jar:./external/ant.jar:./classes:./classes.old" -d classes src/nice/tools/ant/Nicec.java ||\ echo "Compilation of the Ant task definition failed.\nAnt should be in the classpath, or linked to by ./external/ant.jar" |
From: <bo...@us...> - 2003-06-19 12:53:14
|
Update of /cvsroot/nice/Nice In directory sc8-pr-cvs1:/tmp/cvs-serv575 Modified Files: Makefile Log Message: Force compilation of CompilationListener, so it can be used by the ant task. Index: Makefile =================================================================== RCS file: /cvsroot/nice/Nice/Makefile,v retrieving revision 1.120 retrieving revision 1.121 diff -C2 -d -r1.120 -r1.121 *** Makefile 11 Jun 2003 22:24:08 -0000 1.120 --- Makefile 19 Jun 2003 12:53:11 -0000 1.121 *************** *** 145,149 **** stdlib/nice/lang/Native.java stdlib/nice/lang/inline/*.java \ src/mlsub/compilation/Module.java \ ! src/bossa/modules/Package.java src/bossa/util/*.java \ src/gnu/expr/*.java src/gnu/mapping/*.java \ src/nice/tools/code/*.java src/mlsub/typing/*.java \ --- 145,150 ---- stdlib/nice/lang/Native.java stdlib/nice/lang/inline/*.java \ src/mlsub/compilation/Module.java \ ! src/bossa/modules/Package.java src/bossa/modules/CompilationListener.java \ ! src/bossa/util/*.java \ src/gnu/expr/*.java src/gnu/mapping/*.java \ src/nice/tools/code/*.java src/mlsub/typing/*.java \ |
From: <bo...@us...> - 2003-06-18 22:52:50
|
Update of /cvsroot/nice/Nice/distrib In directory sc8-pr-cvs1:/tmp/cvs-serv21155/distrib Modified Files: Makefile Log Message: Make the build a bit less verbose. Index: Makefile =================================================================== RCS file: /cvsroot/nice/Nice/distrib/Makefile,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Makefile 14 May 2003 14:43:39 -0000 1.6 --- Makefile 18 Jun 2003 22:52:47 -0000 1.7 *************** *** 34,38 **** find $(BUILDROOT).orig -name '.cvsignore' | xargs rm cp ../share/java/nice.jar $(BUILDROOT).orig/external/nice-bootstrap.jar ! tar zcvf $(BUILTSOURCEFILE) $(BUILDROOT).orig mv $(BUILDROOT).orig-debian $(BUILDROOT).orig/debian mv $(BUILDROOT).orig $(BUILDROOT) --- 34,38 ---- find $(BUILDROOT).orig -name '.cvsignore' | xargs rm cp ../share/java/nice.jar $(BUILDROOT).orig/external/nice-bootstrap.jar ! tar zcf $(BUILTSOURCEFILE) $(BUILDROOT).orig mv $(BUILDROOT).orig-debian $(BUILDROOT).orig/debian mv $(BUILDROOT).orig $(BUILDROOT) *************** *** 53,57 **** mkdir -p tmp/BUILD cd ${RPMTMP}/usr && tar xzf ${CURDIR}/${TARFILE} ! cd tmp && tar zcvf ${CURDIR}/tmp/Nice-${VERSION}.tar.gz Nice-${VERSION} sed "s/VERSION/${VERSION}/" Nice.spec > tmp/Nice-${VERSION}.spec rpmbuild --target=noarch --buildroot=${CURDIR}/${RPMTMP} -bb tmp/Nice-${VERSION}.spec --- 53,57 ---- mkdir -p tmp/BUILD cd ${RPMTMP}/usr && tar xzf ${CURDIR}/${TARFILE} ! cd tmp && tar zcf ${CURDIR}/tmp/Nice-${VERSION}.tar.gz Nice-${VERSION} sed "s/VERSION/${VERSION}/" Nice.spec > tmp/Nice-${VERSION}.spec rpmbuild --target=noarch --buildroot=${CURDIR}/${RPMTMP} -bb tmp/Nice-${VERSION}.spec |
From: <bo...@us...> - 2003-06-18 22:45:11
|
Update of /cvsroot/nice/Nice/distrib In directory sc8-pr-cvs1:/tmp/cvs-serv20043/distrib Modified Files: Nice.spec Log Message: Make the files in the RPM be owned by root, not by the building user. Index: Nice.spec =================================================================== RCS file: /cvsroot/nice/Nice/distrib/Nice.spec,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Nice.spec 16 Jul 2002 16:09:49 -0000 1.1 --- Nice.spec 18 Jun 2003 22:45:08 -0000 1.2 *************** *** 49,52 **** %files ! /usr --- 49,52 ---- %files ! %attr(-, root, root) /usr |
From: <bo...@us...> - 2003-06-18 21:30:33
|
Update of /cvsroot/nice/Nice/stdlib/nice/getopt In directory sc8-pr-cvs1:/tmp/cvs-serv4310/stdlib/nice/getopt Modified Files: gnugetopt.nice Added Files: tests.nice Log Message: Correctly handle the case where no short option is provided. --- NEW FILE: tests.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2003 */ /* */ /* 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.getopt; /** Unit tests. @author Daniel Bonniot (bo...@us...) */ void test() { var nick = ""; let Option[] options = [ option("nick", "foo", "name", String value => nick = value) ]; parse("", ["--nick", "bar"], options); assert nick.equals("bar"); } Index: gnugetopt.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/getopt/gnugetopt.nice,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** gnugetopt.nice 15 Jun 2003 13:15:27 -0000 1.7 --- gnugetopt.nice 18 Jun 2003 21:30:30 -0000 1.8 *************** *** 57,60 **** --- 57,62 ---- public void initGetopt() { + if (optstring.length() == 0) + optstring = " "; // Determine how to handle the ordering of options and non-options |
From: <bo...@us...> - 2003-06-18 18:12:49
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv4414/src/bossa/syntax Modified Files: Pattern.java MethodBodyDefinition.java Log Message: Take class constraints into account when looking for the declaration corresponding to a method implementation. Index: Pattern.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Pattern.java,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** Pattern.java 15 Jun 2003 13:05:45 -0000 1.56 --- Pattern.java 18 Jun 2003 18:12:46 -0000 1.57 *************** *** 246,249 **** --- 246,273 ---- } + static void inDomain(Pattern[] patterns, Monotype[] types) throws TypingEx + { + for (int i = 0; i < patterns.length; i++) + Types.setMarkedKind(types[i]); + + for (int i = 0; i < patterns.length; i++) + patterns[i].inDomain(Types.rawType(types[i])); + } + + private void inDomain(Monotype type) throws TypingEx + { + if (constraint != null) + { + constraint.enter(); + Typing.leq(patternType, type); + } + else + { + Typing.leq(tc, type); + } + + if (tc2 != null) + Typing.leq(tc2, type); + } /** Index: MethodBodyDefinition.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MethodBodyDefinition.java,v retrieving revision 1.129 retrieving revision 1.130 diff -C2 -d -r1.129 -r1.130 *** MethodBodyDefinition.java 15 Jun 2003 11:11:56 -0000 1.129 --- MethodBodyDefinition.java 18 Jun 2003 18:12:46 -0000 1.130 *************** *** 203,209 **** mlsub.typing.Polytype t = m.getType(); Constraint.enter(t.getConstraint()); ! tagLeq(tags, t.domain()); ! if (hasAdditionalTags) //optimization ! tagLeq(additionalTags, t.domain()); } finally{ --- 203,207 ---- mlsub.typing.Polytype t = m.getType(); Constraint.enter(t.getConstraint()); ! Pattern.inDomain(formals, t.domain()); } finally{ *************** *** 296,310 **** "Possible methods:\n" + methods); - } - - private void tagLeq(TypeConstructor[] tags, Monotype[] types) - throws TypingEx - { - for (int i = 0; i<tags.length; i++) - { - Types.setMarkedKind(types[i]); - Monotype type = types[i].equivalent(); - Typing.leq(tags[i], ((MonotypeConstructor) type).getTP()[0]); - } } --- 294,297 ---- |
From: <bo...@us...> - 2003-06-18 18:12:49
|
Update of /cvsroot/nice/Nice/testsuite/compiler/methods In directory sc8-pr-cvs1:/tmp/cvs-serv4414/testsuite/compiler/methods Modified Files: constrained.testsuite Log Message: Take class constraints into account when looking for the declaration corresponding to a method implementation. Index: constrained.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/methods/constrained.testsuite,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** constrained.testsuite 3 Jun 2003 13:24:04 -0000 1.3 --- constrained.testsuite 18 Jun 2003 18:12:46 -0000 1.4 *************** *** 64,68 **** foo(@X,@Y) {} ! /// FAIL bug ///Toplevel class A{} --- 64,68 ---- foo(@X,@Y) {} ! /// FAIL ///Toplevel class A{} *************** *** 72,75 **** void foo(I<B>); ! foo(@X){} //@X is not in the domain of foo --- 72,75 ---- void foo(I<B>); ! /*/// FAIL HERE */ foo(@X){} //@X is not in the domain of foo |
From: <bo...@us...> - 2003-06-17 13:00:33
|
Update of /cvsroot/nice/Nice/web In directory sc8-pr-cvs1:/tmp/cvs-serv30803/web Modified Files: manual.xml Log Message: Typo. Index: manual.xml =================================================================== RCS file: /cvsroot/nice/Nice/web/manual.xml,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** manual.xml 14 Jun 2003 10:43:34 -0000 1.23 --- manual.xml 17 Jun 2003 13:00:30 -0000 1.24 *************** *** 706,710 **** Contrarily to Java, Nice produces programs with assertions that can be run on earlier JDKs. Therefore there is no problem to distribute ! Nice programs using assertions anc contracts. Since java will not know the <literal>-ea</literal> command line option, they are disabled by default. You can enable them with --- 706,710 ---- Contrarily to Java, Nice produces programs with assertions that can be run on earlier JDKs. Therefore there is no problem to distribute ! Nice programs using assertions and contracts. Since java will not know the <literal>-ea</literal> command line option, they are disabled by default. You can enable them with |
From: <bo...@us...> - 2003-06-17 12:16:19
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang In directory sc8-pr-cvs1:/tmp/cvs-serv24743/stdlib/nice/lang Modified Files: numeric.nice Log Message: Separated unary and binary numeric operators. Index: numeric.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/numeric.nice,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** numeric.nice 17 Jun 2003 04:30:46 -0000 1.29 --- numeric.nice 17 Jun 2003 12:16:17 -0000 1.30 *************** *** 81,88 **** // unary negation ! double `-`(double) = inline nice.lang.inline.NumOp("dNeg"); ! float `-`(float) = inline nice.lang.inline.NumOp("fNeg"); ! long `-`(long) = inline nice.lang.inline.NumOp("lNeg"); ! int `-`(int) = inline nice.lang.inline.NumOp("iNeg"); // multiplication --- 81,88 ---- // unary negation ! double `-`(double) = inline nice.lang.inline.UnaryNumOp("dNeg"); ! float `-`(float) = inline nice.lang.inline.UnaryNumOp("fNeg"); ! long `-`(long) = inline nice.lang.inline.UnaryNumOp("lNeg"); ! int `-`(int) = inline nice.lang.inline.UnaryNumOp("iNeg"); // multiplication *************** *** 127,132 **** // bitwise operators ! int `~`(int x) = inline nice.lang.inline.NumOp("iComp"); ! long `~`(long x) = inline nice.lang.inline.NumOp("lComp"); int `&`(int, int) = inline nice.lang.inline.NumOp("iAnd"); --- 127,132 ---- // bitwise operators ! int `~`(int x) = inline nice.lang.inline.UnaryNumOp("iComp"); ! long `~`(long x) = inline nice.lang.inline.UnaryNumOp("lComp"); int `&`(int, int) = inline nice.lang.inline.NumOp("iAnd"); |
From: <bo...@us...> - 2003-06-17 12:16:19
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang/inline In directory sc8-pr-cvs1:/tmp/cvs-serv24743/stdlib/nice/lang/inline Modified Files: NumOp.java Added Files: UnaryNumOp.java Log Message: Separated unary and binary numeric operators. --- NEW FILE: UnaryNumOp.java --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2003 */ /* */ /* 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.lang.inline; /** Inlining of native unary numeric operators. @author Daniel Bonniot (bo...@us...) */ import gnu.mapping.Procedure1; import gnu.expr.*; import gnu.bytecode.*; public class UnaryNumOp extends Procedure1 implements Inlineable { private final static int error = 0, Neg = 1, // negation (unary -) Comp = 2; // bitwise complement (~) public static Procedure1 create(String param) { PrimType type = Tools.numericType(param.charAt(0)); if (type == null) bossa.util.User.error("Unknown type in inlined numeric operator: " + param); param = param.substring(1); int kind = error; if ("Neg".equals(param)) kind = Neg; else if ("Comp".equals(param))kind = Comp; else bossa.util.User.error("Unknown inlined unary numeric operator " + param); return new UnaryNumOp (kind, type); } private UnaryNumOp (int kind, PrimType type) { this.kind = kind; this.type = type; } private final PrimType type; private final int kind; public void compile (ApplyExp exp, Compilation comp, Target target) { Expression[] args = exp.getArgs(); CodeAttr code = comp.getCode(); Target stack = new StackTarget(type); args[0].compile(comp, stack); if (kind == Neg) { code.emitNeg(); } else if (kind == Comp) // Bitwise complement { // ~x == (x xor -1) if (type == Type.long_type) code.emitPushLong(-1); else code.emitPushInt(-1); code.emitXOr(); } else throw new Error(); target.compileFromStack(comp, type); } public Type getReturnType (Expression[] args) { return type; } // Interpretation public Object apply1 (Object arg) { throw new Error("Not implemented"); } } Index: NumOp.java =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/inline/NumOp.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** NumOp.java 21 Aug 2002 17:16:34 -0000 1.5 --- NumOp.java 17 Jun 2003 12:16:16 -0000 1.6 *************** *** 13,17 **** package nice.lang.inline; ! import gnu.mapping.ProcedureN; import gnu.expr.*; import gnu.bytecode.*; --- 13,17 ---- package nice.lang.inline; ! import gnu.mapping.Procedure2; import gnu.expr.*; import gnu.bytecode.*; *************** *** 23,28 **** @author Daniel Bonniot */ ! public class NumOp ! extends ProcedureN implements Inlineable { private final static int --- 23,27 ---- @author Daniel Bonniot */ ! public class NumOp extends Procedure2 implements Inlineable { private final static int *************** *** 33,37 **** Div = 4, Rem = 5, // remainder (modulus) - Neg = 6, // negation (unary -) And = 7, IOr = 8, --- 32,35 ---- *************** *** 39,44 **** Shl = 10, // left shift (<<) Shr = 11, // right shift (>>) ! uShr = 12, // unsigned right shift (>>>) ! Comp = 13; // bitwise complement (~) --- 37,41 ---- Shl = 10, // left shift (<<) Shr = 11, // right shift (>>) ! uShr = 12; // unsigned right shift (>>>) *************** *** 58,62 **** else if ("Div".equals(param)) kind = Div; else if ("Rem".equals(param)) kind = Rem; - else if ("Neg".equals(param)) kind = Neg; else if ("And".equals(param)) kind = And; else if ("IOr".equals(param)) kind = IOr; --- 55,58 ---- *************** *** 65,69 **** else if ("Shr".equals(param)) kind = Shr; else if ("uShr".equals(param))kind = uShr; - else if ("Comp".equals(param))kind = Comp; else bossa.util.User.error("Unknown inlined numeric operator " + param); --- 61,64 ---- *************** *** 87,104 **** args[0].compile(comp, stack); ! if (kind == Neg) ! { ! code.emitNeg(); ! } ! else if (kind == Comp) // Bitwise complement ! { ! // ~x == (x xor -1) ! if (type == Type.long_type) ! code.emitPushLong(-1); ! else ! code.emitPushInt(-1); ! code.emitXOr(); ! } ! else if (kind >= Shl && kind <= uShr) { args[1].compile(comp, Tools.intTarget); --- 82,86 ---- args[0].compile(comp, stack); ! if (kind >= Shl && kind <= uShr) { args[1].compile(comp, Tools.intTarget); *************** *** 136,140 **** // Interpretation ! public Object applyN (Object[] args) { throw new Error("Not implemented"); --- 118,122 ---- // Interpretation ! public Object apply2 (Object arg1, Object arg2) { throw new Error("Not implemented"); |
From: <bo...@us...> - 2003-06-17 12:06:05
|
Update of /cvsroot/nice/Nice/src/gnu/expr In directory sc8-pr-cvs1:/tmp/cvs-serv23400/src/gnu/expr Modified Files: PrimProcedure.java Log Message: Moved to nice.tools.code.Gen Index: PrimProcedure.java =================================================================== RCS file: /cvsroot/nice/Nice/src/gnu/expr/PrimProcedure.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PrimProcedure.java 27 Nov 2002 17:56:08 -0000 1.6 --- PrimProcedure.java 17 Jun 2003 12:06:02 -0000 1.7 *************** *** 412,440 **** } - /** Creates a LambdaExp that applies this PrimProcedure - * to the appropriate number and type of arguments. - * - * This is usefull to generate an Expression from a given PrimProcedure. - */ - public LambdaExp wrapInLambda() - { - int numArgs = minArgs(); - - LambdaExp lambda = new LambdaExp(); - lambda.min_args = lambda.max_args = numArgs; - - Expression[] args = new Expression[numArgs]; - for (int i = 0; i<numArgs; i++) - { - Declaration decl = lambda.addDeclaration("param__"+i, - getParameterType(i)); - - args[i] = new ReferenceExp(decl); - } - - lambda.body = new ApplyExp(this, args); - return lambda; - } - public Type getParameterType(int index) { --- 412,415 ---- |
From: <bo...@us...> - 2003-06-17 12:03:10
|
Update of /cvsroot/nice/Nice/src/nice/tools/code In directory sc8-pr-cvs1:/tmp/cvs-serv22990/src/nice/tools/code Modified Files: Gen.java Log Message: Inlined and native methods are now wrapped into lambda expressions as needed in all cases. Index: Gen.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/code/Gen.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Gen.java 12 Jun 2003 21:04:41 -0000 1.15 --- Gen.java 17 Jun 2003 12:03:05 -0000 1.16 *************** *** 304,306 **** --- 304,335 ---- code.emitPutField(field); } + + /** Creates a LambdaExp that applies a Procedure + * to the appropriate number of arguments. + * + * This is usefull to generate an Expression from a given Procedure. + */ + public static LambdaExp wrapInLambda(gnu.mapping.Procedure proc) + { + int numArgs = proc.minArgs(); + + LambdaExp lambda = new LambdaExp(); + lambda.min_args = lambda.max_args = numArgs; + + Expression[] args = new Expression[numArgs]; + for (int i = 0; i < numArgs; i++) + { + // The parameters have type Object, since calls to anonymous functions + // have never precise types. + // Besides, work would be needed to know the types in the case + // of inlined methods (macros). + Declaration decl = lambda.addDeclaration("param__" + i, + Type.pointer_type); + + args[i] = new ReferenceExp(decl); + } + + lambda.body = new ApplyExp(proc, args); + return lambda; + } } |
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv22990/src/bossa/syntax Modified Files: VarSymbol.java SymbolExp.java MethodDeclaration.java JavaMethod.java InlinedMethod.java Expression.java CallExp.java Log Message: Inlined and native methods are now wrapped into lambda expressions as needed in all cases. Index: VarSymbol.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/VarSymbol.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** VarSymbol.java 30 Apr 2003 18:55:29 -0000 1.28 --- VarSymbol.java 17 Jun 2003 12:03:05 -0000 1.29 *************** *** 145,148 **** --- 145,156 ---- } + /** @return code that accesses this variable, when it is used + as the function of a call. */ + gnu.expr.Expression compileInCallPosition() + { + // Default implementation. + return compile(); + } + static gnu.expr.Expression[] compile(VarSymbol[] syms) { Index: SymbolExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/SymbolExp.java,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** SymbolExp.java 30 Apr 2003 18:55:30 -0000 1.32 --- SymbolExp.java 17 Jun 2003 12:03:05 -0000 1.33 *************** *** 78,81 **** --- 78,94 ---- } + gnu.expr.Expression generateCodeInCallPosition() + { + try { + gnu.expr.Expression res = symbol.compileInCallPosition(); + location().write(res); + return res; + } + catch(FieldAccess.UsingAsValue e) { + throw User.error(this, + "You must supply the object that contains this field"); + } + } + /** @return the declaration of the variable denoted by this expression, or <code>null</code> if this expression is not a variable. Index: MethodDeclaration.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MethodDeclaration.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** MethodDeclaration.java 28 May 2003 12:57:26 -0000 1.42 --- MethodDeclaration.java 17 Jun 2003 12:03:05 -0000 1.43 *************** *** 334,337 **** --- 334,342 ---- } + gnu.expr.Expression compileInCallPosition() + { + return getDefinition().getCodeInCallPosition(); + } + String explainWhyMatchFails(Arguments arguments) { *************** *** 372,376 **** } ! final gnu.expr.Expression getCode() { if (code == null) --- 377,387 ---- } ! gnu.expr.Expression getCode() ! { ! // Default implementation. ! return getCodeInCallPosition(); ! } ! ! final gnu.expr.Expression getCodeInCallPosition() { if (code == null) Index: JavaMethod.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/JavaMethod.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** JavaMethod.java 18 Apr 2003 14:50:24 -0000 1.25 --- JavaMethod.java 17 Jun 2003 12:03:05 -0000 1.26 *************** *** 25,30 **** A Native Java Method. ! @version $Date$ ! @author Daniel Bonniot (d.b...@ma...) */ public class JavaMethod extends MethodDeclaration --- 25,29 ---- A Native Java Method. ! @author Daniel Bonniot (bo...@us...) */ public class JavaMethod extends MethodDeclaration *************** *** 96,99 **** --- 95,103 ---- { return new QuoteExp(new PrimProcedure(reflectMethod)); + } + + gnu.expr.Expression getCode() + { + return nice.tools.code.Gen.wrapInLambda(new PrimProcedure(reflectMethod)); } Index: InlinedMethod.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/InlinedMethod.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** InlinedMethod.java 30 Apr 2003 18:55:31 -0000 1.11 --- InlinedMethod.java 17 Jun 2003 12:03:05 -0000 1.12 *************** *** 49,58 **** { super.typecheck(); ! // forces the reflection search ! getCode(); } ! protected gnu.expr.Expression computeCode() { Class refClass = null; try{ --- 49,61 ---- { super.typecheck(); ! findProcedure(); } ! private void findProcedure() { + if (this.procedure != null) + // Already done. + return; + Class refClass = null; try{ *************** *** 84,88 **** User.error(inlineProcedure, "Inlined method " + inlineProcedure + ! ": " + e.getLocalizedMessage()); } catch(IllegalAccessException e){ --- 87,91 ---- User.error(inlineProcedure, "Inlined method " + inlineProcedure + ! ": " + e.getMessage()); } catch(IllegalAccessException e){ *************** *** 104,108 **** --- 107,122 ---- this.procedure = (gnu.mapping.Procedure) o; + } + + protected gnu.expr.Expression computeCode() + { + findProcedure(); return new gnu.expr.QuoteExp(procedure); + } + + gnu.expr.Expression getCode() + { + findProcedure(); + return nice.tools.code.Gen.wrapInLambda(procedure); } Index: Expression.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Expression.java,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** Expression.java 29 May 2003 14:17:17 -0000 1.50 --- Expression.java 17 Jun 2003 12:03:05 -0000 1.51 *************** *** 227,230 **** --- 227,240 ---- /** + Creates the bytecode expression to evaluate this Expression, + when it is used as a function that is immediately called. + */ + gnu.expr.Expression generateCodeInCallPosition() + { + // Default implementation. + return generateCode(); + } + + /** * Maps {@link #generateCode()} over a list of expressions. */ Index: CallExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/CallExp.java,v retrieving revision 1.79 retrieving revision 1.80 diff -C2 -d -r1.79 -r1.80 *** CallExp.java 29 May 2003 14:17:16 -0000 1.79 --- CallExp.java 17 Jun 2003 12:03:05 -0000 1.80 *************** *** 313,317 **** res = function.getFieldAccessMethod().compileAccess(compileParams()); else ! res = new gnu.expr.ApplyExp(function.generateCode(), compileParams()); return EnsureTypeProc.ensure(res, Types.javaType(type)); --- 313,318 ---- res = function.getFieldAccessMethod().compileAccess(compileParams()); else ! res = new gnu.expr.ApplyExp(function.generateCodeInCallPosition(), ! compileParams()); return EnsureTypeProc.ensure(res, Types.javaType(type)); *************** *** 322,336 **** gnu.expr.Expression[] params = Expression.compile(arguments.computedExpressions); - - // wraps the arguments that reference methods into LambdaExps - for(int i=0; i<params.length; i++) - if(params[i] instanceof gnu.expr.QuoteExp) - { - gnu.expr.QuoteExp q = (gnu.expr.QuoteExp) params[i]; - if(q.getValue() instanceof gnu.expr.PrimProcedure) - { - params[i] = ((gnu.expr.PrimProcedure) q.getValue()).wrapInLambda(); - } - } // Make sure the arguments have the expected bytecode type, --- 323,326 ---- |
From: <bo...@us...> - 2003-06-17 12:03:10
|
Update of /cvsroot/nice/Nice/testsuite/compiler/macros In directory sc8-pr-cvs1:/tmp/cvs-serv22990/testsuite/compiler/macros Added Files: compilation.testsuite Log Message: Inlined and native methods are now wrapped into lambda expressions as needed in all cases. --- NEW FILE: compilation.testsuite --- /// PASS (int,int)->int typeCheckerHelper = `+`; int i = typeCheckerHelper(1,2); assert i == 3; /// PASS assert id(`&&`)(true, true); /// Toplevel <T> T id(T x) = x; |