diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-09-26 10:48:14 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-09-27 15:53:17 +0200 |
commit | 7e5646388243522bef8f4a1a1e255c7d8e30236d (patch) | |
tree | c28c7fc4240351e3fb9abf1f60a4cf15b8af97e0 /src/compiler | |
parent | a79ba085c5304e304e617c7d95520d25e955d88f (diff) | |
download | scala-7e5646388243522bef8f4a1a1e255c7d8e30236d.tar.gz scala-7e5646388243522bef8f4a1a1e255c7d8e30236d.tar.bz2 scala-7e5646388243522bef8f4a1a1e255c7d8e30236d.zip |
revives macros.Infrastructure
Takes macros.Settings, throws away its mutable parts, moves classPath from Run
back to the top level - and unites all that in the Infrastructure trait.
Diffstat (limited to 'src/compiler')
4 files changed, 18 insertions, 39 deletions
diff --git a/src/compiler/scala/reflect/macros/runtime/Context.scala b/src/compiler/scala/reflect/macros/runtime/Context.scala index 467c335362..8e8b0fcea1 100644 --- a/src/compiler/scala/reflect/macros/runtime/Context.scala +++ b/src/compiler/scala/reflect/macros/runtime/Context.scala @@ -9,7 +9,7 @@ abstract class Context extends scala.reflect.macros.Context with Names with Reifiers with FrontEnds - with Settings + with Infrastructure with Typers with Parsers with Evals diff --git a/src/compiler/scala/reflect/macros/runtime/Infrastructure.scala b/src/compiler/scala/reflect/macros/runtime/Infrastructure.scala new file mode 100644 index 0000000000..7781693822 --- /dev/null +++ b/src/compiler/scala/reflect/macros/runtime/Infrastructure.scala @@ -0,0 +1,16 @@ +package scala.reflect.macros +package runtime + +trait Infrastructure { + self: Context => + + def settings: List[String] = { + val us = universe.settings + import us._ + userSetSettings collectFirst { case x: MultiStringSetting if x.name == XmacroSettings.name => x.value } getOrElse Nil + } + + def compilerSettings: List[String] = universe.settings.recreateArgs + + def classPath: List[java.net.URL] = global.classPath.asURLs +} diff --git a/src/compiler/scala/reflect/macros/runtime/Settings.scala b/src/compiler/scala/reflect/macros/runtime/Settings.scala deleted file mode 100644 index e9d9a17b81..0000000000 --- a/src/compiler/scala/reflect/macros/runtime/Settings.scala +++ /dev/null @@ -1,35 +0,0 @@ -package scala.reflect.macros -package runtime - -trait Settings { - self: Context => - - def settings: List[String] = { - val us = universe.settings - import us._ - userSetSettings collectFirst { case x: MultiStringSetting if x.name == XmacroSettings.name => x.value } getOrElse Nil - } - - def compilerSettings: List[String] = universe.settings.recreateArgs - - def setCompilerSettings(options: String): this.type = - // SI-5925: doesn't work with arguments that contains whitespaces - setCompilerSettings(options.split(" ").toList) - - def setCompilerSettings(options: List[String]): this.type = { - val settings = new scala.tools.nsc.Settings(_ => ()) - settings.copyInto(universe.settings) - this - } - - def withCompilerSettings[T](options: String)(op: => T): T = - // SI-5925: doesn't work with arguments that contains whitespaces - withCompilerSettings(options.split(" ").toList)(op) - - def withCompilerSettings[T](options: List[String])(op: => T): T = { - val old = options - setCompilerSettings(options) - try op - finally setCompilerSettings(old) - } -} diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 8a9db2d4f0..708824ede1 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -1230,8 +1230,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter) /** Has any macro expansion used a fallback during this run? */ var seenMacroExpansionsFallingBack = false - val classPath: List[java.net.URL] = Global.this.classPath.asURLs - /** To be initialized from firstPhase. */ private var terminalPhase: Phase = NoPhase @@ -1329,7 +1327,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) } } for (fullname <- toReload) - Global.this.classPath.findClass(fullname) match { + classPath.findClass(fullname) match { case Some(classRep) => if (settings.verbose.value) inform("[reset] reinit "+fullname) loaders.initializeFromClassPath(root, classRep) |