summaryrefslogtreecommitdiff
path: root/src/compiler/scala/reflect/makro/runtime/Settings.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/scala/reflect/makro/runtime/Settings.scala')
-rw-r--r--src/compiler/scala/reflect/makro/runtime/Settings.scala36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/compiler/scala/reflect/makro/runtime/Settings.scala b/src/compiler/scala/reflect/makro/runtime/Settings.scala
new file mode 100644
index 0000000000..32f7115db8
--- /dev/null
+++ b/src/compiler/scala/reflect/makro/runtime/Settings.scala
@@ -0,0 +1,36 @@
+package scala.reflect.makro
+package runtime
+
+trait Settings {
+ self: Context =>
+
+ def settings: List[String] = {
+ val optionName = mirror.settings.XmacroSettings.name
+ val settings = compilerSettings.find(opt => opt.startsWith(optionName)).map(opt => opt.substring(optionName.length + 1)).getOrElse("")
+ settings.split(",").toList
+ }
+
+ def compilerSettings: List[String] = mirror.settings.recreateArgs
+
+ def setCompilerSettings(options: String): this.type =
+ // todo. is not going to work with quoted arguments with embedded whitespaces
+ setCompilerSettings(options.split(" ").toList)
+
+ def setCompilerSettings(options: List[String]): this.type = {
+ val settings = new tools.nsc.Settings(_ => ())
+ // [Eugene] what settings should we exclude?
+ settings.copyInto(mirror.settings)
+ this
+ }
+
+ def withCompilerSettings[T](options: String)(op: => T): T =
+ // todo. is not going to work with quoted arguments with embedded 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)
+ }
+} \ No newline at end of file