diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-09-27 10:33:18 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-09-27 10:33:18 -0700 |
commit | 71212e51ed5990a3f42e50edea0cebeac3b0d4ca (patch) | |
tree | 363d9ff755f9980701bb34e79f94f474a720e731 /src | |
parent | 78323cbf4c9568b5a7cf326b4d22e042fe052ed5 (diff) | |
parent | 40c10680d7c16624e878dea19ea31f9e7eaa9712 (diff) | |
download | scala-71212e51ed5990a3f42e50edea0cebeac3b0d4ca.tar.gz scala-71212e51ed5990a3f42e50edea0cebeac3b0d4ca.tar.bz2 scala-71212e51ed5990a3f42e50edea0cebeac3b0d4ca.zip |
Merge pull request #2963 from sjrd/topic/hooks-for-scala-js
Small refactorings giving hooks for Scala.js
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala | 9 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/util/ClassPath.scala | 12 |
2 files changed, 17 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala index 6f27eb8660..8b739958ff 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala @@ -164,10 +164,17 @@ abstract class SymbolLoaders { if (settings.verbose) inform("[symloader] no class, picked up source file for " + src.path) enterToplevelsFromSource(owner, classRep.name, src) case (Some(bin), _) => - enterClassAndModule(owner, classRep.name, new ClassfileLoader(bin)) + enterClassAndModule(owner, classRep.name, newClassLoader(bin)) } } + /** Create a new loader from a binary classfile. + * This is intented as a hook allowing to support loading symbols from + * files other than .class files. + */ + protected def newClassLoader(bin: AbstractFile): SymbolLoader = + new ClassfileLoader(bin) + /** * A lazy type that completes itself by calling parameter doComplete. * Any linked modules/classes or module classes are also initialized. diff --git a/src/compiler/scala/tools/nsc/util/ClassPath.scala b/src/compiler/scala/tools/nsc/util/ClassPath.scala index 906a575d90..c63d7f6820 100644 --- a/src/compiler/scala/tools/nsc/util/ClassPath.scala +++ b/src/compiler/scala/tools/nsc/util/ClassPath.scala @@ -96,6 +96,12 @@ object ClassPath { */ def isValidName(name: String): Boolean = true + /** Filters for assessing validity of various entities. + */ + def validClassFile(name: String) = endsClass(name) && isValidName(name) + def validPackage(name: String) = (name != "META-INF") && (name != "") && (name.charAt(0) != '.') + def validSourceFile(name: String) = endsScala(name) || endsJava(name) + /** From the representation to its identifier. */ def toBinaryName(rep: T): String @@ -208,9 +214,9 @@ abstract class ClassPath[T] { /** Filters for assessing validity of various entities. */ - def validClassFile(name: String) = endsClass(name) && context.isValidName(name) - def validPackage(name: String) = (name != "META-INF") && (name != "") && (name.charAt(0) != '.') - def validSourceFile(name: String) = endsScala(name) || endsJava(name) + def validClassFile(name: String) = context.validClassFile(name) + def validPackage(name: String) = context.validPackage(name) + def validSourceFile(name: String) = context.validSourceFile(name) /** * Find a ClassRep given a class name of the form "package.subpackage.ClassName". |