summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2003-08-05 13:51:45 +0000
committerMartin Odersky <odersky@gmail.com>2003-08-05 13:51:45 +0000
commita0451060865e799e5adcaccd06024a0d4196ed4d (patch)
tree1b329977ec2a4e2582319215a5f194d41a10719e /sources
parenta6a049520aaccd42e000a910cff9fed20995e6b9 (diff)
downloadscala-a0451060865e799e5adcaccd06024a0d4196ed4d.tar.gz
scala-a0451060865e799e5adcaccd06024a0d4196ed4d.tar.bz2
scala-a0451060865e799e5adcaccd06024a0d4196ed4d.zip
*** empty log message ***
Diffstat (limited to 'sources')
-rw-r--r--sources/scalac/Global.java3
-rw-r--r--sources/scalac/Unit.java4
-rw-r--r--sources/scalac/symtab/classfile/Pickle.java11
-rw-r--r--sources/scalac/typechecker/Analyzer.java29
4 files changed, 21 insertions, 26 deletions
diff --git a/sources/scalac/Global.java b/sources/scalac/Global.java
index 7b68fa43d5..4860eb9402 100644
--- a/sources/scalac/Global.java
+++ b/sources/scalac/Global.java
@@ -94,6 +94,8 @@ public class Global {
*/
public final Map/*<Symbol, String>*/ mapSymbolComment = new HashMap();
+ public final Map/*<FullName, Pickle>*/ symdata = new HashMap();
+
/** scaladoc option (with docmodule and docmodulepath)
*/
public final boolean doc;
@@ -318,6 +320,7 @@ public class Global {
sym.reset(new SourceCompleter(this));
}
}
+ symdata.clear();
compiledNow.clear();
printer.end();
}
diff --git a/sources/scalac/Unit.java b/sources/scalac/Unit.java
index 1deb71317b..a57aab9f8a 100644
--- a/sources/scalac/Unit.java
+++ b/sources/scalac/Unit.java
@@ -39,10 +39,6 @@ public class Unit {
*/
public Tree[] body;
- /** the generated symbol data; Symbol -> byte[]
- */
- public HashMap/*<Name,Pickle>*/ symdata = new HashMap();
-
/** the name mangler
*/
public NameMangler mangler = new NameMangler();
diff --git a/sources/scalac/symtab/classfile/Pickle.java b/sources/scalac/symtab/classfile/Pickle.java
index a82962dfb5..fe41289f8f 100644
--- a/sources/scalac/symtab/classfile/Pickle.java
+++ b/sources/scalac/symtab/classfile/Pickle.java
@@ -58,13 +58,18 @@ public class Pickle implements Kinds, Modifiers, EntryTags {
/** Finalize pickler with given fullname.
*/
- public void finalize(Name fullname) {
+ public void pickle() {
bytes = new byte[4096];
bp = 0;
writeAttr();
this.index = null;
this.entries = null;
- writeFile(fullname);
+ }
+
+ /** The number of elements defined in `bytes'.
+ */
+ public int size() {
+ return bp;
}
/** Create output file with given extension for given class.
@@ -94,7 +99,7 @@ public class Pickle implements Kinds, Modifiers, EntryTags {
}
}
- private void writeFile(Name fullname) {
+ public void writeFile(Name fullname) {
File outfile = outputFile(fullname, ".symbl");
try {
createPath(outfile);
diff --git a/sources/scalac/typechecker/Analyzer.java b/sources/scalac/typechecker/Analyzer.java
index e577ab8388..9a9803691f 100644
--- a/sources/scalac/typechecker/Analyzer.java
+++ b/sources/scalac/typechecker/Analyzer.java
@@ -110,44 +110,35 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
assert this.context != null : "could not find context for " + unit;
unit.body = transformStatSeq(unit.body, Symbol.NONE);
if (global.target != global.TARGET_INT && global.reporter.errors() == 0) {
- genSymData(unit.symdata, unit.body);
- finalizeSymData(unit.symdata);
+ genSymData(unit.body);
}
this.unit = null;
this.context = null;
global.operation("checked " + unit);
}
- public void genSymData(HashMap/*<Name, Pickle>*/ symdata, Tree[] stats) {
+ public void genSymData(Tree[] stats) {
for (int i = 0; i < stats.length; i++) {
switch (stats[i]) {
case ClassDef(_, _, _, _, _, _):
case ModuleDef(_, _, _, _):
Symbol sym = stats[i].symbol();
Name fullname = sym.fullName();
- Pickle pickle = (Pickle) unit.symdata.get(fullname);
- if (pickle == null) {
- pickle = new Pickle();
- unit.symdata.put(fullname, pickle);
+ if (global.symdata.get(fullname) == null) {
+ Pickle pickle = new Pickle();
+ pickle.add(sym.owner().info().lookup(sym.name.toTermName()));
+ pickle.add(sym.owner().info().lookup(sym.name.toTypeName()));
+ pickle.pickle();
+ pickle.writeFile(fullname);
+ global.symdata.put(fullname, pickle);
}
- pickle.add(sym.owner().info().lookup(sym.name.toTermName()));
- pickle.add(sym.owner().info().lookup(sym.name.toTypeName()));
break;
case PackageDef(Tree packaged, Tree.Template templ):
- genSymData(symdata, templ.body);
+ genSymData(templ.body);
}
}
}
- public void finalizeSymData(HashMap/*<Name, Pickle>*/ symdata) {
- for (Iterator it = symdata.entrySet().iterator(); it.hasNext();) {
- Map.Entry entry = (Map.Entry) it.next();
- Name fullname = (Name) entry.getKey();
- Pickle pickle = (Pickle) entry.getValue();
- pickle.finalize(fullname);
- }
- }
-
/** Mode constants
*/
static final int NOmode = 0x000;