diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-09-26 08:48:26 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-09-27 15:49:03 +0200 |
commit | e9fbb661a3deb6e6234bdf94dce6fa98a205f3ca (patch) | |
tree | fba72faa84d814735024081a1cd1644e9c75e9da /src | |
parent | 1839c1b5528e706c280e7d81031499f3d46826ec (diff) | |
download | scala-e9fbb661a3deb6e6234bdf94dce6fa98a205f3ca.tar.gz scala-e9fbb661a3deb6e6234bdf94dce6fa98a205f3ca.tar.bz2 scala-e9fbb661a3deb6e6234bdf94dce6fa98a205f3ca.zip |
removes extraneous stuff from macros.Infrastructure
libraryClassLoader can be derived from currentClassPath
currentMacro can be trivially derived from macroApplication
Backend-detection methods forXXX (as in forJVM or forScaladoc)
might be useful, but current design of this API is not future-proof.
I'm not able to come up with a better design on the spot, so
let's remove this functionality for the moment.
Diffstat (limited to 'src')
3 files changed, 4 insertions, 57 deletions
diff --git a/src/compiler/scala/reflect/macros/runtime/Evals.scala b/src/compiler/scala/reflect/macros/runtime/Evals.scala index acafeb5b02..1f7b5f2ff1 100644 --- a/src/compiler/scala/reflect/macros/runtime/Evals.scala +++ b/src/compiler/scala/reflect/macros/runtime/Evals.scala @@ -7,7 +7,7 @@ import scala.tools.reflect.ToolBox trait Evals { self: Context => - private lazy val evalMirror = ru.runtimeMirror(libraryClassLoader) + private lazy val evalMirror = ru.runtimeMirror(universe.analyzer.macroClassloader) private lazy val evalToolBox = evalMirror.mkToolBox() private lazy val evalImporter = ru.mkImporter(universe).asInstanceOf[ru.Importer { val from: universe.type }] diff --git a/src/compiler/scala/reflect/macros/runtime/Infrastructure.scala b/src/compiler/scala/reflect/macros/runtime/Infrastructure.scala index 7157dbeaa2..87ac97ff27 100644 --- a/src/compiler/scala/reflect/macros/runtime/Infrastructure.scala +++ b/src/compiler/scala/reflect/macros/runtime/Infrastructure.scala @@ -6,19 +6,9 @@ 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 + val currentClassPath: List[java.net.URL] = universe.classPath.asURLs type Run = universe.Run @@ -31,6 +21,4 @@ trait Infrastructure { 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 } diff --git a/src/reflect/scala/reflect/macros/Infrastructure.scala b/src/reflect/scala/reflect/macros/Infrastructure.scala index 80153ff257..f918770a3a 100644 --- a/src/reflect/scala/reflect/macros/Infrastructure.scala +++ b/src/reflect/scala/reflect/macros/Infrastructure.scala @@ -4,50 +4,13 @@ package macros trait Infrastructure { self: Context => - /** Determines whether the compiler expanding a macro targets JVM. - */ - val forJVM: Boolean - - /** Determines whether the compiler expanding a macro targets CLR. - */ - val forMSIL: Boolean - - /** Determines whether the compiler expanding a macro is a presentation compiler. - */ - val forInteractive: Boolean - - /** Determines whether the compiler expanding a macro is a Scaladoc compiler. - */ - val forScaladoc: Boolean - /** Exposes current compilation run. */ val currentRun: Run - /** Exposes library classpath. - */ - val libraryClassPath: List[java.net.URL] - - /** Exposes a classloader that corresponds to the library classpath. - * - * With this classloader you can perform on-the-fly evaluation of macro arguments. - * For example, consider this code snippet: - * - * def staticEval[T](x: T) = macro staticEval[T] - * - * def staticEval[T](c: Context)(x: c.Expr[T]) = { - * import scala.reflect.runtime.{universe => ru} - * val mirror = ru.runtimeMirror(c.libraryClassLoader) - * import scala.tools.reflect.ToolBox - * val toolBox = mirror.mkToolBox() - * val importer = ru.mkImporter(c.universe).asInstanceOf[ru.Importer { val from: c.universe.type }] - * val tree = c.resetAllAttrs(x.tree.duplicate) - * val imported = importer.importTree(tree) - * val valueOfX = toolBox.eval(imported).asInstanceOf[T] - * ... - * } + /** Exposes current classpath. */ - def libraryClassLoader: ClassLoader + val currentClassPath: List[java.net.URL] /** As seen by macro API, compilation run is an opaque type that can be deconstructed into: * 1) Current compilation unit @@ -73,8 +36,4 @@ trait Infrastructure { abstract class CompilationUnitExtractor { def unapply(compilationUnit: CompilationUnit): Option[(java.io.File, Array[Char], Tree)] } - - /** Returns a macro definition which triggered this macro expansion. - */ - val currentMacro: Symbol } |