git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@5574 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
parent
e88471c2e6
commit
977ef82b06
|
@ -420,18 +420,21 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
|
||||||
}
|
}
|
||||||
|
|
||||||
def compileLate(file: AbstractFile): unit =
|
def compileLate(file: AbstractFile): unit =
|
||||||
if (fileset == null)
|
if (fileset == null) {
|
||||||
throw new FatalError("No class file for " + file + " was found\n(This file cannot be loaded as a source file)");
|
val msg = "No class file for " + file + " was found\n(This file cannot be loaded as a source file)";
|
||||||
|
System.err.println(msg);
|
||||||
|
throw new FatalError(msg);
|
||||||
|
}
|
||||||
else if (!(fileset contains file)) {
|
else if (!(fileset contains file)) {
|
||||||
val unit = new CompilationUnit(getSourceFile(file));
|
val unit = new CompilationUnit(getSourceFile(file));
|
||||||
addUnit(unit);
|
addUnit(unit);
|
||||||
var localPhase = firstPhase.asInstanceOf[GlobalPhase];
|
var localPhase = firstPhase.asInstanceOf[GlobalPhase];
|
||||||
while ((localPhase.id < globalPhase.id || localPhase.id <= namerPhase.id) &&
|
while ((localPhase.id < globalPhase.id || localPhase.id <= namerPhase.id) &&
|
||||||
reporter.errors == 0) {
|
reporter.errors == 0) {
|
||||||
atPhase(localPhase)(localPhase.applyPhase(unit));
|
atPhase(localPhase)(localPhase.applyPhase(unit));
|
||||||
localPhase = localPhase.next.asInstanceOf[GlobalPhase];
|
localPhase = localPhase.next.asInstanceOf[GlobalPhase];
|
||||||
}
|
}
|
||||||
refreshProgress;
|
refreshProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
def compileFiles(files: List[AbstractFile]): unit =
|
def compileFiles(files: List[AbstractFile]): unit =
|
||||||
|
|
|
@ -103,19 +103,20 @@ abstract class SymbolLoaders {
|
||||||
}
|
}
|
||||||
|
|
||||||
def enterClassAndModule(str: String, completer: SymbolLoader): unit = {
|
def enterClassAndModule(str: String, completer: SymbolLoader): unit = {
|
||||||
val owner = if (root.isRoot) definitions.EmptyPackageClass else root;
|
val owner = if (root.isRoot) definitions.EmptyPackageClass else root;
|
||||||
val name = newTermName(str);
|
val name = newTermName(str);
|
||||||
val clazz = owner.newClass(Position.NOPOS, name.toTypeName);
|
val clazz = owner.newClass(Position.NOPOS, name.toTypeName);
|
||||||
val module = owner.newModule(Position.NOPOS, name);
|
val module = owner.newModule(Position.NOPOS, name);
|
||||||
if (completer.sourceFile != null) clazz.sourceFile = completer.sourceFile;
|
if (completer.sourceFile != null) clazz.sourceFile = completer.sourceFile;
|
||||||
clazz.setInfo(completer);
|
clazz.setInfo(completer);
|
||||||
module.setInfo(completer);
|
module.setInfo(completer);
|
||||||
module.moduleClass.setInfo(moduleClassLoader);
|
module.moduleClass.setInfo(moduleClassLoader);
|
||||||
owner.info.decls.enter(clazz);
|
owner.info.decls.enter(clazz);
|
||||||
owner.info.decls.enter(module);
|
owner.info.decls.enter(module);
|
||||||
assert(clazz.linkedModule == module, module);
|
assert(clazz.linkedModule == module, module);
|
||||||
assert(module.linkedClass == clazz, clazz);
|
assert(module.linkedClass == clazz, clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
val classes = new HashMap[String, ClassPath.Context];
|
val classes = new HashMap[String, ClassPath.Context];
|
||||||
val packages = new HashMap[String, ClassPath.Context];
|
val packages = new HashMap[String, ClassPath.Context];
|
||||||
for (val dir <- directory.entries) if (dir.location != null) {
|
for (val dir <- directory.entries) if (dir.location != null) {
|
||||||
|
@ -149,15 +150,16 @@ abstract class SymbolLoaders {
|
||||||
// do classes first
|
// do classes first
|
||||||
|
|
||||||
for (val Pair(name, file) <- classes.elements) {
|
for (val Pair(name, file) <- classes.elements) {
|
||||||
val loader = if (!file.isSourceFile) {
|
val loader = if (!file.isSourceFile) {
|
||||||
// System.err.println("CLASSFILE: " + file.file + " in " + file);
|
// System.err.println("CLASSFILE: " + file.file + " in " + file);
|
||||||
new ClassfileLoader(file.file, file.sourceFile, file.sourcePath);
|
new ClassfileLoader(file.classFile, file.sourceFile, file.sourcePath);
|
||||||
} else {
|
} else {
|
||||||
assert(file.sourceFile != null);
|
assert(file.sourceFile != null);
|
||||||
//System.err.println("SOURCEFILE: " + file.sourceFile + " in " + file);
|
//System.err.println("SOURCEFILE: " + file.sourceFile + " in " + file);
|
||||||
new SourcefileLoader(file.sourceFile);
|
|
||||||
}
|
new SourcefileLoader(file.sourceFile);
|
||||||
enterClassAndModule(name, loader);
|
}
|
||||||
|
enterClassAndModule(name, loader);
|
||||||
}
|
}
|
||||||
for (val Pair(name, file) <- packages.elements) enterPackage(name, new PackageLoader(file));
|
for (val Pair(name, file) <- packages.elements) enterPackage(name, new PackageLoader(file));
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,37 +46,37 @@ object ClassPath {
|
||||||
class Context(val entries : List[Entry]) {
|
class Context(val entries : List[Entry]) {
|
||||||
def find(name : String, isDir : boolean) : Context = if (isPackage) {
|
def find(name : String, isDir : boolean) : Context = if (isPackage) {
|
||||||
def find0(entries : List[Entry]) : Context = {
|
def find0(entries : List[Entry]) : Context = {
|
||||||
if (entries.isEmpty) new Context(Nil);
|
if (entries.isEmpty) new Context(Nil);
|
||||||
else {
|
else {
|
||||||
val ret = find0(entries.tail);
|
val ret = find0(entries.tail);
|
||||||
val head = entries.head;
|
val head = entries.head;
|
||||||
|
|
||||||
|
|
||||||
val clazz = if (head.location == null) null; else
|
val clazz = if (head.location == null) null; else
|
||||||
head.location.lookupPath(name + (if (!isDir) ".class" else ""), isDir);
|
head.location.lookupPath(name + (if (!isDir) ".class" else ""), isDir);
|
||||||
|
|
||||||
val source0 = if (head.source == null) null; else {
|
val source0 = if (head.source == null) null; else {
|
||||||
val source1 = head.source.location.lookupPath(name + (if (isDir) "" else ".scala"), isDir);
|
val source1 = head.source.location.lookupPath(name + (if (isDir) "" else ".scala"), isDir);
|
||||||
if (source1 == null && !isDir && clazz != null) head.source.location;
|
if (source1 == null && !isDir && clazz != null) head.source.location;
|
||||||
else source1;
|
else source1;
|
||||||
}
|
}
|
||||||
if (clazz == null && source0 == null) ret;
|
if (clazz == null && source0 == null) ret;
|
||||||
else {
|
else {
|
||||||
object entry extends Entry {
|
object entry extends Entry {
|
||||||
override def location = clazz;
|
override def location = clazz;
|
||||||
override def source =
|
override def source =
|
||||||
if (source0 == null) null;
|
if (source0 == null) null;
|
||||||
else new Source(source0, head.source.compile);
|
else new Source(source0, head.source.compile);
|
||||||
};
|
};
|
||||||
new Context(entry :: ret.entries);
|
new Context(entry :: ret.entries);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val ret = find0(entries);
|
val ret = find0(entries);
|
||||||
if (false && this.toString().indexOf("scala") != -1)
|
if (false && this.toString().indexOf("scala") != -1)
|
||||||
System.err.println("FIND " + name + " in " + this + " => " + ret);
|
System.err.println("FIND " + name + " in " + this + " => " + ret);
|
||||||
ret;
|
ret;
|
||||||
} else null;
|
} else null;
|
||||||
|
|
||||||
|
|
||||||
def isPackage = {
|
def isPackage = {
|
||||||
|
@ -107,27 +107,21 @@ object ClassPath {
|
||||||
if (entries0.isEmpty) "";
|
if (entries0.isEmpty) "";
|
||||||
else toString(entries0.head) + ":::" + toString(entries0.tail);
|
else toString(entries0.head) + ":::" + toString(entries0.tail);
|
||||||
|
|
||||||
def isSourceFile =
|
def isSourceFile = {
|
||||||
(!isPackage && !entries.isEmpty && entries.head.source != null &&
|
def head = entries.head;
|
||||||
entries.head.source.location.getFile().isFile());
|
def clazz = head.location;
|
||||||
|
def source = if (head.source == null) null else head.source.location;
|
||||||
|
if (entries.isEmpty || entries.isEmpty || source == null || !head.source.compile || !source.getFile().isFile()) false;
|
||||||
|
else if (clazz == null) true;
|
||||||
|
else if (source.lastModified() > clazz.lastModified()) true;
|
||||||
|
else false;
|
||||||
|
}
|
||||||
|
|
||||||
def sourceFile = if (isSourceFile) entries.head.source.location else null;
|
def sourceFile = if ( isSourceFile) entries.head.source.location else null;
|
||||||
|
def classFile = if (!isSourceFile) entries.head .location else null;
|
||||||
|
|
||||||
def sourcePath = if (!isSourceFile && entries.head.source != null) entries.head.source.location else null;
|
def sourcePath = if (!isSourceFile && entries.head.source != null) entries.head.source.location else null;
|
||||||
|
|
||||||
def file = {
|
|
||||||
if (entries.isEmpty) null; /* file not found */
|
|
||||||
else if (isPackage) null;
|
|
||||||
else {
|
|
||||||
def clazz = entries.head.location;
|
|
||||||
def source = if (entries.head.source == null) null else entries.head.source.location;
|
|
||||||
assert(!(clazz == null && source == null));
|
|
||||||
if (clazz == null) source;
|
|
||||||
else if (source == null) clazz;
|
|
||||||
else if (source.getFile().isFile() && source.lastModified() > clazz.lastModified()) source;
|
|
||||||
else clazz;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
def validPackage(name: String): Boolean =
|
def validPackage(name: String): Boolean =
|
||||||
if (name.equals("META-INF")) false;
|
if (name.equals("META-INF")) false;
|
||||||
else if (name.startsWith(".")) false;
|
else if (name.startsWith(".")) false;
|
||||||
|
@ -141,9 +135,12 @@ object ClassPath {
|
||||||
|
|
||||||
|
|
||||||
def this(classpath : String, source : String, output : String, boot : String, extdirs : String) = {
|
def this(classpath : String, source : String, output : String, boot : String, extdirs : String) = {
|
||||||
this();
|
this();
|
||||||
|
//System.err.println("BOOT: " + boot);
|
||||||
|
//System.err.println("CLAS: " + classpath);
|
||||||
|
|
||||||
addFilesInPath(boot);
|
addFilesInPath(boot);
|
||||||
|
|
||||||
addArchivesInExtDirPath(extdirs);
|
addArchivesInExtDirPath(extdirs);
|
||||||
val strtok = new StringTokenizer(source, File.pathSeparator);
|
val strtok = new StringTokenizer(source, File.pathSeparator);
|
||||||
while (strtok.hasMoreTokens()) {
|
while (strtok.hasMoreTokens()) {
|
||||||
|
@ -153,7 +150,7 @@ object ClassPath {
|
||||||
entries += output0;
|
entries += output0;
|
||||||
}
|
}
|
||||||
addFilesInPath(classpath);
|
addFilesInPath(classpath);
|
||||||
//System.err.println("CLASSPATH: " + root);
|
//System.err.println("CLASSPATH: " + root);
|
||||||
}
|
}
|
||||||
def library(classes : String, sources : String) = {
|
def library(classes : String, sources : String) = {
|
||||||
assert(classes != null);
|
assert(classes != null);
|
||||||
|
|
Loading…
Reference in New Issue