diff options
author | paltherr <paltherr@epfl.ch> | 2004-03-09 16:40:09 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2004-03-09 16:40:09 +0000 |
commit | 07c291484e749b7c9ee64ccaf45860bab62e3e65 (patch) | |
tree | 3307afa64e85e54ba0492c71003d2b00116d61b2 /sources/scalac/symtab | |
parent | 829ff49f1cff21b98e2b9cd55ea5c5d3c7d4b4b3 (diff) | |
download | scala-07c291484e749b7c9ee64ccaf45860bab62e3e65.tar.gz scala-07c291484e749b7c9ee64ccaf45860bab62e3e65.tar.bz2 scala-07c291484e749b7c9ee64ccaf45860bab62e3e65.zip |
- Replaced MetadataParser superclass by SymbolL...
- Replaced MetadataParser superclass by SymbolLoader Removed usage
- of staticsParsers (no more needed with SymbolLoader) Simplified
- Analyzer.lateEnter (code no more needed with SymbolLoader) Moved some
- code from SourceCompleter into Analyzer.loadMixinCode Simplified
- parsers (code no more needed with SymbolLoader)
Diffstat (limited to 'sources/scalac/symtab')
-rw-r--r-- | sources/scalac/symtab/SourceCompleter.java | 51 | ||||
-rw-r--r-- | sources/scalac/symtab/classfile/CLRClassParser.java | 17 | ||||
-rw-r--r-- | sources/scalac/symtab/classfile/CLRPackageParser.java | 4 | ||||
-rw-r--r-- | sources/scalac/symtab/classfile/ClassParser.java | 30 | ||||
-rw-r--r-- | sources/scalac/symtab/classfile/PackageParser.java | 16 | ||||
-rw-r--r-- | sources/scalac/symtab/classfile/SymblParser.java | 30 |
6 files changed, 39 insertions, 109 deletions
diff --git a/sources/scalac/symtab/SourceCompleter.java b/sources/scalac/symtab/SourceCompleter.java index be1b4b7bbb..acacb8a337 100644 --- a/sources/scalac/symtab/SourceCompleter.java +++ b/sources/scalac/symtab/SourceCompleter.java @@ -17,55 +17,32 @@ import scalac.util.SourceRepresentation; import java.io.*; -public class SourceCompleter extends Type.LazyType { +public class SourceCompleter extends SymbolLoader { - /** the global compilation environment - */ - protected final Global global; private final boolean mixinOnly; - private boolean completed = false; - public SourceCompleter(Global global) { this(global, false); } public SourceCompleter(Global global, boolean mixinOnly) { - this.global = global; + super(global); this.mixinOnly = mixinOnly; } /** complete class symbol c by loading the unit */ - public void complete(Symbol c) { - if (completed) { - c.setInfo(Type.NoType); - } else { - try { - long msec = System.currentTimeMillis(); - String filename = SourceRepresentation.externalizeFileName( - c.isConstructor() ? c.constructorClass() : - c.isModule() ? c.moduleClass() : - c, ".scala"); - java.io.File f = global.classPath.openJavaFile(filename); - Unit unit = new Unit(global, new SourceFile(f), false, mixinOnly); - Phase phase = global.currentPhase; - global.currentPhase = global.PHASE.PARSER.phase(); - global.PHASE.PARSER.phase().apply(new Unit[] {unit}); - global.currentPhase = global.PHASE.ANALYZER.phase(); - ((AnalyzerPhase)global.PHASE.ANALYZER.phase()).lateEnter(global, unit, c); - global.currentPhase = phase; - global.operation("added " + filename + " in " + - (System.currentTimeMillis() - msec) + "ms"); - } catch (IOException e) { - if (global.debug) e.printStackTrace(); - if (mixinOnly) - global.error("source file for " + c + " not found; it is needed because class is used as a mixin"); - else - global.error("i/o error while loading " + c + ": " + e); - c.setInfo(Type.ErrorType); - } - completed = true; - } + public String doComplete(Symbol clasz) throws IOException { + File file = global.classPath.openJavaFile( + SourceRepresentation.externalizeFileName(clasz, ".scala")); + Unit unit = new Unit(global, new SourceFile(file), false, mixinOnly); + Phase phase = global.currentPhase; + global.currentPhase = global.PHASE.PARSER.phase(); + global.PHASE.PARSER.phase().apply(new Unit[] {unit}); + global.currentPhase = global.PHASE.ANALYZER.phase(); + ((AnalyzerPhase)global.PHASE.ANALYZER.phase()).lateEnter(global, unit, clasz); + global.currentPhase = phase; + return "source file '" + file + "'"; } + } diff --git a/sources/scalac/symtab/classfile/CLRClassParser.java b/sources/scalac/symtab/classfile/CLRClassParser.java index 5dcb3c1769..5432b55b59 100644 --- a/sources/scalac/symtab/classfile/CLRClassParser.java +++ b/sources/scalac/symtab/classfile/CLRClassParser.java @@ -38,20 +38,19 @@ public class CLRClassParser extends ClassParser { this.importer = importer; } - protected void doComplete(Symbol clazz) { - try { doComplete0(clazz); } + protected String doComplete(Symbol clazz) { + try { return doComplete0(clazz); } catch (Throwable e) { System.err.println("\nWhile processing " + Debug.show(clazz)); e.printStackTrace(); System.exit(1); + return null; // !!! } } - protected void doComplete0(Symbol clazz) { + protected String doComplete0(Symbol clazz) { clazz.owner().initialize(); //??? - long msec = System.currentTimeMillis(); - if (make == null) make = new JavaTypeCreator(global.definitions); @@ -100,8 +99,8 @@ public class CLRClassParser extends ClassParser { AliasTypeSymbol alias = new AliasTypeSymbol(Position.NOPOS, aliasname, clazz.module(), translateAttributes(ntype)); - nclazz.allConstructors().setInfo(staticsParser(nclazz)); - nclazz.module().setInfo(staticsParser(nclazz)); + nclazz.allConstructors().setInfo(this); + nclazz.module().setInfo(this); // alias.setInfo(scalac.symtab.Type .typeRef(clazz.owner().thisType(), @@ -233,9 +232,7 @@ public class CLRClassParser extends ClassParser { constr.flags |= Modifiers.PRIVATE; } - global.operation("loaded class " + Debug.show(clazz) + - " from [" + type.Assembly.GetName().Name + "]" + type + - " in " + (System.currentTimeMillis() - msec) + "ms"); + return "assembly [" + type.Assembly.GetName().Name + "]" + type; } /** Return a method type for */ diff --git a/sources/scalac/symtab/classfile/CLRPackageParser.java b/sources/scalac/symtab/classfile/CLRPackageParser.java index b5c5e10696..6a992b0d8a 100644 --- a/sources/scalac/symtab/classfile/CLRPackageParser.java +++ b/sources/scalac/symtab/classfile/CLRPackageParser.java @@ -259,8 +259,8 @@ public class CLRPackageParser extends MetadataParser { if (k < 0) { // it's a class ClassSymbol clazz = new ClassSymbol(n.toTypeName(), p, completer); - clazz.allConstructors().setInfo(completer.staticsParser(clazz)); - clazz.module().setInfo(completer.staticsParser(clazz)); + clazz.allConstructors().setInfo(completer); + clazz.module().setInfo(completer); members.enter(clazz); Scope.Entry e = members.lookupEntry(clazz.module().name); if (e != Scope.Entry.NONE) diff --git a/sources/scalac/symtab/classfile/ClassParser.java b/sources/scalac/symtab/classfile/ClassParser.java index ac964511c8..882b4b2690 100644 --- a/sources/scalac/symtab/classfile/ClassParser.java +++ b/sources/scalac/symtab/classfile/ClassParser.java @@ -14,35 +14,17 @@ import scalac.util.*; import java.io.*; -public class ClassParser extends MetadataParser { +public class ClassParser extends SymbolLoader { public ClassParser(Global global) { super(global); } - protected void doComplete(Symbol c) { - c.owner().initialize(); - //System.out.println("loading " + c);//DEBUG - try { - long msec = System.currentTimeMillis(); - String filename = SourceRepresentation.externalizeFileName( - c, ".class"); - AbstractFile f = global.classPath.openFile(filename); - if (f == null) - global.error("could not read class " + c); - else { - new ClassfileParser(global, new AbstractFileReader(f), c).parse(); - global.operation("loaded " + f.getPath() + " in " + - (System.currentTimeMillis() - msec) + "ms"); - //for (Definition e = c.locals().elems; e != null; e = e.sibling) - // if (e.def.kind == TYP) - // e.def.complete(); - } - } catch (IOException e) { - if (global.debug) e.printStackTrace(); - global.error("i/o error while loading " + c); - c.setInfo(Type.ErrorType); - } + protected String doComplete(Symbol clasz) throws IOException { + AbstractFile file = global.classPath.openFile( + SourceRepresentation.externalizeFileName(clasz, ".class")); + new ClassfileParser(global,new AbstractFileReader(file),clasz).parse(); + return "class file '" + file.getPath() + "'"; } public Type.LazyType staticsParser(Symbol clazz) { diff --git a/sources/scalac/symtab/classfile/PackageParser.java b/sources/scalac/symtab/classfile/PackageParser.java index c3f4879af0..00e4ae1da9 100644 --- a/sources/scalac/symtab/classfile/PackageParser.java +++ b/sources/scalac/symtab/classfile/PackageParser.java @@ -15,7 +15,7 @@ import scalac.util.*; import java.io.*; import java.util.HashMap; -public class PackageParser extends MetadataParser { +public class PackageParser extends SymbolLoader { /** the class parser */ @@ -36,8 +36,7 @@ public class PackageParser extends MetadataParser { /** complete package type symbol p by loading all package members */ - protected void doComplete(Symbol p) { - long msec = System.currentTimeMillis(); + protected String doComplete(Symbol p) { Scope members = new Scope(); String dirname = null; HashMap/*<Symbol, AbstractFile>*/ symFile = new HashMap(); @@ -53,10 +52,7 @@ public class PackageParser extends MetadataParser { if (global.target == global.TARGET_MSIL) importer.importCLRTypes(p, members, this); p.setInfo(Type.compoundType(Type.EMPTY_ARRAY, members, p)); - if (dirname == null) - dirname = "anonymous package"; - global.operation("scanned " + dirname + " in " + - (System.currentTimeMillis() - msec) + "ms"); + return dirname == null ? "anonymous package" : "package '"+dirname+"'"; } private boolean isMostRecent(AbstractFile f, Symbol previous, HashMap symFile) { @@ -95,10 +91,8 @@ public class PackageParser extends MetadataParser { if (isMostRecent(f, locals.lookup(n), symFile)) { ClassSymbol clazz = new ClassSymbol(n, p, classCompletion); // todo: needed? - clazz.allConstructors().setInfo( - classCompletion.staticsParser(clazz)); - clazz.module().setInfo( - classCompletion.staticsParser(clazz)); + clazz.allConstructors().setInfo(classCompletion); + clazz.module().setInfo(classCompletion); // enter class locals.enter(clazz); // enter module diff --git a/sources/scalac/symtab/classfile/SymblParser.java b/sources/scalac/symtab/classfile/SymblParser.java index e5db5ee61c..108e7b3af6 100644 --- a/sources/scalac/symtab/classfile/SymblParser.java +++ b/sources/scalac/symtab/classfile/SymblParser.java @@ -22,30 +22,10 @@ public class SymblParser extends ClassParser { /** complete class symbol c by loading the class */ - public void doComplete(Symbol c) { - //System.out.println("loading " + c);//DEBUG - try { - long msec = System.currentTimeMillis(); - String filename = SourceRepresentation.externalizeFileName( - c, ".symbl"); - AbstractFile f = global.classPath.openFile(filename); - if (f == null) - global.error("could not read class " + c); - else { - byte[] data = f.read(); - new UnPickle(c, data, Name.fromString(filename)); - global.operation("loaded " + f.getPath() + " in " + - (System.currentTimeMillis() - msec) + "ms"); - /* - if (!global.separate) - new SourceCompleter(global).complete(c);//for now - */ - } - } catch (IOException e) { - if (global.debug) e.printStackTrace(); - global.error("i/o error while loading " + c); - c.setInfo(Type.ErrorType); - } + public String doComplete(Symbol clasz) throws IOException { + AbstractFile file = global.classPath.openFile( + SourceRepresentation.externalizeFileName(clasz, ".symbl")); + new UnPickle(clasz, file.read(), Name.fromString(file.getPath())); + return "symbol file '" + file.getPath() + "'"; } } - |