summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormihaylov <mihaylov@epfl.ch>2003-12-08 10:30:49 +0000
committermihaylov <mihaylov@epfl.ch>2003-12-08 10:30:49 +0000
commit4931ca305940a728c5d632aba9f2a3a84c397acf (patch)
tree04b7f0d1c440bab6ee71d23de3fae6fd14ec7d84
parent17b8ac4bf4ed723c1606a6b3419870fd3acfe1bb (diff)
downloadscala-4931ca305940a728c5d632aba9f2a3a84c397acf.tar.gz
scala-4931ca305940a728c5d632aba9f2a3a84c397acf.tar.bz2
scala-4931ca305940a728c5d632aba9f2a3a84c397acf.zip
- added common superclass (MetadataParser) for ...
- added common superclass (MetadataParser) for PackageParser and ClassParser that handles switching and restoring the compiler phase
-rw-r--r--config/list/compiler.lst3
-rw-r--r--sources/scalac/symtab/classfile/ClassParser.java16
-rw-r--r--sources/scalac/symtab/classfile/MetadataParser.java42
-rw-r--r--sources/scalac/symtab/classfile/PackageParser.java21
-rw-r--r--sources/scalac/symtab/classfile/SymblParser.java9
5 files changed, 61 insertions, 30 deletions
diff --git a/config/list/compiler.lst b/config/list/compiler.lst
index 4582983ab5..5a7404d4ce 100644
--- a/config/list/compiler.lst
+++ b/config/list/compiler.lst
@@ -75,12 +75,15 @@ checkers/CheckTypes.java
checkers/Checker.java
symtab/classfile/AttributeParser.java
+symtab/classfile/CLRPackageParser.java
+symtab/classfile/CLRClassParser.java
symtab/classfile/ClassParser.java
symtab/classfile/ClassfileConstants.java
symtab/classfile/ClassfileParser.java
symtab/classfile/ConstantPool.java
symtab/classfile/JavaTypeCreator.java
symtab/classfile/JavaTypeFactory.java
+symtab/classfile/MetadataParser.java
symtab/classfile/PackageParser.java
symtab/classfile/Signatures.java
symtab/classfile/SymblParser.java
diff --git a/sources/scalac/symtab/classfile/ClassParser.java b/sources/scalac/symtab/classfile/ClassParser.java
index 82c75a59f9..b6ee8eb3b2 100644
--- a/sources/scalac/symtab/classfile/ClassParser.java
+++ b/sources/scalac/symtab/classfile/ClassParser.java
@@ -14,22 +14,13 @@ import scalac.util.*;
import java.io.*;
-public class ClassParser extends Type.LazyType {
-
- /** the global compilation environment
- */
- protected Global global;
- protected boolean completed = false;
+public class ClassParser extends MetadataParser {
public ClassParser(Global global) {
- this.global = global;
+ super(global);
}
- /** complete class symbol c by loading the class
- */
- public void complete(Symbol c) {
- Phase phase = global.currentPhase;
- global.currentPhase = global.getFirstPhase();
+ protected void doComplete(Symbol c) {
c.owner().initialize();
//System.out.println("loading " + c);//DEBUG
try {
@@ -52,7 +43,6 @@ public class ClassParser extends Type.LazyType {
global.error("i/o error while loading " + c);
c.setInfo(Type.ErrorType);
}
- global.currentPhase = phase;
}
public Type.LazyType staticsParser(Symbol clazz) {
diff --git a/sources/scalac/symtab/classfile/MetadataParser.java b/sources/scalac/symtab/classfile/MetadataParser.java
new file mode 100644
index 0000000000..7ea907c6f3
--- /dev/null
+++ b/sources/scalac/symtab/classfile/MetadataParser.java
@@ -0,0 +1,42 @@
+/* ____ ____ ____ ____ ______ *\
+** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
+** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
+** /_____/\____/\___/\____/____/ **
+** **
+** $Id$
+\* */
+
+package scalac.symtab.classfile;
+
+import scalac.Global;
+import scalac.Phase;
+import scalac.symtab.Symbol;
+import scalac.symtab.Type;
+
+/** Common superclass for all metadata parsers that load symbols
+ * in the context of the first phase of the compiler.
+ */
+public abstract class MetadataParser extends Type.LazyType {
+
+ /** the global compilation environment
+ */
+ protected Global global;
+
+ public MetadataParser(Global global) {
+ this.global = global;
+ }
+
+ /** Complete symbol 'sym' by loading the members of the symbol.
+ */
+ public final void complete(Symbol sym) {
+ Phase phase = global.currentPhase;
+ global.currentPhase = global.getFirstPhase();
+ doComplete(sym);
+ global.currentPhase = phase;
+ }
+
+ /** Perform the actual loading of the symbol.
+ */
+ protected abstract void doComplete(Symbol sym);
+
+}
diff --git a/sources/scalac/symtab/classfile/PackageParser.java b/sources/scalac/symtab/classfile/PackageParser.java
index 346272230b..fa0940e379 100644
--- a/sources/scalac/symtab/classfile/PackageParser.java
+++ b/sources/scalac/symtab/classfile/PackageParser.java
@@ -15,30 +15,28 @@ import scalac.util.*;
import java.io.*;
import java.util.HashMap;
-public class PackageParser extends Type.LazyType {
-
- /** the global compilation environment
- */
- protected Global global;
+public class PackageParser extends MetadataParser {
/** the class parser
*/
public ClassParser classCompletion;
public SymblParser symblCompletion; // provisional
+ protected final CLRPackageParser importer;
+
public PackageParser(Global global) {
- this.global = global;
+ super(global);
this.classCompletion = new ClassParser(global);
this.symblCompletion = new SymblParser(global); // provisional
if (global.reporter.verbose)
System.out.println("classpath = " + global.classPath);//debug
+ importer = (global.target == global.TARGET_MSIL)
+ ? CLRPackageParser.create(global) : null;
}
/** complete package type symbol p by loading all package members
*/
- public void complete(Symbol p) {
- Phase phase = global.currentPhase;
- global.currentPhase = global.getFirstPhase();
+ protected void doComplete(Symbol p) {
long msec = System.currentTimeMillis();
Scope members = new Scope();
String dirname = null;
@@ -54,12 +52,13 @@ public class PackageParser extends Type.LazyType {
AbstractFile.open(base[i], dirname),
p, members, symFile);
}
+ 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");
- global.currentPhase = phase;
}
private boolean isMostRecent(AbstractFile f, Symbol previous, HashMap symFile) {
@@ -144,4 +143,6 @@ public class PackageParser extends Type.LazyType {
} catch (IOException e) {
}
}
+
+
}
diff --git a/sources/scalac/symtab/classfile/SymblParser.java b/sources/scalac/symtab/classfile/SymblParser.java
index d540b698d5..72975117b5 100644
--- a/sources/scalac/symtab/classfile/SymblParser.java
+++ b/sources/scalac/symtab/classfile/SymblParser.java
@@ -16,17 +16,13 @@ import java.io.*;
public class SymblParser extends ClassParser {
- /** the global compilation environment
- */
-
public SymblParser(Global global) {
super(global);
}
+
/** complete class symbol c by loading the class
*/
- public void complete(Symbol c) {
- Phase phase = global.currentPhase;
- global.currentPhase = global.getFirstPhase();
+ public void doComplete(Symbol c) {
//System.out.println("loading " + c);//DEBUG
try {
long msec = System.currentTimeMillis();
@@ -50,7 +46,6 @@ public class SymblParser extends ClassParser {
global.error("i/o error while loading " + c);
c.setInfo(Type.ErrorType);
}
- global.currentPhase = phase;
}
}