nice-commit Mailing List for The Nice Programming Language (Page 103)
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-11 22:26:59
|
Update of /cvsroot/nice/Nice/src/nice/tools/compiler/console In directory sc8-pr-cvs1:/tmp/cvs-serv22581/src/nice/tools/compiler/console Added Files: main.nice listener.nice Log Message: Added the compilation listener interface. Console output is factored out in package nice.tools.compiler.console --- NEW FILE: main.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.tools.compiler.console; /** Nice compiler main program. Exit code table: 0 : Normal exit (compilation sucessful, version message) 1 : Abnormal termination (bug in the compiler) 2 : Error reported (file missing, type error, ...) 3 : Warning reported Changes to this table should be reflected in function <code>nice-compilation-exit</code> in emacs mode file <tt>nice-mode.el</tt>. @author Daniel Bonniot (bo...@us...) */ import nice.tools.compiler; import bossa.modules; import nice.getopt; import nice.doc; /** @return a status code describing if the compilation was successful. The codes are found in OutputMessages (OK, WARNING, ERROR, BUG). */ int compile(String[] args) { nice.tools.util.Chronometer chrono = notNull(nice.tools.util.Chronometer.make("Total")); chrono.start(); boolean memInfo = false, timeInfo = false; String mainPackage; ?String nativeProgram = null; ?String nativeCompiler = null; ?String classpath = null; boolean editorMode = false; ConsoleOutput output = new ConsoleOutput(); Compilation compilation = new Compilation(listener: output); Program prg = new Program (name: "nicec", longName: "The Nice Compiler", shortDescription: "compiler for the Nice programming language", author: "Daniel Bonniot <bo...@us...>, <Dan...@in...>", seeAlso: "http://nice.sourceforge.net the Nice Home Page\n", manualSection: "1", arguments: "package", options: cast(null)); prg.options = [ option("sourcepath", "Search path for source packages\nPATH is a list of directories and .jar archives", "path", String path => { compilation.sourcePath = path; }), option(letter: 'd', "destination", "Destination directory for compiled packages", "dir", String dir => { compilation.destinationDir = dir; }), option("classpath", "Search path for compiled packages and libraries\nPATH is a list of directories and .jar archives", "path", String path => { compilation.packagePath = path; }), option(letter: 'a', "jar", "Compile to archive\nYou can then run the program with 'java -jar FILE'", "file", String output => { compilation.output = output; }), option(letter: 'o', "output", "Generate native executable", "file", String output => { compilation.output = output + ".jar"; nativeProgram = output; }), option(letter: 'r', "recompile", "Force recompilation of package", () => { compilation.recompileCommandLine = true; }), option(letter: 'R', "recompile-all", "Force recompilation of all dependant packages", () => { compilation.recompileAll = true; }), option(letter: 'c', "compile", "Compile packages but do not link them", () => { compilation.skipLink = true; }), option("strict", "Type-check uses of java classes more stricly", () => { compilation.strictJavaTypes = true; }), // PRIVATE OPTIONS // This options are only usefull for compiling the compiler itself, // so they should not be advertised. option("exclude-runtime", visible: false, "Avoid inclusion of the runtime in the archive", () => { compilation.excludeRuntime = true; }), option("runtime", visible: false, "Location of nice.jar", "file", String file => { compilation.runtimeFile = file; }), option("native-compiler", visible: false, "Location of the native compiler binary (gcj)", "file", String file => { nativeCompiler = file; }), option(letter: 'h', "help", "Print help message and exit", () => help(prg)), option("editor", "Tell nicec that it is called by an editor.", () => { editorMode = true; }), option("man", "Print man page to stdout", () => man(prg)), option("version", "Print version info and exit", () => version()), option("usage", "Print usage information and exit", () => usage(prg)), option("memory", "Print memory usage information after compilation", () => { memInfo = true; }), option("benchmark", "Print time usage information after compilation", () => { timeInfo = true; }) ]; List<String> rest = parse(prg, args); if (rest.size() != 1 || rest[0].length() == 0) { if (rest.size() > 1) println("Supply only one package on the command line.\n" + "nicec will automatically find dependancies."); usage(prg, ERROR); } mainPackage = rest[0]; /* For convenience of command-line tools (shells) with completions, we treat a directory name as the corresponding package name. That is, we replace '/' (which is illegal in package names) by '.'. */ mainPackage = mainPackage.deleteAtEnd("/").replace('/', "."); compile(compilation, mainPackage, nativeProgram, nativeCompiler, editorMode); int res = output.statusCode; if (memInfo) printMemoryUsage(); if (timeInfo) { chrono.stop(); println("Time mesurements:"); nice.tools.util.Chronometer.printAll(); } return res; } void main(String[] args) { int status = compile(args); // A non-zero code is interpreted as error, e.g. by make. // We do not want that if there are just warnings. // When called from an editor it does not matter, as it should be able to interpret warnings. if (! bossa.util.Location.editorMode && status == WARNING) status = OK; System.exit(status); } void version() { println("Nice compiler version " + versionNumber + " (build " + buildDate + ")"); println("Copyright (C) 2003 Daniel Bonniot"); println("Visit the Nice homepage: http://nice.sourceforge.net"); System.exit(0); } String prettyBytes(long bytes) { long K = 1024; if (bytes < 10 * K) return ""+bytes+" B"; else if (bytes < 100 * K) return ""+(bytes/K) + "." + ((bytes % K)/100) + " KB"; else if (bytes < 10*K*K) return ""+(bytes/K) + " KB"; else if (bytes < 100*K*K) return ""+(bytes/(K*K)) + "." + ((bytes % (K*K))/(100*K)) + " MB"; else if (bytes < 10*K*K*K) return ""+(bytes/(K*K)) + " MB"; else return ""+(bytes/(K*K*K)) + " GB"; } void printMemoryUsage() { Runtime r = Runtime.getRuntime(); r.gc(); long total = r.totalMemory(); long free = r.freeMemory(); println("Memory allocated: " + prettyBytes(total) + ", used: " + prettyBytes(total - free)); } // Local Variables: // nice-xprogram: "nicec -d \"$HOME/Nice/classes\" --sourcepath=\"$HOME/Nice/src\" --classpath=\"$HOME/Nice/classes\"" // End: --- NEW FILE: listener.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.tools.compiler.console; /** Keep track of messages reported to the user. @author Daniel Bonniot (bo...@us...) */ public ConsoleOutput consoleOutput() = new ConsoleOutput(); let int OK = 0; // Normal exit (compilation sucessful, version message) let int BUG = 1; // Abnormal termination (bug in the compiler) let int ERROR = 2; // Error reported (file missing, type error, ...) let int WARNING = 3; // Warning reported public final class ConsoleOutput implements CompilationListener { public int statusCode = OK; private void setStatusCode(int status) { if (worse(status, statusCode)) statusCode = status; } progress(packageName, phase) { if (packageName != null) println(packageName + ": " + phase); else println(phase); } warning(location, message) { this.setStatusCode(WARNING); if (location != null) System.out.println("\n" + location + ":\n" + message); else System.out.println("\n" + message); } error(location, message) { this.setStatusCode(ERROR); if (location != null) System.err.println("\n" + location + ":\n" + message); else System.err.println("\n" + message); } /** A bug has occured inside the compiler. */ bug(stackTrace, url) { this.setStatusCode(BUG); System.err.println ("\nAn exception has occured in the compiler\n" + "Please fill-in a bug report at the following webpage:\n" + url + // "\n\nException: " + exn.toString() + "\n\nStack trace:\n" + stackTrace); } } boolean worse(int status, int than) { if (than == OK) return true; if (than == BUG) return false; if (than == ERROR) return false; if (than == WARNING) return status == BUG || status == ERROR; return false; } |
From: <bo...@us...> - 2003-06-11 22:24:40
|
Update of /cvsroot/nice/Nice/src/nice/tools/ant In directory sc8-pr-cvs1:/tmp/cvs-serv21115/src/nice/tools/ant Modified Files: Nicec.java Log Message: Added the compilation listener interface. Console output is factored out in package nice.tools.compiler.console Index: Nicec.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/ant/Nicec.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Nicec.java 14 Mar 2003 12:37:42 -0000 1.17 --- Nicec.java 11 Jun 2003 22:24:06 -0000 1.18 *************** *** 5,9 **** import java.io.File; import java.util.Vector; - import nice.tools.compiler.OutputMessages; import bossa.modules.Compilation; --- 5,8 ---- *************** *** 284,288 **** log("runtime: " + runtime, Project.MSG_VERBOSE); ! Compilation compilation = bossa.modules.fun.createCompilation(); if (sourcepath != null) compilation.sourcePath = sourcepath; --- 283,289 ---- log("runtime: " + runtime, Project.MSG_VERBOSE); ! nice.tools.compiler.console.ConsoleOutput console = ! nice.tools.compiler.console.fun.consoleOutput(); ! Compilation compilation = bossa.modules.fun.createCompilation(console); if (sourcepath != null) compilation.sourcePath = sourcepath; *************** *** 296,311 **** compilation.excludeRuntime = exclude_runtime; compilation.runtimeFile = runtime; ! int retval = nice.tools.compiler.fun.compile (compilation, pack, output, native_compiler, editor); switch (retval) { ! case OutputMessages.ERROR: throw new BuildException(ERROR_MSG, location); ! case OutputMessages.BUG: throw new BuildException(BUG_MSG, location); ! case OutputMessages.WARNING: log(WARNING_MSG, Project.MSG_WARN); break; ! case OutputMessages.OK: log(OK_MSG, Project.MSG_INFO); break; --- 297,313 ---- compilation.excludeRuntime = exclude_runtime; compilation.runtimeFile = runtime; ! nice.tools.compiler.fun.compile (compilation, pack, output, native_compiler, editor); + int retval = console.statusCode; switch (retval) { ! case nice.tools.compiler.console.fun.ERROR: throw new BuildException(ERROR_MSG, location); ! case nice.tools.compiler.console.fun.BUG: throw new BuildException(BUG_MSG, location); ! case nice.tools.compiler.console.fun.WARNING: log(WARNING_MSG, Project.MSG_WARN); break; ! case nice.tools.compiler.console.fun.OK: log(OK_MSG, Project.MSG_INFO); break; |
From: <bo...@us...> - 2003-06-11 22:24:40
|
Update of /cvsroot/nice/Nice/src/mlsub/compilation In directory sc8-pr-cvs1:/tmp/cvs-serv21115/src/mlsub/compilation Modified Files: make.nice Log Message: Added the compilation listener interface. Console output is factored out in package nice.tools.compiler.console Index: make.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/compilation/make.nice,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** make.nice 4 Mar 2003 16:50:17 -0000 1.20 --- make.nice 11 Jun 2003 22:24:07 -0000 1.21 *************** *** 60,71 **** stronglyConnectedComponents (notNull(compilation.root), Module m => m.getRequirements()); ! try{ ! sccs.foreach(List<Module> scc => ! { compileComponent(compilation, scc, ! !compilation.skipLink); }); ! } ! catch(bossa.util.UserError e){ ! nice.tools.compiler.OutputMessages.error(e.getMessage()); ! } } --- 60,66 ---- stronglyConnectedComponents (notNull(compilation.root), Module m => m.getRequirements()); ! ! sccs.foreach(List<Module> scc => ! compileComponent(compilation, scc, !compilation.skipLink)); } |
From: <bo...@us...> - 2003-06-11 22:24:39
|
Update of /cvsroot/nice/Nice/src/nice/tools/compiler In directory sc8-pr-cvs1:/tmp/cvs-serv21115/src/nice/tools/compiler Modified Files: interface.nice Log Message: Added the compilation listener interface. Console output is factored out in package nice.tools.compiler.console Index: interface.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/compiler/interface.nice,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** interface.nice 22 Jan 2003 17:16:47 -0000 1.4 --- interface.nice 11 Jun 2003 22:24:06 -0000 1.5 *************** *** 20,26 **** */ ! int compile(Compilation compilation, String mainPackage, ! ?String nativeProgram = null, ?String nativeCompiler = null, ! boolean editorMode = false) { ?Throwable uncaughtException = null; --- 20,28 ---- */ ! import bossa.modules; ! ! void compile(Compilation compilation, String mainPackage, ! ?String nativeProgram = null, ?String nativeCompiler = null, ! boolean editorMode = false) { ?Throwable uncaughtException = null; *************** *** 28,34 **** try { ! OutputMessages.start(); ! bossa.util.Location.editorMode = editorMode; if (compilation.runtimeFile == null) compilation.runtimeFile = getNiceRuntime(); --- 30,36 ---- try { ! bossa.modules.Package.currentCompilation = compilation; bossa.util.Location.editorMode = editorMode; + if (compilation.runtimeFile == null) compilation.runtimeFile = getNiceRuntime(); *************** *** 36,41 **** compilation.setMainPackage(mainPackage); - bossa.modules.Package.currentCompilation = compilation; - make(compilation); --- 38,41 ---- *************** *** 45,55 **** nativeProgram, jar); } ! catch(OutputMessages.Exit e) { ! // Compilation was interrupted. ! return e.statusCode; } catch(bossa.util.UserError e){ bossa.util.Internal.warning("user error only caught in main"); ! nice.tools.compiler.OutputMessages.error(e.getMessage()); } catch(ExceptionInInitializerError e){ --- 45,54 ---- nativeProgram, jar); } ! catch(bossa.modules.Exit e) { ! // The compilation was stopped because an error prevented going further. } catch(bossa.util.UserError e){ bossa.util.Internal.warning("user error only caught in main"); ! compilation.listener.error(e.location, notNull(e.message)); } catch(ExceptionInInitializerError e){ *************** *** 62,77 **** if (uncaughtException != null) { ! Throwable exn = uncaughtException; ! OutputMessages.bug ! ("\nAn exception has occured in the compiler\n" + ! "Please fill-in a bug report at the following webpage:\n" + ! "http://sourceforge.net/tracker/?func=add&group_id=12788&atid=112788" + ! "\n\nException: " + exn.toString() + ! "\n\nStack trace:\n"); ! exn.printStackTrace(); } - - return OutputMessages.getStatusCode(); } --- 61,73 ---- if (uncaughtException != null) { ! let stackTrace = new java.io.StringWriter(500); ! uncaughtException.printStackTrace(new java.io.PrintWriter(stackTrace)); ! compilation.listener.bug ! (stackTrace: stackTrace.toString(), ! url: ! "http://sourceforge.net/tracker/?func=add&group_id=12788&atid=112788" ! ); } } |
From: <bo...@us...> - 2003-06-11 22:24:39
|
Update of /cvsroot/nice/Nice/src/nice/tools/testsuite In directory sc8-pr-cvs1:/tmp/cvs-serv21115/src/nice/tools/testsuite Modified Files: TestCase.java Log Message: Added the compilation listener interface. Console output is factored out in package nice.tools.compiler.console Index: TestCase.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/testsuite/TestCase.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** TestCase.java 6 Jun 2003 15:18:17 -0000 1.24 --- TestCase.java 11 Jun 2003 22:24:05 -0000 1.25 *************** *** 18,22 **** import java.lang.reflect.*; - import nice.tools.compiler.OutputMessages; import bossa.modules.Compilation; --- 18,21 ---- *************** *** 296,306 **** int retval = compilePackage(packageName); switch (retval) { ! case OutputMessages.ERROR: showMessages = true; throw new TestSuiteException(ERROR_MSG); ! case OutputMessages.BUG: showMessages = true; throw new CompilerBugException(BUG_MSG); ! case OutputMessages.WARNING: showMessages = true; break; --- 295,305 ---- int retval = compilePackage(packageName); switch (retval) { ! case nice.tools.compiler.console.fun.ERROR: showMessages = true; throw new TestSuiteException(ERROR_MSG); ! case nice.tools.compiler.console.fun.BUG: showMessages = true; throw new CompilerBugException(BUG_MSG); ! case nice.tools.compiler.console.fun.WARNING: showMessages = true; break; *************** *** 326,336 **** */ private int compilePackage(String packageName) throws TestSuiteException { ! Compilation compilation = bossa.modules.fun.createCompilation(); String tempDir = TestNice.getTempFolder().getAbsolutePath(); compilation.sourcePath = tempDir; compilation.destinationDir = tempDir; compilation.runtimeFile = TestNice.getRuntime(); ! return nice.tools.compiler.fun.compile (compilation, packageName, null, null, false); } --- 325,338 ---- */ private int compilePackage(String packageName) throws TestSuiteException { ! nice.tools.compiler.console.ConsoleOutput output = ! nice.tools.compiler.console.fun.consoleOutput(); ! Compilation compilation = bossa.modules.fun.createCompilation(output); String tempDir = TestNice.getTempFolder().getAbsolutePath(); compilation.sourcePath = tempDir; compilation.destinationDir = tempDir; compilation.runtimeFile = TestNice.getRuntime(); ! nice.tools.compiler.fun.compile (compilation, packageName, null, null, false); + return output.statusCode; } |
Update of /cvsroot/nice/Nice/src/bossa/modules In directory sc8-pr-cvs1:/tmp/cvs-serv21115/src/bossa/modules Modified Files: Package.java Compilation.nice Compilation.java Added Files: CompilationListener.nice CompilationInterface.java Log Message: Added the compilation listener interface. Console output is factored out in package nice.tools.compiler.console --- NEW FILE: CompilationListener.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 bossa.modules; /** The listener interface for compilation events. @author (bo...@us...) */ import bossa.util.*; interface CompilationListener { void error (?Location location, String message); void warning(?Location location, String message); /** A bug occured in the compiler. @param url the adress where a bug report should be submitted. */ void bug(String stackTrace, String url); /** Reports the progress of compilation. phase can be: parsing, type-checking, generating code, ... the package can be null if the phase applies to the whole program (testing dispatch, creating the archive, compiling to native code, ...). */ void progress(String packageName, String phase); } --- NEW FILE: CompilationInterface.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.modules; /** An abstract parent for Compilation. Allows methods to be in the Java style. @author (bo...@us...) */ public abstract class CompilationInterface extends mlsub.compilation.Compilation { public abstract void error(bossa.util.UserError ex); public abstract void warning(bossa.util.Location loc, String message); public abstract void exitIfErrors(); } Index: Package.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/Package.java,v retrieving revision 1.88 retrieving revision 1.89 diff -C2 -d -r1.88 -r1.89 *** Package.java 31 May 2003 17:30:39 -0000 1.88 --- Package.java 11 Jun 2003 22:24:08 -0000 1.89 *************** *** 234,238 **** { typecheck(); ! nice.tools.compiler.OutputMessages.exitIfErrors(); generateCode(); saveInterface(); --- 234,238 ---- { typecheck(); ! compilation.exitIfErrors(); generateCode(); saveInterface(); *************** *** 301,305 **** finishCompilation(); ! nice.tools.compiler.OutputMessages.exitIfErrors(); } --- 301,305 ---- finishCompilation(); ! compilation.exitIfErrors(); } Index: Compilation.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/Compilation.nice,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Compilation.nice 22 Jan 2003 17:17:15 -0000 1.20 --- Compilation.nice 11 Jun 2003 22:24:08 -0000 1.21 *************** *** 22,26 **** **/ ! class Compilation extends mlsub.compilation.Compilation { boolean recompileAll = false; --- 22,26 ---- **/ ! class Compilation extends CompilationInterface { boolean recompileAll = false; *************** *** 51,54 **** --- 51,56 ---- ?Locator locator = null; + CompilationListener listener; + Map<String,Package> packages = new HashMap(); Map<String,mlsub.typing.TypeConstructor> javaTypeConstructors = new HashMap(); *************** *** 83,87 **** this.root = Package.make(new bossa.syntax.LocatedString(packageName, new bossa.util.Location("Command line")), this, true); } } ! Compilation createCompilation() = new Compilation(); --- 85,115 ---- this.root = Package.make(new bossa.syntax.LocatedString(packageName, new bossa.util.Location("Command line")), this, true); } + + /**************************************************************** + * Error handling + ****************************************************************/ + + private boolean wasError = false; + + error(ex) + { + wasError = true; + listener.error(notNull(ex).location, notNull(notNull(ex).message)); + } + + exitIfErrors() + { + if (wasError) + throw new Exit(); + } + + warning(location, message) + { + listener.warning(location, notNull(message)); + } } ! Compilation createCompilation(CompilationListener listener) = ! new Compilation(listener: listener); ! ! class Exit extends RuntimeException {} Index: Compilation.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/Compilation.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Compilation.java 22 Jan 2003 17:17:15 -0000 1.6 --- Compilation.java 11 Jun 2003 22:24:08 -0000 1.7 *************** *** 5,12 **** * Stores information about a bossa compilation. * * @author Daniel Bonniot */ ! public class Compilation extends mlsub.compilation.Compilation { public boolean recompileAll; --- 5,17 ---- * Stores information about a bossa compilation. * + * This java source is only used to break a dependency cycle when + * bootstrapping. The master source is in Nice files. + * * @author Daniel Bonniot */ ! import bossa.util.Location; ! ! public abstract class Compilation extends CompilationInterface { public boolean recompileAll; |
From: <bo...@us...> - 2003-06-11 22:24:13
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv21115/src/bossa/syntax Modified Files: analyse.nice MethodBodyDefinition.java AST.java Log Message: Added the compilation listener interface. Console output is factored out in package nice.tools.compiler.console Index: analyse.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/analyse.nice,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** analyse.nice 10 Jun 2003 19:33:00 -0000 1.71 --- analyse.nice 11 Jun 2003 22:24:07 -0000 1.72 *************** *** 43,55 **** Info info = buildInfo(varScope, typeScope); ! try{ ! analyse(s, info); ! if (mustReturnAValue && !info.getUnreachable()) ! throw error(s, "Missing return statement"); ! } ! catch(bossa.util.UserError e){ ! nice.tools.compiler.OutputMessages.error(e.getMessage()); ! } return s; } --- 43,51 ---- Info info = buildInfo(varScope, typeScope); ! analyse(s, info); ! if (mustReturnAValue && !info.getUnreachable()) ! throw error(s, "Missing return statement"); ! return s; } Index: MethodBodyDefinition.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MethodBodyDefinition.java,v retrieving revision 1.124 retrieving revision 1.125 diff -C2 -d -r1.124 -r1.125 *** MethodBodyDefinition.java 2 Jun 2003 18:07:31 -0000 1.124 --- MethodBodyDefinition.java 11 Jun 2003 22:24:07 -0000 1.125 *************** *** 408,412 **** bossa.syntax.dispatch.typecheck(body); } catch(UserError ex){ ! nice.tools.compiler.OutputMessages.error(ex.getMessage()); errorFound = true; } --- 408,412 ---- bossa.syntax.dispatch.typecheck(body); } catch(UserError ex){ ! module.compilation().error(ex); errorFound = true; } Index: AST.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/AST.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** AST.java 12 May 2003 11:11:44 -0000 1.42 --- AST.java 11 Jun 2003 22:24:07 -0000 1.43 *************** *** 70,74 **** } catch(UserError ex){ ! nice.tools.compiler.OutputMessages.error(ex.getMessage()); } } --- 70,74 ---- } catch(UserError ex){ ! module.compilation().error(ex); } } *************** *** 91,95 **** } ! nice.tools.compiler.OutputMessages.exitIfErrors(); } --- 91,95 ---- } ! module.compilation().exitIfErrors(); } *************** *** 106,110 **** } catch(UserError ex){ ! nice.tools.compiler.OutputMessages.error(ex.getMessage()); } } --- 106,110 ---- } catch(UserError ex){ ! module.compilation().error(ex); } } *************** *** 115,122 **** } catch(UserError ex){ ! nice.tools.compiler.OutputMessages.error(ex.getMessage()); } ! nice.tools.compiler.OutputMessages.exitIfErrors(); } --- 115,122 ---- } catch(UserError ex){ ! module.compilation().error(ex); } ! module.compilation().exitIfErrors(); } *************** *** 132,140 **** } catch(UserError ex){ ! nice.tools.compiler.OutputMessages.error(ex.getMessage()); } } ! nice.tools.compiler.OutputMessages.exitIfErrors(); for (int i = 0; i < classes.length; i++) --- 132,140 ---- } catch(UserError ex){ ! module.compilation().error(ex); } } ! module.compilation().exitIfErrors(); for (int i = 0; i < classes.length; i++) |
From: <bo...@us...> - 2003-06-11 22:24:13
|
Update of /cvsroot/nice/Nice/bin In directory sc8-pr-cvs1:/tmp/cvs-serv21115/bin Modified Files: nicec.bootstrap nicec Log Message: Added the compilation listener interface. Console output is factored out in package nice.tools.compiler.console Index: nicec.bootstrap =================================================================== RCS file: /cvsroot/nice/Nice/bin/nicec.bootstrap,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** nicec.bootstrap 19 Apr 2003 13:44:45 -0000 1.1 --- nicec.bootstrap 11 Jun 2003 22:24:08 -0000 1.2 *************** *** 8,14 **** export NICEC_JAR - echo $NICEC_JAR ! ./bin/nicec "$@" elif NICEC="`which nicec`"; then --- 8,13 ---- export NICEC_JAR ! nice_bootstrap=true ./bin/nicec "$@" elif NICEC="`which nicec`"; then Index: nicec =================================================================== RCS file: /cvsroot/nice/Nice/bin/nicec,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** nicec 21 Apr 2003 18:39:46 -0000 1.34 --- nicec 11 Jun 2003 22:24:08 -0000 1.35 *************** *** 79,81 **** fi ! exec ${java} nice.tools.compiler.fun ${system_args} "$@" --- 79,85 ---- fi ! if [ "$nice_bootstrap" = true ]; then ! exec ${java} nice.tools.compiler.fun ${system_args} "$@" ! fi ! ! exec ${java} nice.tools.compiler.console.fun ${system_args} "$@" |
From: <bo...@us...> - 2003-06-11 22:24:12
|
Update of /cvsroot/nice/Nice In directory sc8-pr-cvs1:/tmp/cvs-serv21115 Modified Files: Makefile Log Message: Added the compilation listener interface. Console output is factored out in package nice.tools.compiler.console Index: Makefile =================================================================== RCS file: /cvsroot/nice/Nice/Makefile,v retrieving revision 1.119 retrieving revision 1.120 diff -C2 -d -r1.119 -r1.120 *** Makefile 6 Jun 2003 13:01:15 -0000 1.119 --- Makefile 11 Jun 2003 22:24:08 -0000 1.120 *************** *** 29,33 **** ! all: src/nice/tools/compiler.jar compiler2 archive2 stable: clean bootstrap compiler1 ant testengine archiveOld --- 29,33 ---- ! all: src/nice/tools/compiler/console.jar compiler2 archive2 stable: clean bootstrap compiler1 ant testengine archiveOld *************** *** 36,59 **** world: fixpoint check test ! src/nice/tools/compiler.jar: $(MAKE) complete compiler1: setDate ${NICEC} bossa.syntax ! ${NICEC} -R -a src/nice/tools/compiler.jar nice.tools.compiler compiler2 compiler3: setDate ${NICEC1} -R bossa.syntax ! ${NICEC1} -R -a src/nice/tools/compiler.jar nice.tools.compiler ! archiveOld: src/nice/tools/compiler.jar mkdir -p share/java ! cp src/nice/tools/compiler.jar share/java/nice.jar jar umf src/mainClass share/java/nice.jar -C classes java -C classes nice -C classes mlsub -C classes bossa -C classes gnu -C classes.old bossa -C classes.old mlsub -C classes.old nice if [ -r classes/lang/package.nicei ]; then cd classes; jar uf ../share/java/nice.jar nice/*/package.nicei; fi ! archive archive2 archive3 share/java/nice.jar: src/nice/tools/compiler.jar mkdir -p share/java ! cp src/nice/tools/compiler.jar share/java/nice.jar jar umf src/mainClass share/java/nice.jar -C classes java -C classes nice -C classes mlsub -C classes bossa -C classes gnu if [ -r classes/lang/package.nicei ]; then cd classes; jar uf ../share/java/nice.jar nice/*/package.nicei; fi --- 36,59 ---- world: fixpoint check test ! src/nice/tools/compiler/console.jar: $(MAKE) complete compiler1: setDate ${NICEC} bossa.syntax ! ${NICEC} -R -a src/nice/tools/compiler/console.jar nice.tools.compiler.console compiler2 compiler3: setDate ${NICEC1} -R bossa.syntax ! ${NICEC1} -R -a src/nice/tools/compiler/console.jar nice.tools.compiler.console ! archiveOld: src/nice/tools/compiler/console.jar mkdir -p share/java ! cp src/nice/tools/compiler/console.jar share/java/nice.jar jar umf src/mainClass share/java/nice.jar -C classes java -C classes nice -C classes mlsub -C classes bossa -C classes gnu -C classes.old bossa -C classes.old mlsub -C classes.old nice if [ -r classes/lang/package.nicei ]; then cd classes; jar uf ../share/java/nice.jar nice/*/package.nicei; fi ! archive archive2 archive3 share/java/nice.jar: src/nice/tools/compiler/console.jar mkdir -p share/java ! cp src/nice/tools/compiler/console.jar share/java/nice.jar jar umf src/mainClass share/java/nice.jar -C classes java -C classes nice -C classes mlsub -C classes bossa -C classes gnu if [ -r classes/lang/package.nicei ]; then cd classes; jar uf ../share/java/nice.jar nice/*/package.nicei; fi *************** *** 97,111 **** GCJTEMP = /tmp/Nice-gcj.jar gcj: ! cp src/nice/tools/compiler.jar $(GCJTEMP) jar umf src/mainClass $(GCJTEMP) -C classes nice/doc -C classes nice/getopt -C classes nice/lang -C classes nice/tools/ast -C classes nice/tools/code -C classes nice/tools/compiler -C classes nice/tools/util -C classes mlsub -C classes bossa -C classes gnu $(GCJ) --main=nice.tools.compiler.fun -o bin/nicec.bin $(GCJTEMP) gcj-testsuite: ! cp src/nice/tools/compiler.jar $(GCJTEMP) jar umf src/mainClass $(GCJTEMP) -C classes nice/doc -C classes nice/getopt -C classes nice/lang -C classes nice/tools/ast -C classes nice/tools/code -C classes nice/tools/compiler -C classes nice/tools/util -C classes nice/tools/testsuite -C classes mlsub -C classes bossa -C classes gnu $(GCJ) -g --main=nice.tools.testsuite.TestNice -o bin/testsuite.bin $(GCJTEMP) clean: ! rm -f src/nice/tools/compiler.jar -rm -rf classes share/java src/bossa/parser/{Parse*.java,Token*.java,ASCII_*.java} find "${TOP}" \( -name "*.class" -o -name "*.nicei" -o -name "*~" \) -exec rm {} \; --- 97,111 ---- GCJTEMP = /tmp/Nice-gcj.jar gcj: ! cp src/nice/tools/compiler/console.jar $(GCJTEMP) jar umf src/mainClass $(GCJTEMP) -C classes nice/doc -C classes nice/getopt -C classes nice/lang -C classes nice/tools/ast -C classes nice/tools/code -C classes nice/tools/compiler -C classes nice/tools/util -C classes mlsub -C classes bossa -C classes gnu $(GCJ) --main=nice.tools.compiler.fun -o bin/nicec.bin $(GCJTEMP) gcj-testsuite: ! cp src/nice/tools/compiler/console.jar $(GCJTEMP) jar umf src/mainClass $(GCJTEMP) -C classes nice/doc -C classes nice/getopt -C classes nice/lang -C classes nice/tools/ast -C classes nice/tools/code -C classes nice/tools/compiler -C classes nice/tools/util -C classes nice/tools/testsuite -C classes mlsub -C classes bossa -C classes gnu $(GCJ) -g --main=nice.tools.testsuite.TestNice -o bin/testsuite.bin $(GCJTEMP) clean: ! rm -f src/nice/tools/compiler/console.jar -rm -rf classes share/java src/bossa/parser/{Parse*.java,Token*.java,ASCII_*.java} find "${TOP}" \( -name "*.class" -o -name "*.nicei" -o -name "*~" \) -exec rm {} \; |
From: <bo...@us...> - 2003-06-11 22:24:12
|
Update of /cvsroot/nice/Nice/src/bossa/util In directory sc8-pr-cvs1:/tmp/cvs-serv21115/src/bossa/util Modified Files: User.java Internal.java Log Message: Added the compilation listener interface. Console output is factored out in package nice.tools.compiler.console Index: User.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/util/User.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** User.java 7 Apr 2003 20:35:32 -0000 1.29 --- User.java 11 Jun 2003 22:24:07 -0000 1.30 *************** *** 71,77 **** Internal.printStackTrace(); ! nice.tools.compiler.OutputMessages.warning ! ("\n"+(responsible == null ? "" : responsible.location().toString() + ": ") + ! "Warning:\n" + message); } --- 71,76 ---- Internal.printStackTrace(); ! bossa.modules.Package.currentCompilation.warning ! (responsible == null ? null : responsible.location(), message); } Index: Internal.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/util/Internal.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Internal.java 30 Apr 2002 22:08:27 -0000 1.24 --- Internal.java 11 Jun 2003 22:24:07 -0000 1.25 *************** *** 49,53 **** if(Debug.alwaysDumpStack) printStackTrace(); ! nice.tools.compiler.OutputMessages.warning("[Internal warning] "+message); } } --- 49,57 ---- if(Debug.alwaysDumpStack) printStackTrace(); ! if (bossa.modules.Package.currentCompilation != null) ! bossa.modules.Package.currentCompilation.warning ! (null, "[Internal warning] " + message); ! else ! System.err.println("[Internal warning] " + message); } } |
From: <bo...@us...> - 2003-06-11 21:52:59
|
Update of /cvsroot/nice/Nice/src/nice/tools/compiler/console In directory sc8-pr-cvs1:/tmp/cvs-serv6505/src/nice/tools/compiler/console Log Message: Directory /cvsroot/nice/Nice/src/nice/tools/compiler/console added to the repository |
From: <ar...@us...> - 2003-06-11 19:53:12
|
Update of /cvsroot/nice/Nice/testsuite/compiler In directory sc8-pr-cvs1:/tmp/cvs-serv16419/F:/nice/testsuite/compiler Modified Files: globalVariables.testsuite Log Message: Fix compilation of global constant of type char. Index: globalVariables.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/globalVariables.testsuite,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** globalVariables.testsuite 30 Apr 2003 19:39:07 -0000 1.8 --- globalVariables.testsuite 11 Jun 2003 19:53:07 -0000 1.9 *************** *** 105,106 **** --- 105,113 ---- /// package b import a x = 1; + + /// PASS + /// package a + /// TOPLEVEL + let char x = 'x'; + /// package b import a + ; |
From: <ar...@us...> - 2003-06-11 19:53:11
|
Update of /cvsroot/nice/Nice/src/gnu/bytecode In directory sc8-pr-cvs1:/tmp/cvs-serv16419/F:/nice/src/gnu/bytecode Modified Files: Field.java Log Message: Fix compilation of global constant of type char. Index: Field.java =================================================================== RCS file: /cvsroot/nice/Nice/src/gnu/bytecode/Field.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Field.java 4 Jun 2003 21:37:43 -0000 1.4 --- Field.java 11 Jun 2003 19:53:06 -0000 1.5 *************** *** 136,139 **** --- 136,140 ---- entry = cpool.addInt(((Boolean) value).booleanValue() ? 1 : 0); break; case 'C': + entry = cpool.addInt(((Character) value).charValue()); break; case 'B': case 'S': |
From: <xo...@us...> - 2003-06-11 19:05:22
|
Update of /cvsroot/nice/Nice/web In directory sc8-pr-cvs1:/tmp/cvs-serv27916 Modified Files: manual.xml Log Message: Added new sections on value dispatch, local variables, and abstract interfaces, and revised the section on package variables. Index: manual.xml =================================================================== RCS file: /cvsroot/nice/Nice/web/manual.xml,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** manual.xml 30 May 2003 12:06:07 -0000 1.20 --- manual.xml 11 Jun 2003 19:05:19 -0000 1.21 *************** *** 222,226 **** </section> ! <section><title>Parametric classes</title> <para> A powerful feature of Nice is the ability to define --- 222,226 ---- </section> ! <section id = "parametricClasses" ><title>Parametric classes</title> <para> A powerful feature of Nice is the ability to define *************** *** 584,587 **** --- 584,623 ---- </section> + <section><title>Value Dispatch</title> + <para> + In addition to choosing a method based on the classes of the + arguments, it's even possible to override a method based on the + actual values of the arguments. Currently this feature works + with integers, booleans, and Strings. This feature makes it + convenient to code things that might otherwise have required + switch statements or nested if/else statements. Using value + dispatch can be more flexible than switch or if/else statements, + because you can always add new alternatives conveniently by + just implementing a new method override. + </para> + <example> + <title>Value Dispatch</title> + <programlisting lang="nice"><![CDATA[ + String digitToString(int digit, String language) + requires digit < 10 && digit >= 0; + + digitToString(digit, language) { throw new Exception("Couldn't convert " + digit + " to language " + language); } + + digitToString(1, "english") = "one"; + digitToString(2, "english") = "two"; + digitToString(3, "english") = "three"; + + digitToString(1, "french") = "un"; + digitToString(2, "french") = "deux"; + digitToString(3, "french") = "trois"; + + String booleanToYesNo(boolean bool); + + booleanToYesNo(true) = "yes"; + booleanToYesNo(false) = "no"; + ]]></programlisting> + </example> + + </section> <section><title>Optional parameters</title> <para> *************** *** 681,693 **** <chapter><title>Statements</title> ! <section id="packageVars"><title>Package variables</title> <para> ! Since Nice uses <link linkend="packages">packages</link> as its largest ! conceptual unit, variable declarations may appear outside class ! definitions, and are useful in the same way that static variables in ! Java are. Here is the syntax: </para> <para> ! <literal>var <replaceable>type</replaceable> <replaceable>variable-name</replaceable> <optional>= <replaceable>initial-value</replaceable></optional> --- 717,740 ---- <chapter><title>Statements</title> ! <section id="localVars"><title>Local variables and constants</title> <para> ! Local variables may be defined with the <literal>var</literal> keyword. ! Here is the syntax: </para> <para> ! <literal>var <optional><replaceable>type</replaceable></optional> ! <replaceable>variable-name</replaceable> ! <optional>= <replaceable>initial-value</replaceable></optional> ! ; ! </literal> ! </para> ! <para> ! For local variables (not <link linkend = "packageVars">package ! variables</link>), the Nice also accepts the Java style of ! declaration: ! </para> ! <para> ! <literal> ! <replaceable>type</replaceable> <replaceable>variable-name</replaceable> <optional>= <replaceable>initial-value</replaceable></optional> *************** *** 695,698 **** --- 742,769 ---- </literal> </para> + <para> + Constants are declared with "let": + </para> + <literal>let <optional><replaceable>type</replaceable></optional> + <replaceable>variable-name</replaceable> + <optional>= <replaceable>initial-value</replaceable></optional> + ; + </literal> + <para> + If the variable or constant is of a simple type (i.e., not a + <link linked="parametricClasses">parameterized type</link>), then it is + not necessary to specify the type yourself, the compiler can infer + the correct type automatically. + </para> + </section> + <section id="packageVars"><title>Package variables and constants</title> + <para> + Since Nice uses <link linkend="packages">packages</link> as its largest + conceptual unit, variable and constant declarations may appear + outside class definitions, and are useful in the same way that + static variables in Java are. Their syntax is identical to the + syntax for local variables, except that either <literal>var</literal> + or <literal>let</literal> must be used, the Java style is not accepted. + </para> </section> <section id="localFunctions"><title>Local functions</title> *************** *** 1364,1375 **** </para> </section> - <!-- <section id = "abstractInterfaces"> <title>Abstract Interfaces</title> <para> ! TODO: Link to Daniel's paper, explain. </para> </section> - --> </chapter> --- 1435,1594 ---- </para> </section> <section id = "abstractInterfaces"> <title>Abstract Interfaces</title> <para> ! Nice offers a powerful tool known as the <firstterm>abstract interface ! </firstterm>. Abstract interfaces are similar in some respects to regular ! Java- or Nice-style interfaces in that they define a set of methods that ! a type must implement to be considered a member of the interface. ! </para> ! <para> ! Two things make an abstract interface different from a regular interface. ! First, a class can be made to implement an abstract interface <emphasis>after</emphasis> ! it's been defined, and even the source code is unnecessary. You can make ! the basic String class implement your new abstract interface, if you like. ! Second, an abstract interface is not actually a type, it's an annotation ! which can be applied to types. This means that when you declare an abstract ! interface, you're not creating a new type, you're saying "types which implement ! this abstract interface will all have these methods", but those types are ! not related in any other way. So it is not possible to make a <literal> ! List<MyAbstractInterface></literal>, or to use an abstract interface ! as a type declaration like <literal>var MyAbstractInterface absInter = ... ! </literal>. </para> + <para> + So what is an abstract interface <emphasis>for</emphasis>? Abstract interfaces + can appear in type parameters, so one can write methods for them: + </para> + <para> + <literal><MyAbstractInterface T> void doSomething(T thing);</literal> + </para> + <para> + and then apply these methods to any object whose class implements <literal> + MyAbstractInterface</literal>. It's especially useful for situations where + one wants to use a method on a group of unrelated types, as in the example + below. We have a <literal>log()</literal> method which is parameterized + for any class which implements the abstract interface <literal>LogEntry</literal>, + and we make a number of classes implement LogEntry, so they can be passed + to our log method. + </para> + <para> + <example id="ex:abstractInterface"><title>Abstract Interfaces</title> + <programlisting lang="nice"><![CDATA[ + //Abstract interface for things which can be logged. + abstract interface LogEntry + { + String toLogString(); + int severity(); + } + + //Some constants for severity levels + let DEBUG = 1; + let INFO = 2; + let ERROR = 3; + + <LogEntry E> void log(E entry, int severity = -1) + { + if (severity < 0) + severity = entry.severity(); + someLogWriter.println(timeStamp() + " " + severity + " " + entry.toLogString()); + } + + //Make strings pass straight through as DEBUG info. + class java.lang.String implements LogEntry; + + toLogString(s@String) = s; + severity(s@String) = DEBUG; + + + //Make throwables print a stack trace, plus a message + class nice.lang.Throwable implements LogEntry; + + toLogString(t@Throwable) + { + let writer = new StringWriter(); + let printWriter = new PrintWriter(writer); + printWriter.println("ERROR: " + t.getClass().getName() + ": " + t.getMessage()); + t.printStackTrace(printWriter); + printWriter.close(); + return writer.toString(); + } + + severity(t@Throwable) = ERROR; + + //We like to log requests, too + class javax.servlet.http.HttpServletRequest implements LogEntry; + + toLogString(r@HttpServletRequest) = "Request from: " + r.getRemoteHost(); + severity(r@HttpServletRequest) = INFO; + + ]]> + </programlisting> + </example> + </para> + <para> + There are some interesting things to notice about this code. First, + we only had to write <literal>log()</literal> once, and we left it + up to the LogEntry to do the formatting. This could be done with a + regular interface as well, except that we also made String and + Throwable implement our abstract interface, which we couldn't have + done with a regular interface. So now we can write code like + </para> + <para> + <literal><programlisting language = "nice"> + log(request); + log("Beginning processing"); + try + { + 1/0; + } + catch (Exception e) + { + log(e); + } + </programlisting></literal> + </para> + <para> + and our abstract interface implementations will take care of making + sure that we get the right formatting and severity levels. The most + interesting thing about this code is that if we write <literal>log(5) + </literal> then the compiler will catch the error, because <literal> + byte</literal> doesn't implement <literal>LogEntry</literal>. If + we had defined <literal>log</literal> with the signature <literal> + <E> void log(E entry, int severity = -1)</literal>, we could + have achieved all the same effects, but we would have lost the + type safety abstract interfaces gave us above - because <E> + means <emphasis>any</emphasis> type is allowed, so we would have + had to define some defaults: + </para> + <para> + <literal><programlisting language = "nice"> + toLogString(e) + { + throw new Exception("No toLogString method defined!"); + } + + severity(e) + { + throw new Exception("No severity method defined!"); + } + </programlisting></literal> + </para> + <para> + Then we'd be no better off than in a dynamically typed language - + we wouldn't find out that we'd tried to log a 5 until we got an + exception at runtime. With abstract interfaces, we were able to + tell the compiler <emphasis>exactly</emphasis> which classes + should be allowed as arguments to <literal>log</literal>, and so + our program is safer as a result. + </para> + <para> + Daniel Bonniot, Nice's creator, invented abstract interfaces. You + can read more about them in the + <ulink url = "http://nice.sourceforge.net/research.html">Academic + Research</ulink> section of the Nice website. + </para> + </section> </chapter> |
From: <ar...@us...> - 2003-06-11 18:15:57
|
Update of /cvsroot/nice/Nice/src/nice/tools/testsuite In directory sc8-pr-cvs1:/tmp/cvs-serv6038/F:/nice/src/nice/tools/testsuite Modified Files: TestSuite.java Log Message: Fix output for skip testcases. Index: TestSuite.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/testsuite/TestSuite.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** TestSuite.java 6 Jun 2003 15:18:17 -0000 1.15 --- TestSuite.java 11 Jun 2003 18:15:53 -0000 1.16 *************** *** 208,211 **** --- 208,212 ---- if (testCase.skip) { + TestNice.getOutput().startTestCase(testCase); testCase.fail(); continue; |
From: <ar...@us...> - 2003-06-11 17:39:38
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv18371/F:/nice/src/bossa/syntax Modified Files: typecheck.nice Log Message: Changed error message for boolean conditions. fixes "bug" #750432 . Index: typecheck.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typecheck.nice,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** typecheck.nice 27 May 2003 23:42:15 -0000 1.71 --- typecheck.nice 11 Jun 2003 17:39:33 -0000 1.72 *************** *** 363,378 **** Expression elseExp = notNull(e.elseExp); ! try{ ! condition = condition.resolveOverloading(PrimitiveType.boolPolytype); ! checkAssignment(PrimitiveType.boolPolytype, condition); ! e.condition = condition; ! } ! catch(TypingEx t){ ! if (notNullError(t, e, condition.toString())) ! throw new bossa.util.UserError ! (e, ! "The condition must be a boolean.\n" + ! condition + " has type " + condition.getType()); ! } enterIf(); --- 363,369 ---- Expression elseExp = notNull(e.elseExp); ! condition = condition.resolveOverloading(PrimitiveType.boolPolytype); ! checkBooleanCondition(condition); ! e.condition = condition; enterIf(); *************** *** 614,627 **** { l.whileExp = whileExp = whileExp.resolveOverloading(PrimitiveType.boolPolytype); ! try { ! checkAssignment(PrimitiveType.boolPolytype, whileExp); ! } ! catch(TypingEx t) { ! if (notNullError(t, l, whileExp.toString())) ! throw new bossa.util.UserError ! (whileExp, ! "The condition must be a boolean.\n" + ! whileExp + " has type " + whileExp.getType()); ! } } --- 605,609 ---- { l.whileExp = whileExp = whileExp.resolveOverloading(PrimitiveType.boolPolytype); ! checkBooleanCondition(whileExp); } *************** *** 769,772 **** --- 751,766 ---- return true; } + + void checkBooleanCondition(Expression condition) { + try { + checkAssignment(PrimitiveType.boolPolytype, condition); + } + catch(TypingEx t){ + throw new bossa.util.UserError(condition, + "The condition must be a boolean.\n" + + condition + " has type " + condition.getType()); + } + } + void wrongReturnType(bossa.util.Located responsible, |
From: <ar...@us...> - 2003-06-11 14:52:32
|
Update of /cvsroot/nice/Nice/debian In directory sc8-pr-cvs1:/tmp/cvs-serv28439/F:/nice/debian Modified Files: changelog Log Message: Removed nested lookahead in localTuplePart and some other little improvements. Fixes bug #747837. Index: changelog =================================================================== RCS file: /cvsroot/nice/Nice/debian/changelog,v retrieving revision 1.172 retrieving revision 1.173 diff -C2 -d -r1.172 -r1.173 *** changelog 11 Jun 2003 12:21:28 -0000 1.172 --- changelog 11 Jun 2003 14:52:27 -0000 1.173 *************** *** 15,18 **** --- 15,19 ---- * The 'char' type is no longer a subtype of int. The integer unicode representation of a character c can be obtained by int(c). + * Bugfixes (Parsing of nested tuples, ...) -- |
From: <ar...@us...> - 2003-06-11 14:52:30
|
Update of /cvsroot/nice/Nice/testsuite/compiler/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv28439/F:/nice/testsuite/compiler/syntax Modified Files: tuples.testsuite Log Message: Removed nested lookahead in localTuplePart and some other little improvements. Fixes bug #747837. Index: tuples.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/syntax/tuples.testsuite,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tuples.testsuite 28 May 2003 10:48:42 -0000 1.3 --- tuples.testsuite 11 Jun 2003 14:52:27 -0000 1.4 *************** *** 28,29 **** --- 28,54 ---- /// FAIL /*/// FAIL HERE */(String s, int i) = (5, "abc"); + + /// PASS + int x; + int y; + int z; + (x, (y, z)) = (1, (2, 3)); + + /// PASS + int x; + int y; + (x, (y, int z)) = (1, (2, 3)); + + /// PASS + int x; + (x, (int, int) tuple) = (1, (2, 3)); + + /// PASS + let x = new X(); + (x.a , x.b) = (x.b , x.a); + assert x.a==10 && x.b==5; + /// Toplevel + class X { + int a = 5; + int b = 10; + } |
From: <ar...@us...> - 2003-06-11 14:52:30
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1:/tmp/cvs-serv28439/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Removed nested lookahead in localTuplePart and some other little improvements. Fixes bug #747837. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.181 retrieving revision 1.182 diff -C2 -d -r1.181 -r1.182 *** Parser.jj 5 Jun 2003 23:47:23 -0000 1.181 --- Parser.jj 11 Jun 2003 14:52:24 -0000 1.182 *************** *** 2392,2397 **** res = LocalDeclaration() ";" ) | - LOOKAHEAD( LocalTupleDeclarationLookahead() ) res=LocalTupleDeclaration(statements) --- 2392,2399 ---- res = LocalDeclaration() ";" ) + | //try first a tupleExp before a tupleDeclaration + LOOKAHEAD ( LocalTupleExpLookahead() ) + res=Statement() | LOOKAHEAD( LocalTupleDeclarationLookahead() ) res=LocalTupleDeclaration(statements) *************** *** 2497,2503 **** Expression LocalTuplePart(List statements) : ! {} { ! LOOKAHEAD( "(" LocalTuplePart() "," ) "(" { List parts = new LinkedList(); Expression part; } part = LocalTuplePart(statements) { parts.add(part); } --- 2499,2512 ---- Expression LocalTuplePart(List statements) : ! { LocatedString id; Monotype type; } { ! ( //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(new Block.LocalVariable(id, type, false, null)); ! return new IdentExp(id); } ! | //otherwise it's localtuple part "(" { List parts = new LinkedList(); Expression part; } part = LocalTuplePart(statements) { parts.add(part); } *************** *** 2505,2516 **** ")" { return new TupleExp(parts); } ! | ! { LocatedString id; Monotype type = null; } ! [ LOOKAHEAD(monotype() ident()) type = monotype() ] id = ident() ! { ! if (type != null) ! statements.add(new Block.LocalVariable(id, type, false, null)); ! return new IdentExp(id); ! } } --- 2514,2518 ---- ")" { return new TupleExp(parts); } ! ) } *************** *** 2535,2539 **** "(" LocalTupleDeclarationContent() ")" // Identifiers, either in types, or as a variable to assign to. ! | <IDENT> // All tokens that can be part of a monotype // (exception "(" and ")" which are already handled, since they are --- 2537,2541 ---- "(" LocalTupleDeclarationContent() ")" // Identifiers, either in types, or as a variable to assign to. ! | <IDENT> // All tokens that can be part of a monotype // (exception "(" and ")" which are already handled, since they are *************** *** 2542,2545 **** --- 2544,2567 ---- )+ } + + // lookahead for a tupleExp on left side of an assignment + void LocalTupleExpLookahead() : {} + { + "(" LocalTupleExpContent() ")" "=" + } + + void LocalTupleExpContent() : { } + { + ( "(" LocalTupleExpContent() ")" + | doted_string() + ) + ( "," + ( "(" LocalTupleExpContent() ")" + | doted_string() + ) + )* + } + + Statement EmptyStatement() : |
From: <bo...@us...> - 2003-06-11 12:22:00
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang In directory sc8-pr-cvs1:/tmp/cvs-serv18530/stdlib/nice/lang Modified Files: strings.nice rawArray.java prelude.nice numeric.nice Log Message: char is no longer a subtype of int. Index: strings.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/strings.nice,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** strings.nice 3 Jun 2003 19:14:18 -0000 1.10 --- strings.nice 11 Jun 2003 12:21:25 -0000 1.11 *************** *** 23,26 **** --- 23,31 ---- <Any R> String `+`(String s, R o) = s.concat(String.valueOf(o)); + int indexOf(String, char) = native int String.indexOf(int); + int indexOf(String, char, int) = native int String.indexOf(int, int); + int lastIndexOf(String, char) = native int String.lastIndexOf(int); + int lastIndexOf(String, char, int) = native int String.lastIndexOf(int, int); + String replace(String source, char c, String with) { Index: rawArray.java =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/rawArray.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** rawArray.java 24 Jan 2003 13:20:30 -0000 1.9 --- rawArray.java 11 Jun 2003 12:21:26 -0000 1.10 *************** *** 135,144 **** { Object o = array[i]; ! try{ ! res[i] = ((Number) o).intValue(); ! } ! catch(ClassCastException e){ ! res[i] = ((Character) o).charValue(); ! } } --- 135,139 ---- { Object o = array[i]; ! res[i] = ((Number) o).intValue(); } *************** *** 155,164 **** { Object o = array[i]; ! try{ ! res[i] = ((Number) o).longValue(); ! } ! catch(ClassCastException e){ ! res[i] = ((Character) o).charValue(); ! } } --- 150,154 ---- { Object o = array[i]; ! res[i] = ((Number) o).longValue(); } *************** *** 175,184 **** { Object o = array[i]; ! try{ ! res[i] = ((Number) o).floatValue(); ! } ! catch(ClassCastException e){ ! res[i] = ((Character) o).charValue(); ! } } --- 165,169 ---- { Object o = array[i]; ! res[i] = ((Number) o).floatValue(); } *************** *** 195,204 **** { Object o = array[i]; ! try{ ! res[i] = ((Number) o).doubleValue(); ! } ! catch(ClassCastException e){ ! res[i] = ((Character) o).charValue(); ! } } --- 180,184 ---- { Object o = array[i]; ! res[i] = ((Number) o).doubleValue(); } *************** *** 284,293 **** { Object o = Array.get(array, i); ! try{ ! res[i] = ((Number) o).intValue(); ! } ! catch(ClassCastException e){ ! res[i] = ((Character) o).charValue(); ! } } --- 264,268 ---- { Object o = Array.get(array, i); ! res[i] = ((Number) o).intValue(); } *************** *** 305,314 **** { Object o = Array.get(array, i); ! try{ ! res[i] = ((Number) o).longValue(); ! } ! catch(ClassCastException e){ ! res[i] = ((Character) o).charValue(); ! } } --- 280,284 ---- { Object o = Array.get(array, i); ! res[i] = ((Number) o).longValue(); } *************** *** 326,335 **** { Object o = Array.get(array, i); ! try{ ! res[i] = ((Number) o).floatValue(); ! } ! catch(ClassCastException e){ ! res[i] = ((Character) o).charValue(); ! } } --- 296,300 ---- { Object o = Array.get(array, i); ! res[i] = ((Number) o).floatValue(); } *************** *** 347,356 **** { Object o = Array.get(array, i); ! try{ ! res[i] = ((Number) o).doubleValue(); ! } ! catch(ClassCastException e){ ! res[i] = ((Character) o).charValue(); ! } } --- 312,316 ---- { Object o = Array.get(array, i); ! res[i] = ((Number) o).doubleValue(); } Index: prelude.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/prelude.nice,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** prelude.nice 6 Jun 2003 13:08:01 -0000 1.30 --- prelude.nice 11 Jun 2003 12:21:26 -0000 1.31 *************** *** 66,70 **** class byte extends short = native; ! class char extends int = native; double doubleValue(Number) = native double Number.doubleValue(); --- 66,70 ---- class byte extends short = native; ! final class char = native; double doubleValue(Number) = native double Number.doubleValue(); Index: numeric.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/numeric.nice,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** numeric.nice 4 Jun 2003 17:06:53 -0000 1.27 --- numeric.nice 11 Jun 2003 12:21:26 -0000 1.28 *************** *** 32,36 **** short short (double) = inline nice.lang.inline.Nop(); byte byte (double) = inline nice.lang.inline.Nop(); ! char char (double) = inline nice.lang.inline.Nop(); --- 32,39 ---- short short (double) = inline nice.lang.inline.Nop(); byte byte (double) = inline nice.lang.inline.Nop(); ! ! // Conversions between characters and their unicode representation ! char char (int) = inline nice.lang.inline.Nop(); ! int int (char) = inline nice.lang.inline.Nop(); *************** *** 144,151 **** short `|`(short, short) = inline nice.lang.inline.NumOp("iIOr"); short `^`(short, short) = inline nice.lang.inline.NumOp("iXOr"); - - char `&`(char, char) = inline nice.lang.inline.NumOp("iAnd"); - char `|`(char, char) = inline nice.lang.inline.NumOp("iIOr"); - char `^`(char, char) = inline nice.lang.inline.NumOp("iXOr"); /**************************************************************** --- 147,150 ---- |
From: <bo...@us...> - 2003-06-11 12:21:59
|
Update of /cvsroot/nice/Nice/testsuite/compiler/expressions/operators/numeric In directory sc8-pr-cvs1:/tmp/cvs-serv18530/testsuite/compiler/expressions/operators/numeric Modified Files: conversion.testsuite Log Message: char is no longer a subtype of int. Index: conversion.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/expressions/operators/numeric/conversion.testsuite,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** conversion.testsuite 18 Apr 2003 15:14:47 -0000 1.3 --- conversion.testsuite 11 Jun 2003 12:21:25 -0000 1.4 *************** *** 20,24 **** /// PASS ! int i = 'A'; char c = char(i); assert c == 'A'; --- 20,24 ---- /// PASS ! int i = int('A'); char c = char(i); assert c == 'A'; |
From: <bo...@us...> - 2003-06-11 12:21:32
|
Update of /cvsroot/nice/Nice/debian In directory sc8-pr-cvs1:/tmp/cvs-serv18530/debian Modified Files: changelog Log Message: char is no longer a subtype of int. Index: changelog =================================================================== RCS file: /cvsroot/nice/Nice/debian/changelog,v retrieving revision 1.171 retrieving revision 1.172 diff -C2 -d -r1.171 -r1.172 *** changelog 10 Jun 2003 20:20:51 -0000 1.171 --- changelog 11 Jun 2003 12:21:28 -0000 1.172 *************** *** 5,9 **** foo("blue") { ... } foo("red") { ... } ! foo(color) { println("unknown color" + color); } * Added operator ** to calculate powers of longs, doubles and BigIntegers. * Archives (generated with the -a option) can now be used to distribute --- 5,9 ---- foo("blue") { ... } foo("red") { ... } ! foo(color) { println("unknown color: " + color); } * Added operator ** to calculate powers of longs, doubles and BigIntegers. * Archives (generated with the -a option) can now be used to distribute *************** *** 13,16 **** --- 13,18 ---- The termination properties of loops with literal boolean values are now recognized, as in Java. + * The 'char' type is no longer a subtype of int. The integer unicode + representation of a character c can be obtained by int(c). -- |
From: <bo...@us...> - 2003-06-11 12:21:32
|
Update of /cvsroot/nice/Nice/regtest/basic In directory sc8-pr-cvs1:/tmp/cvs-serv18530/regtest/basic Modified Files: arrays.nice Log Message: char is no longer a subtype of int. Index: arrays.nice =================================================================== RCS file: /cvsroot/nice/Nice/regtest/basic/arrays.nice,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** arrays.nice 20 Feb 2003 11:16:14 -0000 1.19 --- arrays.nice 11 Jun 2003 12:21:28 -0000 1.20 *************** *** 105,110 **** short[] shs = map(bs, id); shs[0] = 129; ! char[] cs = new char[1]; ! cs[0] = 'A'; double[] ds = map(cs, id); p(ds); --- 105,110 ---- short[] shs = map(bs, id); shs[0] = 129; ! int[] cs = new int[1]; ! cs[0] = 65; double[] ds = map(cs, id); p(ds); |
From: <bo...@us...> - 2003-06-11 12:21:31
|
Update of /cvsroot/nice/Nice/stdlib/nice/getopt In directory sc8-pr-cvs1:/tmp/cvs-serv18530/stdlib/nice/getopt Modified Files: options.nice gnugetopt.nice getopt.nice Log Message: char is no longer a subtype of int. Index: options.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/getopt/options.nice,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** options.nice 22 Jan 2003 17:10:13 -0000 1.5 --- options.nice 11 Jun 2003 12:21:27 -0000 1.6 *************** *** 50,54 **** String longName; String purpose; ! int optval = 0; // the int value of shortName boolean visible; --- 50,54 ---- String longName; String purpose; ! char optval = '\0'; boolean visible; Index: gnugetopt.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/getopt/gnugetopt.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gnugetopt.nice 28 Apr 2003 23:28:47 -0000 1.2 --- gnugetopt.nice 11 Jun 2003 12:21:27 -0000 1.3 *************** *** 37,41 **** private boolean endparse = false; private boolean opterr = true; ! private int optopt = '?'; private int optind = 0; private int longind = 0; --- 37,41 ---- private boolean endparse = false; private boolean opterr = true; ! private char optopt = '?'; private int optind = 0; private int longind = 0; *************** *** 99,103 **** } ! public int getOptopt() = optopt; public int getLongind() = longind; --- 99,103 ---- } ! public char getOptopt() = optopt; public int getLongind() = longind; *************** *** 152,156 **** } ! private int checkLongOption() { ?LongOpt pfound = null; --- 152,156 ---- } ! private char checkLongOption() { ?LongOpt pfound = null; *************** *** 201,207 **** nextchar = ""; ! optopt = 0; ++optind; ! return('?'); } --- 201,207 ---- nextchar = ""; ! optopt = '\0'; ++optind; ! return '?'; } *************** *** 233,237 **** nextchar = ""; optopt = pfound.val; ! return('?'); } } // if (nameend) --- 233,237 ---- nextchar = ""; optopt = pfound.val; ! return '?'; } } // if (nameend) *************** *** 260,264 **** sb.setLength(0); sb.append(pfound.val); ! return(0); } --- 260,264 ---- sb.setLength(0); sb.append(pfound.val); ! return '\0'; } *************** *** 268,280 **** longopt_handled = false; ! return(0); } ! public int getopt() { optarg = null; if (endparse == true) ! return(-1); if ((nextchar == null) || (nextchar.equals(""))) --- 268,280 ---- longopt_handled = false; ! return '\0'; } ! public char getopt() { optarg = null; if (endparse == true) ! return '\1'; if ((nextchar == null) || (nextchar.equals(""))) *************** *** 333,337 **** optind = first_nonopt; ! return(-1); } --- 333,337 ---- optind = first_nonopt; ! return '\1'; } *************** *** 342,349 **** { if (ordering == REQUIRE_ORDER) ! return(-1); optarg = argv[optind++]; ! return(1); } --- 342,349 ---- { if (ordering == REQUIRE_ORDER) ! return '\1'; optarg = argv[optind++]; ! return '\2'; } *************** *** 374,381 **** (optstring.indexOf(argv[optind].charAt(1)) == -1))))) { ! int c = this.checkLongOption(); if (longopt_handled) ! return(c); // Can't find it as a long option. If this is not getopt_long_only, --- 374,381 ---- (optstring.indexOf(argv[optind].charAt(1)) == -1))))) { ! char c = this.checkLongOption(); if (longopt_handled) ! return c; // Can't find it as a long option. If this is not getopt_long_only, *************** *** 396,406 **** nextchar = ""; ++optind; ! optopt = 0; ! return('?'); } } // if (longopts) // Look at and handle the next short option-character */ ! int c = (nextchar || "").charAt(0); //**** Do we need to check for empty str? if ((nextchar || "").length() > 1) nextchar = (nextchar || "").substring(1); --- 396,406 ---- nextchar = ""; ++optind; ! optopt = '\0'; ! return '?'; } } // if (longopts) // Look at and handle the next short option-character */ ! char c = notNull(nextchar).charAt(0); //**** Do we need to check for empty str? if ((nextchar || "").length() > 1) nextchar = (nextchar || "").substring(1); *************** *** 422,426 **** System.err.println(progname+": illegal option -- "+this.toString()); else ! System.err.println(progname+": invalid option -- "+char(c).toString()); } --- 422,426 ---- System.err.println(progname+": illegal option -- "+this.toString()); else ! System.err.println(progname+": invalid option -- "+c.toString()); } *************** *** 440,444 **** { if (opterr) ! System.err.println(progname+": option '"+char(c).toString()+"' doesn't allow an argument"); optopt = c; --- 440,444 ---- { if (opterr) ! System.err.println(progname+": option '"+c.toString()+"' doesn't allow an argument"); optopt = c; *************** *** 493,497 **** { if (opterr) ! System.err.println(progname+": option requires an argument -- "+char(c).toString()); optopt = c; --- 493,497 ---- { if (opterr) ! System.err.println(progname+": option requires an argument -- "+c.toString()); optopt = c; *************** *** 513,517 **** { if (opterr) ! System.err.println(progname+": option requires an argument -- "+char(c).toString()); optopt = c; --- 513,517 ---- { if (opterr) ! System.err.println(progname+": option requires an argument -- "+c.toString()); optopt = c; *************** *** 550,554 **** private int has_arg; private ?StringBuffer flag = null; ! private int val; public void initLongOpt() //throws IllegalArgumentException --- 550,554 ---- private int has_arg; private ?StringBuffer flag = null; ! private char val; public void initLongOpt() //throws IllegalArgumentException *************** *** 568,572 **** public ?StringBuffer getFlag() = flag; ! public int getVal() = val; } // Class LongOpt --- 568,572 ---- public ?StringBuffer getFlag() = flag; ! public char getVal() = val; } // Class LongOpt Index: getopt.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/getopt/getopt.nice,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** getopt.nice 31 Mar 2003 19:15:11 -0000 1.15 --- getopt.nice 11 Jun 2003 12:21:27 -0000 1.16 *************** *** 31,35 **** { uniqId = uniqId+1; ! l = new LongOpt(name:o.longName, has_arg:optType(o), val:uniqId); } else --- 31,35 ---- { uniqId = uniqId+1; ! l = new LongOpt(name:o.longName, has_arg:optType(o), val:char(uniqId)); } else *************** *** 49,57 **** longOpts[i] = longOptions.get(i); Getopt g = new Getopt(progname: progName, argv: args, optstring: shortOptions, ! long_options: cast(longOpts)); g.initGetopt(); // Parsing loop ! int c = g.getopt(); ! while (c != -1) { ?Option chosen = options.find(Option o => o.optval == c); --- 49,57 ---- longOpts[i] = longOptions.get(i); Getopt g = new Getopt(progname: progName, argv: args, optstring: shortOptions, ! long_options: elementsNotNull(longOpts)); g.initGetopt(); // Parsing loop ! char c = g.getopt(); ! while (c != '\1') { ?Option chosen = options.find(Option o => o.optval == c); |
From: <ar...@us...> - 2003-06-10 20:20:55
|
Update of /cvsroot/nice/Nice/debian In directory sc8-pr-cvs1:/tmp/cvs-serv26060/F:/nice/debian Modified Files: changelog Log Message: update of changelog. Index: changelog =================================================================== RCS file: /cvsroot/nice/Nice/debian/changelog,v retrieving revision 1.170 retrieving revision 1.171 diff -C2 -d -r1.170 -r1.171 *** changelog 4 Jun 2003 21:37:45 -0000 1.170 --- changelog 10 Jun 2003 20:20:51 -0000 1.171 *************** *** 1,4 **** --- 1,9 ---- nice (0.9.0) unstable; urgency=low + * Added dispatch on String literals. This can be used as a switch on Strings. + void foo(String color); + foo("blue") { ... } + foo("red") { ... } + foo(color) { println("unknown color" + color); } * Added operator ** to calculate powers of longs, doubles and BigIntegers. * Archives (generated with the -a option) can now be used to distribute |