summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-09-26 10:48:14 +0200
committerEugene Burmako <xeno.by@gmail.com>2012-09-27 15:53:17 +0200
commit7e5646388243522bef8f4a1a1e255c7d8e30236d (patch)
treec28c7fc4240351e3fb9abf1f60a4cf15b8af97e0 /src
parenta79ba085c5304e304e617c7d95520d25e955d88f (diff)
downloadscala-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')
-rw-r--r--src/compiler/scala/reflect/macros/runtime/Context.scala2
-rw-r--r--src/compiler/scala/reflect/macros/runtime/Infrastructure.scala16
-rw-r--r--src/compiler/scala/reflect/macros/runtime/Settings.scala35
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala4
-rw-r--r--src/reflect/scala/reflect/macros/Context.scala2
-rw-r--r--src/reflect/scala/reflect/macros/Infrastructure.scala19
-rw-r--r--src/reflect/scala/reflect/macros/Settings.scala36
-rw-r--r--src/reflect/scala/reflect/macros/Universe.scala3
8 files changed, 38 insertions, 79 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)
diff --git a/src/reflect/scala/reflect/macros/Context.scala b/src/reflect/scala/reflect/macros/Context.scala
index 1d49cc48c1..7a365ed37b 100644
--- a/src/reflect/scala/reflect/macros/Context.scala
+++ b/src/reflect/scala/reflect/macros/Context.scala
@@ -10,7 +10,7 @@ trait Context extends Aliases
with Names
with Reifiers
with FrontEnds
- with Settings
+ with Infrastructure
with Typers
with Parsers
with Evals
diff --git a/src/reflect/scala/reflect/macros/Infrastructure.scala b/src/reflect/scala/reflect/macros/Infrastructure.scala
new file mode 100644
index 0000000000..a1ef1c87a3
--- /dev/null
+++ b/src/reflect/scala/reflect/macros/Infrastructure.scala
@@ -0,0 +1,19 @@
+package scala.reflect
+package macros
+
+trait Infrastructure {
+ self: Context =>
+
+ /** Exposes macro-specific settings as a list of strings.
+ * These settings are passed to the compiler via the "-Xmacro-settings:setting1,setting2...,settingN" command-line option.
+ */
+ def settings: List[String]
+
+ /** Exposes current compiler settings as a list of options.
+ * Use `scalac -help`, `scalac -X` and `scalac -Y` to learn about currently supported options.
+ */
+ def compilerSettings: List[String]
+
+ /** Exposes current classpath. */
+ def classPath: List[java.net.URL]
+} \ No newline at end of file
diff --git a/src/reflect/scala/reflect/macros/Settings.scala b/src/reflect/scala/reflect/macros/Settings.scala
deleted file mode 100644
index a2cdb4c8e1..0000000000
--- a/src/reflect/scala/reflect/macros/Settings.scala
+++ /dev/null
@@ -1,36 +0,0 @@
-package scala.reflect
-package macros
-
-trait Settings {
- self: Context =>
-
- /** Exposes macro-specific settings as a list of strings.
- * These settings are passed to the compiler via the "-Xmacro-settings:setting1,setting2...,settingN" command-line option.
- */
- def settings: List[String]
-
- /** Exposes current compiler settings as a list of options.
- * Use `scalac -help`, `scalac -X` and `scalac -Y` to learn about currently supported options.
- */
- def compilerSettings: List[String]
-
- /** Updates current compiler settings with an option string.
- * Use `scalac -help`, `scalac -X` and `scalac -Y` to learn about currently supported options.
- */
- def setCompilerSettings(options: String): this.type
-
- /** Updates current compiler settings with a list of options.
- * Use `scalac -help`, `scalac -X` and `scalac -Y` to learn about currently supported options.
- */
- def setCompilerSettings(options: List[String]): this.type
-
- /** Temporarily sets compiler settings to a given option string and executes a given closure.
- * Use `scalac -help`, `scalac -X` and `scalac -Y` to learn about currently supported options.
- */
- def withCompilerSettings[T](options: String)(op: => T): T
-
- /** Temporarily sets compiler settings to a given list of options and executes a given closure.
- * Use `scalac -help`, `scalac -X` and `scalac -Y` to learn about currently supported options.
- */
- def withCompilerSettings[T](options: List[String])(op: => T): T
-} \ No newline at end of file
diff --git a/src/reflect/scala/reflect/macros/Universe.scala b/src/reflect/scala/reflect/macros/Universe.scala
index 0aa3e1fa6a..97d0a8d98a 100644
--- a/src/reflect/scala/reflect/macros/Universe.scala
+++ b/src/reflect/scala/reflect/macros/Universe.scala
@@ -135,9 +135,6 @@ abstract class Universe extends scala.reflect.api.Universe {
/** All units of work comprising this compilation run. */
def units: Iterator[CompilationUnit]
-
- /** Classpath of this compilation run. */
- def classPath: List[java.net.URL]
}
type CompilationUnit <: CompilationUnitContextApi