summaryrefslogtreecommitdiff
path: root/src/compiler/scala/reflect/makro/runtime/Infrastructure.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/scala/reflect/makro/runtime/Infrastructure.scala')
-rw-r--r--src/compiler/scala/reflect/makro/runtime/Infrastructure.scala36
1 files changed, 27 insertions, 9 deletions
diff --git a/src/compiler/scala/reflect/makro/runtime/Infrastructure.scala b/src/compiler/scala/reflect/makro/runtime/Infrastructure.scala
index 6d8e55cc35..76c4b21731 100644
--- a/src/compiler/scala/reflect/makro/runtime/Infrastructure.scala
+++ b/src/compiler/scala/reflect/makro/runtime/Infrastructure.scala
@@ -1,26 +1,44 @@
package scala.reflect.makro
package runtime
+import scala.tools.nsc.util.ScalaClassLoader
+
trait Infrastructure {
self: Context =>
- val forJVM: Boolean = mirror.forJVM
+ val forJVM: Boolean = universe.forJVM
+
+ val forMSIL: Boolean = universe.forMSIL
+
+ val forInteractive: Boolean = universe.forInteractive
- val forMSIL: Boolean = mirror.forMSIL
+ val forScaladoc: Boolean = universe.forScaladoc
- val forInteractive: Boolean = mirror.forInteractive
+ val currentRun: Run = universe.currentRun
- val forScaladoc: Boolean = mirror.forScaladoc
+ val libraryClassPath: List[java.net.URL] = universe.classPath.asURLs
- val currentRun: Run = mirror.currentRun
+ lazy val libraryClassLoader: ClassLoader = {
+ val classpath = libraryClassPath
+ var loader: ClassLoader = ScalaClassLoader.fromURLs(classpath, self.getClass.getClassLoader)
+
+ // [Eugene] a heuristic to detect REPL
+ if (universe.settings.exposeEmptyPackage.value) {
+ import scala.tools.nsc.interpreter._
+ val virtualDirectory = universe.settings.outputDirs.getSingleOutput.get
+ loader = new AbstractFileClassLoader(virtualDirectory, loader) {}
+ }
+
+ loader
+ }
- type Run = mirror.Run
+ type Run = universe.Run
object Run extends RunExtractor {
def unapply(run: Run): Option[(CompilationUnit, List[CompilationUnit])] = Some(run.currentUnit, run.units.toList)
}
- type CompilationUnit = mirror.CompilationUnit
+ type CompilationUnit = universe.CompilationUnit
object CompilationUnit extends CompilationUnitExtractor {
def unapply(compilationUnit: CompilationUnit): Option[(java.io.File, Array[Char], Tree)] = Some(compilationUnit.source.file.file, compilationUnit.source.content, compilationUnit.body)
@@ -28,7 +46,7 @@ trait Infrastructure {
val currentMacro: Symbol = expandee.symbol
- val globalCache: collection.mutable.Map[Any, Any] = mirror.analyzer.globalMacroCache
+ val globalCache: collection.mutable.Map[Any, Any] = universe.analyzer.globalMacroCache
- val cache: collection.mutable.Map[Any, Any] = mirror.analyzer.perRunMacroCache.getOrElseUpdate(currentMacro, collection.mutable.Map[Any, Any]())
+ val cache: collection.mutable.Map[Any, Any] = universe.analyzer.perRunMacroCache.getOrElseUpdate(currentMacro, collection.mutable.Map[Any, Any]())
} \ No newline at end of file