summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2004-03-21 17:48:43 +0000
committerpaltherr <paltherr@epfl.ch>2004-03-21 17:48:43 +0000
commit430c5dbe56f5826a2b26a386e4f1f55d3bc835b7 (patch)
tree153fbe83f79b849557994bff017ea9be68776c2b
parent61bf0c8f1d9ffb90f0fa543f5f654a08bfc365e0 (diff)
downloadscala-430c5dbe56f5826a2b26a386e4f1f55d3bc835b7.tar.gz
scala-430c5dbe56f5826a2b26a386e4f1f55d3bc835b7.tar.bz2
scala-430c5dbe56f5826a2b26a386e4f1f55d3bc835b7.zip
- Avoided recomputations of files that are alre...
- Avoided recomputations of files that are already done in PackageParser
-rw-r--r--sources/scalac/Global.java8
-rw-r--r--sources/scalac/symtab/SourceCompleter.java39
-rw-r--r--sources/scalac/symtab/classfile/ClassParser.java37
-rw-r--r--sources/scalac/symtab/classfile/ClassfileParser.java4
-rw-r--r--sources/scalac/symtab/classfile/PackageParser.java11
-rw-r--r--sources/scalac/symtab/classfile/SymblParser.java39
6 files changed, 90 insertions, 48 deletions
diff --git a/sources/scalac/Global.java b/sources/scalac/Global.java
index 5d21cedff6..1807f45b2c 100644
--- a/sources/scalac/Global.java
+++ b/sources/scalac/Global.java
@@ -375,9 +375,11 @@ public abstract class Global {
}
if (reporter.errors() != 0) {
imports.clear();
- for (Iterator it = compiledNow.keySet().iterator(); it.hasNext();) {
- Symbol sym = (Symbol) it.next();
- sym.reset(new SourceCompleter(this));
+ for (Iterator i = compiledNow.entrySet().iterator(); i.hasNext();) {
+ Map.Entry entry = (Map.Entry)i.next();
+ Symbol clasz = (Symbol)entry.getKey();
+ AbstractFile file = ((SourceFile)entry.getValue()).getFile();
+ clasz.reset(new SourceCompleter(this, file));
}
}
symdata.clear();
diff --git a/sources/scalac/symtab/SourceCompleter.java b/sources/scalac/symtab/SourceCompleter.java
index b9456a4b10..fa6157ea14 100644
--- a/sources/scalac/symtab/SourceCompleter.java
+++ b/sources/scalac/symtab/SourceCompleter.java
@@ -8,28 +8,39 @@
package scalac.symtab;
-import scala.tools.util.AbstractFile;
-import scala.tools.util.SourceFile;
+import java.io.IOException;
-import scalac.*;
-import scalac.ast.parser.*;
-import scalac.typechecker.AnalyzerPhase;
-import scalac.util.SourceRepresentation;
-import java.io.*;
+import scala.tools.util.AbstractFile;
+import scalac.Global;
+import scalac.symtab.Symbol;
+/** This class implements a SymbolLoader that reads a source file. */
public class SourceCompleter extends SymbolLoader {
- public SourceCompleter(Global global) {
+ //########################################################################
+ // Private Fields
+
+ /** The source file to read */
+ private final AbstractFile file;
+
+ //########################################################################
+ // Public Constructors
+
+ /** Initializes this instance with the specified source file. */
+ public SourceCompleter(Global global, AbstractFile file) {
super(global);
+ this.file = file;
}
- /** complete class symbol c by loading the unit
- */
- public String doComplete(Symbol clasz) throws IOException {
- SourceFile source = global.getSourceFile(clasz);
- global.compileLate(source, false);
- return "source file '" + source + "'";
+ //########################################################################
+ // Protected Methods
+
+ /** Completes the specified symbol by reading the source file. */
+ protected String doComplete(Symbol clasz) throws IOException {
+ global.compileLate(global.getSourceFile(file), false);
+ return "source file '" + file + "'";
}
+ //########################################################################
}
diff --git a/sources/scalac/symtab/classfile/ClassParser.java b/sources/scalac/symtab/classfile/ClassParser.java
index 4aba202cff..f920a5ef79 100644
--- a/sources/scalac/symtab/classfile/ClassParser.java
+++ b/sources/scalac/symtab/classfile/ClassParser.java
@@ -2,31 +2,46 @@
** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
** /_____/\____/\___/\____/____/ **
-** **
-** $Id$
\* */
+// $Id$
+
package scalac.symtab.classfile;
+import java.io.IOException;
+
import scala.tools.util.AbstractFile;
-import scalac.*;
-import scalac.symtab.*;
-import scalac.util.*;
-import java.io.*;
+import scalac.Global;
+import scalac.symtab.Symbol;
+import scalac.symtab.SymbolLoader;
+/** This class implements a SymbolLoader that reads a class file. */
public class ClassParser extends SymbolLoader {
- public ClassParser(Global global) {
+ //########################################################################
+ // Private Fields
+
+ /** The class file to read */
+ private final AbstractFile file;
+
+ //########################################################################
+ // Public Constructors
+
+ /** Initializes this instance with the specified class file. */
+ public ClassParser(Global global, AbstractFile file) {
super(global);
+ this.file = file;
}
+ //########################################################################
+ // Protected Methods
+
+ /** Completes the specified symbol by reading the class file. */
protected String doComplete(Symbol clasz) throws IOException {
- AbstractFile file = global.classPath.openFile(
- SourceRepresentation.externalizeFileName(clasz, ".class"));
- ClassfileParser.parse(global, new AbstractFileReader(file), clasz);
+ ClassfileParser.parse(global, file, clasz);
return "class file '" + file + "'";
}
+ //########################################################################
}
-
diff --git a/sources/scalac/symtab/classfile/ClassfileParser.java b/sources/scalac/symtab/classfile/ClassfileParser.java
index 795d8e9584..eb269455e2 100644
--- a/sources/scalac/symtab/classfile/ClassfileParser.java
+++ b/sources/scalac/symtab/classfile/ClassfileParser.java
@@ -8,6 +8,7 @@
package scalac.symtab.classfile;
+import scala.tools.util.AbstractFile;
import scala.tools.util.Position;
import scalac.*;
import scalac.util.*;
@@ -67,7 +68,8 @@ public class ClassfileParser implements ClassfileConstants {
/** parse the classfile and throw IO exception if there is an
* error in the classfile structure
*/
- public static void parse(Global global, AbstractFileReader in, Symbol c) throws IOException {
+ public static void parse(Global global, AbstractFile file, Symbol c) throws IOException {
+ AbstractFileReader in = new AbstractFileReader(file);
try {
int magic = in.nextInt();
if (magic != JAVA_MAGIC)
diff --git a/sources/scalac/symtab/classfile/PackageParser.java b/sources/scalac/symtab/classfile/PackageParser.java
index 93d17fb381..374c977c38 100644
--- a/sources/scalac/symtab/classfile/PackageParser.java
+++ b/sources/scalac/symtab/classfile/PackageParser.java
@@ -34,9 +34,6 @@ public class PackageParser extends SymbolLoader {
//########################################################################
// Private Fields
- /** The JVM class file parser */
- private final ClassParser classCompletion;
-
/** The CLR package parser */
private final CLRPackageParser importer;
@@ -46,7 +43,6 @@ public class PackageParser extends SymbolLoader {
/** Initializes this instance. */
public PackageParser(Global global) {
super(global);
- this.classCompletion = new ClassParser(global);
this.importer = (global.target == global.TARGET_MSIL)
? CLRPackageParser.create(global) : null;
}
@@ -112,8 +108,8 @@ public class PackageParser extends SymbolLoader {
}
packages.remove(name);
Name classname = Name.fromString(name).toTypeName();
- SourceCompleter completer = new SourceCompleter(global);
- peckage.newLoadedClass(0, classname, completer, members);
+ SymbolLoader loader = new SourceCompleter(global, sfile);
+ peckage.newLoadedClass(0, classname, loader, members);
}
for (Iterator i = classes.entrySet().iterator(); i.hasNext(); ) {
HashMap.Entry entry = (HashMap.Entry)i.next();
@@ -121,7 +117,8 @@ public class PackageParser extends SymbolLoader {
AbstractFile cfile = (AbstractFile)entry.getValue();
packages.remove(name);
Name classname = Name.fromString(name).toTypeName();
- peckage.newLoadedClass(JAVA, classname, classCompletion, members);
+ SymbolLoader loader = new ClassParser(global, cfile);
+ peckage.newLoadedClass(JAVA, classname, loader, members);
}
for (Iterator i = packages.iterator(); i.hasNext(); ) {
String name = (String)i.next();
diff --git a/sources/scalac/symtab/classfile/SymblParser.java b/sources/scalac/symtab/classfile/SymblParser.java
index ae0dc4f5d8..56873215e8 100644
--- a/sources/scalac/symtab/classfile/SymblParser.java
+++ b/sources/scalac/symtab/classfile/SymblParser.java
@@ -2,31 +2,46 @@
** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
** /_____/\____/\___/\____/____/ **
-** **
-** $Id$
\* */
+// $Id$
+
package scalac.symtab.classfile;
+import java.io.IOException;
+
import scala.tools.util.AbstractFile;
-import scalac.*;
-import scalac.symtab.*;
-import scalac.util.*;
-import java.io.*;
+import scalac.Global;
+import scalac.symtab.Symbol;
+import scalac.symtab.SymbolLoader;
+
+/** This class implements a SymbolLoader that reads a symbol file. */
+public class SymblParser extends SymbolLoader {
+
+ //########################################################################
+ // Private Fields
-public class SymblParser extends ClassParser {
+ /** The symbol file to read */
+ private final AbstractFile file;
- public SymblParser(Global global) {
+ //########################################################################
+ // Public Constructors
+
+ /** Initializes this instance with the specified symbol file. */
+ public SymblParser(Global global, AbstractFile file) {
super(global);
+ this.file = file;
}
- /** complete class symbol c by loading the class
- */
+ //########################################################################
+ // Protected Methods
+
+ /** Completes the specified symbol by reading the symbol file. */
public String doComplete(Symbol clasz) throws IOException {
- AbstractFile file = global.classPath.openFile(
- SourceRepresentation.externalizeFileName(clasz, ".symbl"));
UnPickle.parse(global, file, clasz);
return "symbol file '" + file + "'";
}
+
+ //########################################################################
}