summaryrefslogtreecommitdiff
path: root/src/compiler/scala/reflect/macros/runtime/Infrastructure.scala
blob: a8cc61e0f9364de6513463857ef3db46e05f75ca (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
package scala.reflect.macros
package runtime

import scala.tools.nsc.util.ScalaClassLoader

trait Infrastructure {
  self: Context =>

  val forJVM: Boolean = universe.forJVM

  val forMSIL: Boolean = universe.forMSIL

  val forInteractive: Boolean = universe.forInteractive

  val forScaladoc: Boolean = universe.forScaladoc

  val currentRun: Run = universe.currentRun

  val libraryClassPath: List[java.net.URL] = universe.classPath.asURLs

  lazy val libraryClassLoader: ClassLoader = universe.analyzer.macroClassloader

  type Run = universe.Run

  object Run extends RunExtractor {
    def unapply(run: Run): Option[(CompilationUnit, List[CompilationUnit])] = Some(run.currentUnit, run.units.toList)
  }

  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)
  }

  val currentMacro: Symbol = expandee.symbol
}