nice-commit Mailing List for The Nice Programming Language (Page 44)
Brought to you by:
bonniot
You can subscribe to this list here.
2003 |
Jan
|
Feb
(60) |
Mar
(125) |
Apr
(183) |
May
(140) |
Jun
(227) |
Jul
(141) |
Aug
(181) |
Sep
(75) |
Oct
(89) |
Nov
(187) |
Dec
(162) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(69) |
Feb
(197) |
Mar
(98) |
Apr
(26) |
May
(10) |
Jun
(85) |
Jul
(88) |
Aug
(79) |
Sep
(80) |
Oct
(81) |
Nov
(53) |
Dec
(109) |
2005 |
Jan
(68) |
Feb
(77) |
Mar
(232) |
Apr
(79) |
May
(37) |
Jun
(37) |
Jul
(3) |
Aug
(18) |
Sep
|
Oct
|
Nov
|
Dec
|
2006 |
Jan
(10) |
Feb
|
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(1) |
Dec
(9) |
2007 |
Jan
(2) |
Feb
(8) |
Mar
(2) |
Apr
(5) |
May
|
Jun
|
Jul
|
Aug
(4) |
Sep
|
Oct
|
Nov
(17) |
Dec
(6) |
2008 |
Jan
|
Feb
(3) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Daniel B. <bo...@us...> - 2004-07-02 19:31:14
|
Update of /cvsroot/nice/Nice In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14796 Modified Files: Makefile Log Message: Abstracted the resource location in pathes in the nice.tools.locator package. Index: Makefile =================================================================== RCS file: /cvsroot/nice/Nice/Makefile,v retrieving revision 1.147 retrieving revision 1.148 diff -C2 -d -r1.147 -r1.148 *** Makefile 2 Jul 2004 15:25:15 -0000 1.147 --- Makefile 2 Jul 2004 19:31:03 -0000 1.148 *************** *** 65,68 **** --- 65,69 ---- compiler2 compiler3: setDate + ${NICEC1} -r nice.tools.locator ${NICEC1} -R bossa.syntax ${NICEC1} -R -a src/nice/tools/compiler/console.jar nice.tools.compiler.console *************** *** 159,162 **** --- 160,165 ---- ln -sf nicec bin/nicedoc; ln -sf nicec bin/niceunit -cd src/bossa/syntax && mv -f dispatch.java.bootstrap dispatch.java + ${JAVAC} src/nice/tools/util/System.java + ${NICEC} nice.tools.locator ${JAVAC} \ src/bossa/syntax/dispatch.java \ |
From: Daniel B. <bo...@us...> - 2004-07-02 19:31:14
|
Update of /cvsroot/nice/Nice/src/bossa/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14796/src/bossa/modules Modified Files: Locator.java DirectorySourceContent.java CompiledContent.java Log Message: Abstracted the resource location in pathes in the nice.tools.locator package. Index: Locator.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/Locator.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Locator.java 7 Aug 2003 09:53:39 -0000 1.3 --- Locator.java 2 Jul 2004 19:31:03 -0000 1.4 *************** *** 30,35 **** Locator (Compilation compilation, String classpath) { ! sourceRoots = splitPath(compilation.sourcePath); ! packageRoots = splitPath(classpath); } --- 30,52 ---- Locator (Compilation compilation, String classpath) { ! sources = new nice.tools.locator.Locator ! (compilation.sourcePath, ! new gnu.mapping.Procedure1() { ! public Object apply1(Object o) { ! String message = (String) o; ! User.warning(message); ! return null; ! } ! }); ! ! packages = new nice.tools.locator.Locator ! (classpath, ! new gnu.mapping.Procedure1() { ! public Object apply1(Object o) { ! String message = (String) o; ! User.warning(message); ! return null; ! } ! }); } *************** *** 39,57 **** CompiledContent compiled = null; ! String filesystemName = pkg.getName().replace('.', File.separatorChar); ! ! for (int i = 0; source == null && i < sourceRoots.length; i++) ! // source files cannot be in Jar files ! if (sourceRoots[i] instanceof File) ! source = DirectorySourceContent.create ! (pkg, new File((File) sourceRoots[i], filesystemName)); - for (int i = 0; compiled == null && i < packageRoots.length; i++) - if (packageRoots[i] instanceof File) - compiled = DirectoryCompiledContent.create - (pkg, new File((File) packageRoots[i], filesystemName)); - else - compiled = JarCompiledContent.create(pkg, (JarFile) packageRoots[i]); - Content res = new Content(pkg, source, compiled); --- 56,70 ---- CompiledContent compiled = null; ! String name = pkg.getName().replace('.', '/'); ! ! java.net.URLConnection sroot = sources.get(name); ! java.net.URLConnection croot = packages.get(name + "/package.nicei"); ! ! if (sroot != null) ! source = DirectorySourceContent.create(pkg, sroot.getURL()); ! ! if (croot != null) ! compiled = CompiledContent.create(pkg, croot.getURL()); Content res = new Content(pkg, source, compiled); *************** *** 65,115 **** * Private ****************************************************************/ ! /** where to find source files. */ ! private final Object[] sourceRoots; /** where to find compiled packages. */ ! private final Object[] packageRoots; ! ! private static Object[] splitPath (String path) ! { ! LinkedList res = new LinkedList(); ! ! int start = 0; ! // skip starting separators ! while (start<path.length() && ! path.charAt(start) == File.pathSeparatorChar) ! start++; ! ! while(start<path.length()) ! { ! int end = path.indexOf(File.pathSeparatorChar, start); ! if (end == -1) ! end = path.length(); ! ! String pathComponent = path.substring(start, end); ! if (pathComponent.length() > 0) ! { ! File f = nice.tools.util.System.getFile(pathComponent).getAbsoluteFile(); ! // Ignore non-existing directories and archives ! if (f.exists()) ! { ! if (pathComponent.endsWith(".jar")) ! try{ ! res.add(new JarFile(f)); ! } ! catch(IOException e){} ! else if (f.isDirectory()) ! res.add(f); ! else ! User.warning("Path " + f + " is not valid"); ! } ! else ! User.warning("Path " + f + " does not exist"); ! } ! start = end + 1; ! } ! ! return res.toArray(new Object[res.size()]); ! } } --- 78,86 ---- * Private ****************************************************************/ ! /** where to find source files. */ ! private final nice.tools.locator.Locator sources; /** where to find compiled packages. */ ! private final nice.tools.locator.Locator packages; } Index: DirectorySourceContent.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/DirectorySourceContent.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DirectorySourceContent.java 24 Jun 2003 15:28:19 -0000 1.2 --- DirectorySourceContent.java 2 Jul 2004 19:31:03 -0000 1.3 *************** *** 20,24 **** /** A package located in a directory. ! @version $Date$ @author Daniel Bonniot --- 20,24 ---- /** A package located in a directory. ! @version $Date$ @author Daniel Bonniot *************** *** 39,42 **** --- 39,50 ---- } + static DirectorySourceContent create(Package pkg, java.net.URL url) + { + if (! url.getProtocol().equals("file")) + User.error("Cannot use " + url + " to get sources for package " + pkg); + + return create(pkg, new File(url.getFile())); + } + DirectorySourceContent(Package pkg, File directory) { *************** *** 45,49 **** this.sources = getSources(); ! lastModification = maxLastModification(sources); } --- 53,57 ---- this.sources = getSources(); ! lastModification = maxLastModification(sources); } Index: CompiledContent.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/CompiledContent.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CompiledContent.java 18 Apr 2002 11:11:35 -0000 1.3 --- CompiledContent.java 2 Jul 2004 19:31:03 -0000 1.4 *************** *** 61,63 **** --- 61,87 ---- /** return a longer string that identifies the type of package source too. */ abstract public String toString(); + + static CompiledContent create(Package pkg, java.net.URL url) + { + if (url.getProtocol().equals("file")) + { + File dir = new File(url.getFile()).getParentFile(); + return DirectoryCompiledContent.create(pkg, dir); + } + + if (url.getProtocol().equals("jar")) + { + String jar = url.getFile(); + jar = jar.substring(jar.indexOf(':') + 1, jar.indexOf('!')); + try { + return JarCompiledContent.create + (pkg, new java.util.jar.JarFile(jar)); + } + catch(IOException e) { + return null; + } + } + + return null; + } } |
From: Daniel B. <bo...@us...> - 2004-07-02 19:31:14
|
Update of /cvsroot/nice/Nice/src/nice/tools/code In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14796/src/nice/tools/code Modified Files: TypeImport.java ClassLoader.java Log Message: Abstracted the resource location in pathes in the nice.tools.locator package. Index: TypeImport.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/code/TypeImport.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TypeImport.java 2 Jul 2004 12:12:20 -0000 1.6 --- TypeImport.java 2 Jul 2004 19:31:03 -0000 1.7 *************** *** 179,222 **** currentClasspath = classpath; ! LinkedList components = new LinkedList(); ! ! int start = 0; ! // skip starting separators ! while (start<classpath.length() && ! classpath.charAt(start) == File.pathSeparatorChar) ! start++; ! ! while(start<classpath.length()) ! { ! int end = classpath.indexOf(File.pathSeparatorChar, start); ! if (end == -1) ! end = classpath.length(); ! ! String pathComponent = classpath.substring(start, end); ! if (pathComponent.length() > 0) ! try{ ! File f = nice.tools.util.System.getFile(pathComponent); ! if (f.canRead()) ! components.add(f.getCanonicalFile().toURL()); ! else ! { ! if (!f.exists()) ! User.warning("Classpath component " + pathComponent + " does not exist"); ! else ! User.warning("Classpath component " + pathComponent + " is not readable"); ! } ! } ! catch(java.net.MalformedURLException e){ ! User.warning("Classpath component " + pathComponent + " is invalid"); ! } ! catch(java.io.IOException e){ ! User.warning("Classpath component " + pathComponent + " is invalid"); ! } ! start = end+1; ! } ! classLoader = new java.net.URLClassLoader ! ((URL[]) components.toArray(new URL[components.size()]), ! /* no parent */ null); } } --- 179,193 ---- currentClasspath = classpath; ! URL[] path = nice.tools.locator.dispatch.parsePath ! (classpath, ! new gnu.mapping.Procedure1() { ! public Object apply1(Object o) { ! String message = (String) o; ! User.warning(message); ! return null; ! } ! }); ! classLoader = new java.net.URLClassLoader(path, /* no parent */ null); } } Index: ClassLoader.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/code/ClassLoader.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ClassLoader.java 1 Jul 2004 11:41:41 -0000 1.1 --- ClassLoader.java 2 Jul 2004 19:31:03 -0000 1.2 *************** *** 33,84 **** { this.registrar = registrar; ! this.locations = splitPath(classpath); } public ClassType load(String className) { ! String filesystemName = className.replace('.', File.separatorChar) + ".class"; ! String jarName = className.replace('.', '/') + ".class"; ! ! for (int i = 0; i < locations.length; i++) ! { ! InputStream input = null; ! if (locations[i] instanceof File) ! { ! File dir = (File) locations[i]; ! File file = new File(dir, filesystemName); ! try { ! input = new FileInputStream(file); ! } ! catch(FileNotFoundException ex) { ! } ! } ! else ! { ! JarFile jar = (JarFile) locations[i]; ! JarEntry e = jar.getJarEntry(jarName); ! if (e != null) ! try { ! input = jar.getInputStream(e); ! } ! catch(java.io.IOException ex) { ! } ! } ! if (input != null) ! { ! ClassType res = new ClassType(); ! registrar.register(className, res); ! try { ! new ClassFileInput(res, input); ! return res; ! } ! catch (IOException ex) { ! } ! } ! } ! return null; } --- 33,64 ---- { this.registrar = registrar; ! this.locator = new nice.tools.locator.Locator ! (classpath, ! new gnu.mapping.Procedure1() { ! public Object apply1(Object o) { ! return null; ! } ! }); } public ClassType load(String className) { ! String name = className.replace('.', '/') + ".class"; ! java.net.URLConnection resource = locator.get(name); ! if (resource == null) ! return null; ! try { ! InputStream input = resource.getInputStream(); ! ClassType res = new ClassType(); ! registrar.register(className, res); ! new ClassFileInput(res, input); ! return res; ! } ! catch (IOException ex) { ! return null; ! } } *************** *** 88,94 **** /** where to find compiled packages. */ ! private final Object[] locations; ! /** Map from class names to types. Used to avoid loading several copies of the same class. */ --- 68,74 ---- /** where to find compiled packages. */ ! private final nice.tools.locator.Locator locator; ! /** Map from class names to types. Used to avoid loading several copies of the same class. */ *************** *** 99,140 **** public abstract void register(String className, ClassType type); } - - private static Object[] splitPath (String path) - { - LinkedList res = new LinkedList(); - - int start = 0; - // skip starting separators - while (start < path.length() && - path.charAt(start) == File.pathSeparatorChar) - start++; - - while(start < path.length()) - { - int end = path.indexOf(File.pathSeparatorChar, start); - if (end == -1) - end = path.length(); - - String pathComponent = path.substring(start, end); - if (pathComponent.length() > 0) - { - File f = nice.tools.util.System.getFile(pathComponent); - // Ignore non-existing directories and archives - if (f.exists()) - { - if (pathComponent.endsWith(".jar")) - try{ - res.add(new JarFile(f)); - } - catch(IOException e){} - else - res.add(f); - } - } - start = end + 1; - } - - return res.toArray(new Object[res.size()]); - } - } --- 79,81 ---- |
From: Daniel B. <bo...@us...> - 2004-07-02 19:31:13
|
Update of /cvsroot/nice/Nice/src/nice/tools/locator In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14796/src/nice/tools/locator Added Files: path.nice main.nice locator.nice Log Message: Abstracted the resource location in pathes in the nice.tools.locator package. --- NEW FILE: main.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package nice.tools.locator; import java.net.*; /** A locator finds resources based on given path. @author Daniel Bonniot (bo...@us...) */ public class Locator { final URL[] path; ?URLConnection get(String resource); toString() = this.getClass.getName + ": " Arrays.asList(path).toString(); } new Locator(String path, String->void warning) = this(path: parsePath(path, warning)); --- NEW FILE: locator.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package nice.tools.locator; /** Implementation of the locator. @author Daniel Bonniot (bo...@us...) */ get(Locator this, String resource) { for (URL base : this.path) { try { let url = new URL(base, resource); let connection = url.openConnection(); connection.connect(); return connection; } catch(java.io.IOException e) {} } return null; } --- NEW FILE: path.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package nice.tools.locator; /** Handle string representations of a path. @author Daniel Bonniot (bo...@us...) */ public URL[] parsePath(String path, String->void warning) { List<URL> components = new ArrayList(); int start = 0; // skip starting separators while (start < path.length() && path.charAt(start) == java.io.File.pathSeparatorChar) start++; while(start < path.length()) { int end = path.indexOf(java.io.File.pathSeparatorChar, start); if (end == -1) end = path.length(); String pathComponent = path.substring(start, end); if (pathComponent.length() > 0) try{ java.io.File f = nice.tools.util.System.getFile(pathComponent); if (f.canRead()) components.add(url(f.getCanonicalFile())); else { if (!f.exists()) warning("Path component "pathComponent" does not exist"); else warning("Path component "pathComponent" is not readable"); } } catch(java.net.MalformedURLException e){ warning("Path component "pathComponent" is invalid"); } catch(java.io.IOException e){ warning("Path component "pathComponent" is invalid"); } start = end + 1; } return components.toArray(); } URL url(java.io.File f) { String path = f.getPath(); if (path.endsWith(".jar")) return new URL("jar", "", "file:" path "!/"); else return f.toURL(); } |
From: Daniel B. <bo...@us...> - 2004-07-02 19:31:12
|
Update of /cvsroot/nice/Nice/src/nice/tools/unit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14796/src/nice/tools/unit Modified Files: api.nice Log Message: Abstracted the resource location in pathes in the nice.tools.locator package. Index: api.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/unit/api.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** api.nice 18 Feb 2004 16:33:25 -0000 1.1 --- api.nice 2 Jul 2004 19:31:01 -0000 1.2 *************** *** 1,4 **** --- 1,6 ---- package nice.tools.unit; + import nice.tools.locator; + import java.lang.reflect.*; *************** *** 94,135 **** ClassLoader classloaderFromClasspath(String classpath) { ! LinkedList<java.net.URL> components = new LinkedList(); ! ! int start = 0; ! // skip starting separators ! while (start<classpath.length() && ! classpath.charAt(start) == java.io.File.pathSeparatorChar) ! start++; ! ! while (start<classpath.length()) ! { ! int end = classpath.indexOf(java.io.File.pathSeparatorChar, start); ! if (end == -1) ! end = classpath.length(); ! ! String pathComponent = classpath.substring(start, end); ! if (pathComponent.length() > 0) ! try{ ! java.io.File f = new java.io.File(pathComponent); ! if (f.canRead()) ! components.add(f.getCanonicalFile().toURL()); ! else ! { ! if (!f.exists()) ! System.err.println("Classpath component " + pathComponent + " does not exist"); ! else ! System.err.println("Classpath component " + pathComponent + " is not readable"); ! } ! } ! catch(java.net.MalformedURLException e){ ! System.err.println("Classpath component " + pathComponent + " is invalid"); ! } ! catch(java.io.IOException e){ ! System.err.println("Classpath component " + pathComponent + " is invalid"); ! } ! start = end + 1; ! } ! return new java.net.URLClassLoader(components.toArray(), ! /* no parent */ null); } --- 96,102 ---- ClassLoader classloaderFromClasspath(String classpath) { ! java.net.URL[] path = parsePath(classpath, ! String message => System.err.println(message)); ! return new java.net.URLClassLoader(path, /* no parent */ null); } |
From: Daniel B. <bo...@us...> - 2004-07-02 16:57:16
|
Update of /cvsroot/nice/Nice/src/nice/tools/locator In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16896/src/nice/tools/locator Log Message: Directory /cvsroot/nice/Nice/src/nice/tools/locator added to the repository |
From: Daniel B. <bo...@us...> - 2004-07-02 16:17:44
|
Update of /cvsroot/nice/Nice/src/nice/tools/ant In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7677/src/nice/tools/ant Modified Files: Nicec.java NiceDoc.java Log Message: Specify the parser argument in the ant tasks. Index: Nicec.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/ant/Nicec.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Nicec.java 20 Feb 2004 02:51:58 -0000 1.21 --- Nicec.java 2 Jul 2004 16:17:35 -0000 1.22 *************** *** 291,295 **** NicecListener listener = new NicecListener(this); Compilation compilation = bossa.modules.fun.createCompilation ! (listener); if (sourcepath != null) compilation.sourcePath = sourcepath; --- 291,295 ---- NicecListener listener = new NicecListener(this); Compilation compilation = bossa.modules.fun.createCompilation ! (listener, new bossa.parser.JavaccParser(false)); if (sourcepath != null) compilation.sourcePath = sourcepath; Index: NiceDoc.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/ant/NiceDoc.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NiceDoc.java 20 Feb 2004 10:26:17 -0000 1.3 --- NiceDoc.java 2 Jul 2004 16:17:35 -0000 1.4 *************** *** 154,158 **** NicecListener listener = new NicecListener(this); ! Compilation compilation = bossa.modules.fun.createCompilation(listener); if (sourcepath != null) compilation.sourcePath = sourcepath; --- 154,159 ---- NicecListener listener = new NicecListener(this); ! Compilation compilation = bossa.modules.fun.createCompilation ! (listener, new bossa.parser.JavaccParser(true)); if (sourcepath != null) compilation.sourcePath = sourcepath; |
From: Daniel B. <bo...@us...> - 2004-07-02 15:25:24
|
Update of /cvsroot/nice/Nice In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26140 Modified Files: Makefile Log Message: Start the testsuite with more memory, as this saves a lot of time (~30%). Index: Makefile =================================================================== RCS file: /cvsroot/nice/Nice/Makefile,v retrieving revision 1.146 retrieving revision 1.147 diff -C2 -d -r1.146 -r1.147 *** Makefile 30 Jun 2004 16:11:31 -0000 1.146 --- Makefile 2 Jul 2004 15:25:15 -0000 1.147 *************** *** 104,109 **** cd regtest; JAVA="${java}" /usr/bin/time ./regtest ! check: ! /usr/bin/time ${java} -classpath "classes" nice.tools.testsuite.TestNice testsuite check_lib: --- 104,109 ---- cd regtest; JAVA="${java}" /usr/bin/time ./regtest ! check: ! /usr/bin/time ${java} -Xms64M -classpath "classes" nice.tools.testsuite.TestNice testsuite check_lib: |
From: Daniel B. <bo...@us...> - 2004-07-02 15:15:10
|
Update of /cvsroot/nice/Nice/testsuite/compiler/expressions/arrays In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23127/testsuite/compiler/expressions/arrays Modified Files: literal.testsuite Log Message: For literal arrays and tuples without a specified type, promote byte and short to int. Index: literal.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/expressions/arrays/literal.testsuite,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** literal.testsuite 11 Feb 2004 12:46:38 -0000 1.11 --- literal.testsuite 2 Jul 2004 15:14:58 -0000 1.12 *************** *** 3,7 **** /// PASS ! assert("[B".equals([1,2,3].getClass().getName())); /// PASS --- 3,7 ---- /// PASS ! assert("[I".equals([1,2,3].getClass().getName())); /// PASS |
From: Daniel B. <bo...@us...> - 2004-07-02 15:15:10
|
Update of /cvsroot/nice/Nice/src/nice/tools/code In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23127/src/nice/tools/code Modified Files: MultiArrayNewProc.java LiteralArrayProc.java Log Message: For literal arrays and tuples without a specified type, promote byte and short to int. Index: MultiArrayNewProc.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/code/MultiArrayNewProc.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MultiArrayNewProc.java 20 Feb 2003 00:21:44 -0000 1.5 --- MultiArrayNewProc.java 2 Jul 2004 15:14:58 -0000 1.6 *************** *** 51,55 **** args[i].compile(comp, Type.int_type); ! arrayType = creationType(arrayType, target); comp.getCode().emitNewArray(arrayType.getComponentType(), nbDimensions); --- 51,55 ---- args[i].compile(comp, Type.int_type); ! arrayType = creationType(arrayType, target, false); comp.getCode().emitNewArray(arrayType.getComponentType(), nbDimensions); *************** *** 59,75 **** /** Decide the bytecode type to create a new array with, given its computed type and the target. */ ! static ArrayType creationType(ArrayType computedType, Target target) { if (target.getType() instanceof ArrayType) { ArrayType targetType = (ArrayType) target.getType(); ! /* ! By well-typing, we know the target type is a super-type of the computed type. If the target has primitive components, we might as well ! use that type to produce better code, since subsumption would need copying otherwise. ! On the other hand, it would be incorrect (and useless) for reference types, in case the arrays comes back in the value of a function. --- 59,78 ---- /** Decide the bytecode type to create a new array with, given its computed type and the target. + + @param promote whether promotion of component types is desired. */ ! static ArrayType creationType(ArrayType computedType, Target target, ! boolean promote) { if (target.getType() instanceof ArrayType) { ArrayType targetType = (ArrayType) target.getType(); ! /* ! By well-typing, we know the target type is a super-type of the computed type. If the target has primitive components, we might as well ! use that type to produce better code, since subsumption would need copying otherwise. ! On the other hand, it would be incorrect (and useless) for reference types, in case the arrays comes back in the value of a function. *************** *** 78,82 **** return targetType; } ! return computedType; } --- 81,91 ---- return targetType; } ! ! if (promote) ! // We don't have information about the context. The sensible thing to do ! // is to promote primitive types (those smaller than int). ! return promoteComponent(computedType); ! else ! return computedType; } *************** *** 89,92 **** --- 98,126 ---- } + /** Recursively promote the component of the given array. */ + private static ArrayType promoteComponent(ArrayType array) + { + Type type = array.getComponentType(); + + // Is the type subject to promotion? + Type promoted; + + if (type == Type.byte_type || type == Type.short_type) + promoted = Type.int_type; + + // If not directly, is it an array whose component type is? + else if (type.isArray()) + promoted = promoteComponent((ArrayType) type); + + else + promoted = type; + + // If the component is changed, return a new array. + if (promoted != type) + return SpecialArray.create(promoted); + + return array; + } + public Type getReturnType(Expression[] args) { Index: LiteralArrayProc.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/code/LiteralArrayProc.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** LiteralArrayProc.java 21 Jun 2004 17:08:37 -0000 1.8 --- LiteralArrayProc.java 2 Jul 2004 15:14:59 -0000 1.9 *************** *** 42,49 **** private int nbElements; private boolean wrapAsCollection; ! public void compile (ApplyExp exp, Compilation comp, Target target) { ! arrayType = MultiArrayNewProc.creationType(arrayType, target); Expression[] args = exp.getArgs(); --- 42,50 ---- private int nbElements; private boolean wrapAsCollection; ! public void compile (ApplyExp exp, Compilation comp, Target target) { ! // The type was not specified explicitely, so we allow promotion. ! arrayType = MultiArrayNewProc.creationType(arrayType, target, true); Expression[] args = exp.getArgs(); |
From: Daniel B. <bo...@us...> - 2004-07-02 15:15:10
|
Update of /cvsroot/nice/Nice/testsuite/compiler/expressions/tuples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23127/testsuite/compiler/expressions/tuples Modified Files: compilation.testsuite Log Message: For literal arrays and tuples without a specified type, promote byte and short to int. Index: compilation.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/expressions/tuples/compilation.testsuite,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** compilation.testsuite 21 Jun 2004 17:08:26 -0000 1.9 --- compilation.testsuite 2 Jul 2004 15:14:58 -0000 1.10 *************** *** 48,53 **** (String fst, String snd) = foo("abc","xyz"); /// Toplevel ! <T,U> (T,U) foo(T x, U y) = (x,y); /// PASS (?int,?int) tup = (null, 3); --- 48,65 ---- (String fst, String snd) = foo("abc","xyz"); /// Toplevel ! <T,U> (T,U) foo(T x, U y) = (x,y); /// PASS (?int,?int) tup = (null, 3); + + /// PASS + List<(int,int)> l = new ArrayList(); + l.add((1,2)); + (int i1, int i2) = l.get(0); + assert i1 == 1 && i2 == 2; + + /// PASS bug + List<((int,int),String)> l = new ArrayList(); + l.add(((1,2), "")); + ((int i1, int i2), String s) = l.get(0); + assert i1 == 1 && i2 == 2; |
From: Daniel B. <bo...@us...> - 2004-07-02 12:12:29
|
Update of /cvsroot/nice/Nice/src/nice/tools/code In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11867/src/nice/tools/code Modified Files: Types.java TypeImport.java Log Message: Remember String=>Class mappings across compilations. Index: TypeImport.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/code/TypeImport.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TypeImport.java 1 Jul 2004 11:41:41 -0000 1.5 --- TypeImport.java 2 Jul 2004 12:12:20 -0000 1.6 *************** *** 131,138 **** return null; } ! ! static HashMap stringToReflectClass; ! ! /** Searches a native class given by its fully qualified name in the user classpath. --- 131,138 ---- return null; } ! ! static HashMap stringToReflectClass = new HashMap(); ! ! /** Searches a native class given by its fully qualified name in the user classpath. Index: Types.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/code/Types.java,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** Types.java 25 Feb 2004 11:23:28 -0000 1.57 --- Types.java 2 Jul 2004 12:12:20 -0000 1.58 *************** *** 644,648 **** { tcToGBType = new HashMap(); - TypeImport.stringToReflectClass = new HashMap(); Import.reset(); } --- 644,647 ---- |
From: Arjan B. <ar...@us...> - 2004-07-01 11:52:18
|
Update of /cvsroot/nice/Nice/src/bossa/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5463/F:/nice/src/bossa/util Modified Files: Location.java Log Message: Removed duplication in bossa.util.Location. Index: Location.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/util/Location.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** Location.java 29 Jun 2004 16:36:54 -0000 1.28 --- Location.java 1 Jul 2004 11:52:08 -0000 1.29 *************** *** 121,136 **** public java.io.File getFile() { return file; } - private static final String home = java.lang.System.getProperty("user.home"); - public String toString() { if (file == null) return ""; - - String name = file.toString(); - if (name != null && name.startsWith(home)) - return "~" + name.substring(home.length()); else ! return name; } --- 121,130 ---- public java.io.File getFile() { return file; } public String toString() { if (file == null) return ""; else ! return nice.tools.util.System.prettyPrint(file); } |
From: Arjan B. <ar...@us...> - 2004-07-01 11:41:57
|
Update of /cvsroot/nice/Nice/src/nice/tools/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2841/F:/nice/src/nice/tools/util Removed Files: ClassLoader.java Log Message: Moved nice.tools.util.Classloader to nice.tools.code. --- ClassLoader.java DELETED --- |
From: Arjan B. <ar...@us...> - 2004-07-01 11:41:57
|
Update of /cvsroot/nice/Nice/src/nice/tools/code In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2841/F:/nice/src/nice/tools/code Modified Files: TypeImport.java Added Files: ClassLoader.java Log Message: Moved nice.tools.util.Classloader to nice.tools.code. Index: TypeImport.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/code/TypeImport.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TypeImport.java 20 Mar 2003 23:01:50 -0000 1.4 --- TypeImport.java 1 Jul 2004 11:41:41 -0000 1.5 *************** *** 165,169 **** } ! private static ClassLoader classLoader; private static String currentClasspath = "NOT INITIALIZED"; --- 165,169 ---- } ! private static java.net.URLClassLoader classLoader; private static String currentClasspath = "NOT INITIALIZED"; --- NEW FILE: ClassLoader.java --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package nice.tools.code; import gnu.bytecode.*; import java.util.LinkedList; import java.util.Map; import java.util.jar.JarFile; import java.util.jar.JarEntry; import java.io.*; /** A ClassLoader located classes on its classpath and returns their representation as a gnu.bytecode.ClassType. @version $Date: 2004/07/01 11:41:41 $ @author Daniel Bonniot (bo...@us...) */ public class ClassLoader { public ClassLoader(String classpath, Registrar registrar) { this.registrar = registrar; this.locations = splitPath(classpath); } public ClassType load(String className) { String filesystemName = className.replace('.', File.separatorChar) + ".class"; String jarName = className.replace('.', '/') + ".class"; for (int i = 0; i < locations.length; i++) { InputStream input = null; if (locations[i] instanceof File) { File dir = (File) locations[i]; File file = new File(dir, filesystemName); try { input = new FileInputStream(file); } catch(FileNotFoundException ex) { } } else { JarFile jar = (JarFile) locations[i]; JarEntry e = jar.getJarEntry(jarName); if (e != null) try { input = jar.getInputStream(e); } catch(java.io.IOException ex) { } } if (input != null) { ClassType res = new ClassType(); registrar.register(className, res); try { new ClassFileInput(res, input); return res; } catch (IOException ex) { } } } return null; } /**************************************************************** * Private implementation ****************************************************************/ /** where to find compiled packages. */ private final Object[] locations; /** Map from class names to types. Used to avoid loading several copies of the same class. */ private final Registrar registrar; public abstract static class Registrar { public abstract void register(String className, ClassType type); } private static Object[] splitPath (String path) { LinkedList res = new LinkedList(); int start = 0; // skip starting separators while (start < path.length() && path.charAt(start) == File.pathSeparatorChar) start++; while(start < path.length()) { int end = path.indexOf(File.pathSeparatorChar, start); if (end == -1) end = path.length(); String pathComponent = path.substring(start, end); if (pathComponent.length() > 0) { File f = nice.tools.util.System.getFile(pathComponent); // Ignore non-existing directories and archives if (f.exists()) { if (pathComponent.endsWith(".jar")) try{ res.add(new JarFile(f)); } catch(IOException e){} else res.add(f); } } start = end + 1; } return res.toArray(new Object[res.size()]); } } |
From: Arjan B. <ar...@us...> - 2004-07-01 11:41:57
|
Update of /cvsroot/nice/Nice/src/gnu/bytecode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2841/F:/nice/src/gnu/bytecode Modified Files: Type.java Log Message: Moved nice.tools.util.Classloader to nice.tools.code. Index: Type.java =================================================================== RCS file: /cvsroot/nice/Nice/src/gnu/bytecode/Type.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Type.java 27 Nov 2003 01:24:53 -0000 1.18 --- Type.java 1 Jul 2004 11:41:41 -0000 1.19 *************** *** 101,110 **** } ! private static nice.tools.util.ClassLoader loader; static { String runtime = nice.tools.code.TypeImport.getRuntime(); ! loader = new nice.tools.util.ClassLoader (runtime, ! new nice.tools.util.ClassLoader.Registrar() { public void register(String name, ClassType type) { --- 101,110 ---- } ! private static nice.tools.code.ClassLoader loader; static { String runtime = nice.tools.code.TypeImport.getRuntime(); ! loader = new nice.tools.code.ClassLoader (runtime, ! new nice.tools.code.ClassLoader.Registrar() { public void register(String name, ClassType type) { |
From: Arjan B. <ar...@us...> - 2004-07-01 10:46:27
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24939/F:/nice/src/bossa/parser Modified Files: JavaccParser.java Parser.jj Log Message: Minor: reduced code duplication. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.246 retrieving revision 1.247 diff -C2 -d -r1.246 -r1.247 *** Parser.jj 29 Jun 2004 15:13:48 -0000 1.246 --- Parser.jj 1 Jul 2004 10:46:18 -0000 1.247 *************** *** 61,65 **** } ! private static Location makeLocation(Token t) { return Location.make(t.beginLine, t.beginColumn, t.endLine, t.endColumn); --- 61,65 ---- } ! static Location makeLocation(Token t) { return Location.make(t.beginLine, t.beginColumn, t.endLine, t.endColumn); Index: JavaccParser.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/JavaccParser.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** JavaccParser.java 30 Jun 2004 14:12:37 -0000 1.1 --- JavaccParser.java 1 Jul 2004 10:46:18 -0000 1.2 *************** *** 110,114 **** token = token.next; ! throw User.error(Location.make(token.beginLine, token.beginColumn), removeLocation(e.getMessage())); } --- 110,114 ---- token = token.next; ! throw User.error(Parser.makeLocation(token), removeLocation(e.getMessage())); } |
From: Daniel B. <bo...@us...> - 2004-06-30 16:11:41
|
Update of /cvsroot/nice/Nice In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24969 Modified Files: Makefile Log Message: Refer to much less specific classes in the bootstrap process. Index: Makefile =================================================================== RCS file: /cvsroot/nice/Nice/Makefile,v retrieving revision 1.145 retrieving revision 1.146 diff -C2 -d -r1.145 -r1.146 *** Makefile 30 Jun 2004 14:12:38 -0000 1.145 --- Makefile 30 Jun 2004 16:11:31 -0000 1.146 *************** *** 160,170 **** -cd src/bossa/syntax && mv -f dispatch.java.bootstrap dispatch.java ${JAVAC} \ stdlib/nice/lang/{Native,rawArray}.java \ src/bossa/modules/{Package,CompilationListener}.java \ ! src/bossa/util/*.java \ ! src/gnu/expr/*.java src/gnu/mapping/*.java \ ! src/nice/tools/{code/*.java,util/JDK.java} \ ! src/mlsub/typing/{*.java,lowlevel/*.java} \ ! src/bossa/syntax/dispatch.java $(JAVAC_GENERIC) -d classes-inline stdlib/nice/lang/inline/*.java cp -a classes-inline/* classes --- 160,167 ---- -cd src/bossa/syntax && mv -f dispatch.java.bootstrap dispatch.java ${JAVAC} \ + src/bossa/syntax/dispatch.java \ stdlib/nice/lang/{Native,rawArray}.java \ src/bossa/modules/{Package,CompilationListener}.java \ ! src/nice/tools/{code/*.java,util/JDK.java} $(JAVAC_GENERIC) -d classes-inline stdlib/nice/lang/inline/*.java cp -a classes-inline/* classes |
From: Daniel B. <bo...@us...> - 2004-06-30 14:13:15
|
Update of /cvsroot/nice/Nice/src/nice/tools/testsuite In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1421/src/nice/tools/testsuite Modified Files: TestCase.java Log Message: Defined a parser interface, and made the core independent of the implementation of the parser. This makes bootstrap and future modifications simpler. Index: TestCase.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/testsuite/TestCase.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** TestCase.java 20 Feb 2004 02:51:57 -0000 1.28 --- TestCase.java 30 Jun 2004 14:12:35 -0000 1.29 *************** *** 325,331 **** */ 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; --- 325,332 ---- */ 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, new bossa.parser.JavaccParser()); String tempDir = TestNice.getTempFolder().getAbsolutePath(); compilation.sourcePath = tempDir; |
From: Daniel B. <bo...@us...> - 2004-06-30 14:12:47
|
Update of /cvsroot/nice/Nice In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1421 Modified Files: Makefile Log Message: Defined a parser interface, and made the core independent of the implementation of the parser. This makes bootstrap and future modifications simpler. Index: Makefile =================================================================== RCS file: /cvsroot/nice/Nice/Makefile,v retrieving revision 1.144 retrieving revision 1.145 diff -C2 -d -r1.144 -r1.145 *** Makefile 26 Jun 2004 10:47:33 -0000 1.144 --- Makefile 30 Jun 2004 14:12:38 -0000 1.145 *************** *** 155,171 **** #**************************************************************** ! parser: src/bossa/parser/Parser.java ! src/bossa/parser/Parser.java: src/bossa/parser/Parser.jj ! cd src/bossa/parser; CLASSPATH=`TOP=${TOP} ${TOP}/external/javacc` \ ! ${java} javacc Parser.jj ! ! bootstrap: parser mkdir -p classes classes-inline ln -sf nicec bin/nicedoc; ln -sf nicec bin/niceunit -cd src/bossa/syntax && mv -f dispatch.java.bootstrap dispatch.java ${JAVAC} \ ! stdlib/nice/lang/Native.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,util/JDK.java} \ --- 155,166 ---- #**************************************************************** ! core-bootstrap: mkdir -p classes classes-inline ln -sf nicec bin/nicedoc; ln -sf nicec bin/niceunit -cd src/bossa/syntax && mv -f dispatch.java.bootstrap dispatch.java ${JAVAC} \ ! stdlib/nice/lang/{Native,rawArray}.java \ ! src/bossa/modules/{Package,CompilationListener}.java \ ! src/bossa/util/*.java \ src/gnu/expr/*.java src/gnu/mapping/*.java \ src/nice/tools/{code/*.java,util/JDK.java} \ *************** *** 186,191 **** rm classes/bossa/syntax/dispatch.class ${NICEC} -r bossa.syntax ! cd src;\ ! ${JAVAC} bossa/modules/Package.java ../stdlib/nice/lang/rawArray.java gnu/bytecode/dump.java ant: --- 181,191 ---- rm classes/bossa/syntax/dispatch.class ${NICEC} -r bossa.syntax ! ! src/bossa/parser/Parser.java: src/bossa/parser/Parser.jj ! cd src/bossa/parser; CLASSPATH=`TOP=${TOP} ${TOP}/external/javacc` \ ! ${java} javacc Parser.jj ! ! bootstrap: core-bootstrap src/bossa/parser/Parser.java ! ${JAVAC} src/bossa/parser/JavaccParser.java ant: *************** *** 222,225 **** --- 222,228 ---- cd src; ${JAVAC} bossa/modules/Package.java + parser: src/bossa/parser/Parser.java + ${JAVAC} src/bossa/parser/Parser.java + recompile: parser # ${JAVAC} -Xdepend src/bossa/modules/Package.java |
From: Daniel B. <bo...@us...> - 2004-06-30 14:12:47
|
Update of /cvsroot/nice/Nice/src/bossa/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1421/src/bossa/modules Modified Files: Package.java Content.java Compilation.nice Compilation.java Added Files: Parser.java Log Message: Defined a parser interface, and made the core independent of the implementation of the parser. This makes bootstrap and future modifications simpler. --- NEW FILE: Parser.java --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package bossa.modules; import java.io.*; import java.util.*; import bossa.syntax.LocatedString; /** The interface of a parser for the Nice language @author Daniel Bonniot (bo...@us...) */ public interface Parser { LocatedString readImports(Reader r, List imports, Collection opens); void read(Reader r, List definitions); bossa.syntax.FormalParameters formalParameters(String parameters); } Index: Compilation.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/Compilation.nice,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** Compilation.nice 18 Jan 2004 01:14:31 -0000 1.27 --- Compilation.nice 30 Jun 2004 14:12:38 -0000 1.28 *************** *** 46,51 **** boolean strictJavaTypes = false; - boolean storeDocStrings = false; - /** Location of the nice.jar file. */ ?String runtimeFile = null; --- 46,49 ---- *************** *** 55,58 **** --- 53,58 ---- CompilationListener listener; + Parser parser; + Map<String,Package> packages = new HashMap(); Map<String,mlsub.typing.TypeConstructor> javaTypeConstructors = new HashMap(); *************** *** 148,153 **** } ! Compilation createCompilation(CompilationListener listener) = ! new Compilation(listener: listener); class Exit extends RuntimeException {} --- 148,153 ---- } ! Compilation createCompilation(CompilationListener listener, Parser parser) = ! new Compilation(listener: listener, parser: parser); class Exit extends RuntimeException {} Index: Package.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/Package.java,v retrieving revision 1.116 retrieving revision 1.117 diff -C2 -d -r1.116 -r1.117 *** Package.java 11 Jun 2004 15:58:58 -0000 1.116 --- Package.java 30 Jun 2004 14:12:37 -0000 1.117 *************** *** 116,120 **** definitions = new ArrayList(); ! source.getDefinitions(definitions, shouldReload, compilation.storeDocStrings); this.ast = new AST(this, definitions); definitions = null; --- 116,120 ---- definitions = new ArrayList(); ! source.getDefinitions(definitions, shouldReload); this.ast = new AST(this, definitions); definitions = null; Index: Compilation.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/Compilation.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Compilation.java 18 Jan 2004 01:14:30 -0000 1.8 --- Compilation.java 30 Jun 2004 14:12:38 -0000 1.9 *************** *** 31,35 **** public boolean excludeRuntime; public boolean strictJavaTypes; ! public boolean storeDocStrings; public Locator locator; --- 31,35 ---- public boolean excludeRuntime; public boolean strictJavaTypes; ! public Parser parser; public Locator locator; Index: Content.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/Content.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Content.java 18 Jan 2004 01:14:31 -0000 1.14 --- Content.java 30 Jun 2004 14:12:37 -0000 1.15 *************** *** 74,78 **** } ! void getDefinitions(List definitions, boolean shouldReload, boolean storeDocStrings) { Content.Unit[] readers = getReaders(shouldReload); --- 74,78 ---- } ! void getDefinitions(List definitions, boolean shouldReload) { Content.Unit[] readers = getReaders(shouldReload); *************** *** 80,84 **** for(int i = 0; i<readers.length; i++) try{ ! read(readers[i], definitions, storeDocStrings); } catch(UserError ex){ --- 80,84 ---- for(int i = 0; i<readers.length; i++) try{ ! read(readers[i], definitions); } catch(UserError ex){ *************** *** 93,98 **** bossa.util.Location.setCurrentFile(unit.file); ! bossa.syntax.LocatedString pkgName = ! bossa.parser.Loader.readImports(unit.reader, imports, opens); if (pkgName != null && ! pkgName.equals(pkg.name)) User.error(pkgName, --- 93,99 ---- bossa.util.Location.setCurrentFile(unit.file); ! bossa.syntax.LocatedString pkgName = ! pkg.compilation.parser.readImports(unit.reader, imports, opens); ! if (pkgName != null && ! pkgName.equals(pkg.name)) User.error(pkgName, *************** *** 100,110 **** ", but it was found in package " + pkg.name); } ! ! private void read(Content.Unit unit, List definitions, boolean storeDocStrings) { bossa.util.Location.setCurrentFile(unit.file); ! bossa.parser.Loader.open(unit.reader, definitions, storeDocStrings); } ! /** @param shouldReload reload if the source if available. --- 101,111 ---- ", but it was found in package " + pkg.name); } ! ! private void read(Content.Unit unit, List definitions) { bossa.util.Location.setCurrentFile(unit.file); ! pkg.compilation.parser.read(unit.reader, definitions); } ! /** @param shouldReload reload if the source if available. |
From: Daniel B. <bo...@us...> - 2004-06-30 14:12:46
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1421/src/bossa/parser Added Files: JavaccParser.java Removed Files: Loader.java Log Message: Defined a parser interface, and made the core independent of the implementation of the parser. This makes bootstrap and future modifications simpler. --- Loader.java DELETED --- --- NEW FILE: JavaccParser.java --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package bossa.parser; import java.util.*; import java.io.*; import bossa.syntax.LocatedString; import bossa.syntax.FormalParameters; import bossa.util.*; import nice.tools.util.Chronometer; /** Nice parser using the JavaCC-generated parser. @author Daniel Bonniot */ public class JavaccParser implements bossa.modules.Parser { public final boolean storeDocStrings; public JavaccParser(boolean storeDocStrings) { this.storeDocStrings = storeDocStrings; } public JavaccParser() { this(false); } public LocatedString readImports(Reader r, List imports, Collection opens) { chrono.start(); try { Parser parser = new Parser(r); try{ return parser.readImports(imports, opens); } catch(ParseException e){ throw reportError(e); } } finally { chrono.stop(); } } public void read(Reader r, List definitions) { chrono.start(); try { Parser parser = new Parser(r); try{ parser.module(definitions, storeDocStrings); } catch(ParseException e){ throw reportError(e); } catch(TokenMgrError e) { String message = e.getMessage(); if (message.indexOf("<EOF>") != -1) message = "Unexpected end of file"; User.error(Location.nowhere(), message); } } finally { chrono.stop(); } } public FormalParameters formalParameters(String parameters) { try { return getParser(parameters).formalParameters(false, null); } catch(ParseException ex) { return null; } } private static Error reportError(ParseException e) { if(e.currentToken!=null) { Token token = e.currentToken; /* For errors generated by JavaCC, currentToken is the last successfull token, so we want to point to the next one. For errors handled by us for specific reporting, currentToken is the offending token (which was parsed), and there is no next. */ if (token.next != null) token = token.next; throw User.error(Location.make(token.beginLine, token.beginColumn), removeLocation(e.getMessage())); } else throw User.error(e.getMessage()); } private static Chronometer chrono = Chronometer.make("Parsing"); /** Remove the "at line L, column C." in the error message, since it is already in the location. */ private static String removeLocation(String message) { int start = message.indexOf(" at line "); if (start == -1) return message; int end = message.indexOf('.', start); return message.substring(0, start) + message.substring(end, message.length()); } private static Parser getParser(String toParse) { Reader r = new StringReader(toParse); Parser parser = new Parser(r); return parser; } } |
From: Daniel B. <bo...@us...> - 2004-06-30 14:12:46
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1421/src/bossa/syntax Modified Files: FormalParameters.java CustomConstructor.java Log Message: Defined a parser interface, and made the core independent of the implementation of the parser. This makes bootstrap and future modifications simpler. Index: FormalParameters.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/FormalParameters.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** FormalParameters.java 24 Jun 2004 08:11:10 -0000 1.40 --- FormalParameters.java 30 Jun 2004 14:12:37 -0000 1.41 *************** *** 560,564 **** } ! static FormalParameters readBytecodeAttribute(gnu.bytecode.MiscAttr attr) { String value = new String(attr.data); --- 560,565 ---- } ! static FormalParameters readBytecodeAttribute(gnu.bytecode.MiscAttr attr, ! bossa.modules.Parser parser) { String value = new String(attr.data); *************** *** 568,581 **** "\" from " + attr.getContainer()); ! try { ! return ! bossa.parser.Loader.getParser(value).formalParameters(false, null); ! } ! catch (bossa.parser.ParseException ex) { throw Internal.error ("Could not parse '" + attr.getName() + "' bytecode attribute:\n" + "In method: " + attr.getContainer() + "\n" + "Value : " + value); ! } } --- 569,581 ---- "\" from " + attr.getContainer()); ! FormalParameters res = parser.formalParameters(value); ! ! if (res == null) throw Internal.error ("Could not parse '" + attr.getName() + "' bytecode attribute:\n" + "In method: " + attr.getContainer() + "\n" + "Value : " + value); ! ! return res; } Index: CustomConstructor.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/CustomConstructor.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** CustomConstructor.java 28 Feb 2004 14:23:43 -0000 1.14 --- CustomConstructor.java 30 Jun 2004 14:12:37 -0000 1.15 *************** *** 268,272 **** ImportedCustomConstructor(NiceClass def, Method method, MiscAttr attr) { ! super(def, FormalParameters.readBytecodeAttribute(attr)); this.method = method; TypeConstructors.addConstructor(classe.definition.tc, this); --- 268,273 ---- ImportedCustomConstructor(NiceClass def, Method method, MiscAttr attr) { ! super(def, FormalParameters.readBytecodeAttribute ! (attr, JavaClasses.compilation.parser)); this.method = method; TypeConstructors.addConstructor(classe.definition.tc, this); |
From: Daniel B. <bo...@us...> - 2004-06-30 14:12:45
|
Update of /cvsroot/nice/Nice/src/nice/tools/compiler/console In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1421/src/nice/tools/compiler/console Modified Files: main.nice Log Message: Defined a parser interface, and made the core independent of the implementation of the parser. This makes bootstrap and future modifications simpler. Index: main.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/compiler/console/main.nice,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** main.nice 31 Dec 2003 22:36:59 -0000 1.7 --- main.nice 30 Jun 2004 14:12:36 -0000 1.8 *************** *** 50,54 **** ConsoleOutput consOutput = new ConsoleOutput(); ! Compilation compilation = new Compilation(listener: consOutput); Program prg = new Program --- 50,55 ---- ConsoleOutput consOutput = new ConsoleOutput(); ! Compilation compilation = new Compilation ! (listener: consOutput, parser: new bossa.parser.JavaccParser()); Program prg = new Program |
From: Daniel B. <bo...@us...> - 2004-06-30 14:12:45
|
Update of /cvsroot/nice/Nice/src/nice/tools/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1421/src/nice/tools/doc Modified Files: main.nice Log Message: Defined a parser interface, and made the core independent of the implementation of the parser. This makes bootstrap and future modifications simpler. Index: main.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/doc/main.nice,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** main.nice 25 Apr 2004 16:19:01 -0000 1.6 --- main.nice 30 Jun 2004 14:12:36 -0000 1.7 *************** *** 18,23 **** ConsoleOutput consOutput = new ConsoleOutput(); ! Compilation compilation = new Compilation(listener: consOutput); ! compilation.storeDocStrings = true; Program prg = new Program --- 18,23 ---- ConsoleOutput consOutput = new ConsoleOutput(); ! Compilation compilation = new Compilation ! (listener: consOutput, parser: new bossa.parser.JavaccParser(true)); Program prg = new Program *************** *** 77,79 **** generate(compilation, mainPackage, outdir); ! } \ No newline at end of file --- 77,79 ---- generate(compilation, mainPackage, outdir); ! } |