blob: 02d739249b35073cb97445c4fb77df68b0140eaa (
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
|
/* ____ ____ ____ ____ ______ *\
** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
** /_____/\____/\___/\____/____/ **
\* */
// $Id$
package scalac.symtab;
import ch.epfl.lamp.util.SourceFile;
import scalac.*;
import scalac.ast.parser.*;
import scalac.typechecker.AnalyzerPhase;
import java.io.*;
public class SourceCompleter extends Type.LazyType {
/** 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;
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.fullName()) + ".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;
}
}
}
|