blob: 0dc29c87bb3af319dc24a8103da267d016a4ef7f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
/* ____ ____ ____ ____ ______ *\
** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
** /_____/\____/\___/\____/____/ **
** **
** $Id$
\* */
package scalac.symtab.classfile;
import scalac.*;
import scalac.symtab.*;
import scalac.util.*;
import java.io.*;
public class ClassParser extends Type.LazyType {
/** the global compilation environment
*/
protected Global global;
protected boolean completed = false;
public ClassParser(Global global) {
this.global = global;
}
/** complete class symbol c by loading the class
*/
public void complete(Symbol c) {
c.owner().initialize();
//System.out.println("loading " + c);//DEBUG
try {
long msec = System.currentTimeMillis();
String filename = SourceRepresentation.externalizeFileName(
c.fullName()) + ".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) {
e.printStackTrace();
global.error("i/o error while loading " + c);
c.setInfo(Type.ErrorType);
}
}
public Type.LazyType staticsParser(Symbol clazz) {
return new StaticsParser(clazz);
}
public Type.LazyType aliasParser(Symbol alias) {
return new AliasParser(alias);
}
public class StaticsParser extends Type.LazyType {
Symbol clazz;
StaticsParser(Symbol clazz) {
this.clazz = clazz;
}
public void complete(Symbol statics) {
ClassParser.this.complete(clazz);
}
public String toString() {
return "StaticsParser(" + clazz + ")";
}
}
class AliasParser extends Type.LazyType {
Symbol alias;
AliasParser(Symbol alias) {
this.alias = alias;
}
public void complete(Symbol c) {
try {
long msec = System.currentTimeMillis();
String filename = SourceRepresentation.externalizeFileName(
alias.fullName()) + ".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");
}
} catch (IOException e) {
e.printStackTrace();
global.error("i/o error while loading " + c);
c.setInfo(Type.ErrorType);
}
}
}
}
|