summaryrefslogtreecommitdiff
path: root/src/continuations
diff options
context:
space:
mode:
authorGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2013-09-12 10:26:46 -0700
committerGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2013-09-12 10:26:46 -0700
commit33a819f61b8b9c19708e8ae22bf25adf6cc7ac24 (patch)
tree30fb8d7295f359aca662eb3fb96bc9f9a0646f1f /src/continuations
parente748f2ed8fda553fd8fe36499bac63aa115a82a9 (diff)
parentdfe3fe335bf7358e04e7f422fecf16f445c14f2b (diff)
downloadscala-33a819f61b8b9c19708e8ae22bf25adf6cc7ac24.tar.gz
scala-33a819f61b8b9c19708e8ae22bf25adf6cc7ac24.tar.bz2
scala-33a819f61b8b9c19708e8ae22bf25adf6cc7ac24.zip
Merge pull request #2859 from som-snytt/issue/7622-phaser
SI-7622 Clean Up Phase Assembly
Diffstat (limited to 'src/continuations')
-rw-r--r--src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala2
-rw-r--r--src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSPlugin.scala43
2 files changed, 24 insertions, 21 deletions
diff --git a/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala b/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala
index 29480576ea..98d0695865 100644
--- a/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala
+++ b/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala
@@ -8,7 +8,7 @@ trait CPSUtils {
val global: Global
import global._
- var cpsEnabled = false
+ val cpsEnabled: Boolean
val verbose: Boolean = System.getProperty("cpsVerbose", "false") == "true"
def vprintln(x: =>Any): Unit = if (verbose) println(x)
diff --git a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSPlugin.scala b/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSPlugin.scala
index d3b02d74f4..a7e82e949b 100644
--- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSPlugin.scala
+++ b/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSPlugin.scala
@@ -11,41 +11,44 @@ class SelectiveCPSPlugin(val global: Global) extends Plugin {
val name = "continuations"
val description = "applies selective cps conversion"
- val anfPhase = new {val global = SelectiveCPSPlugin.this.global } with SelectiveANFTransform() {
+ val pluginEnabled = options contains "enable"
+
+ val anfPhase = new {
+ val global = SelectiveCPSPlugin.this.global
+ val cpsEnabled = pluginEnabled
+ override val enabled = cpsEnabled
+ } with SelectiveANFTransform {
val runsAfter = List("pickler")
}
- val cpsPhase = new {val global = SelectiveCPSPlugin.this.global } with SelectiveCPSTransform() {
+ val cpsPhase = new {
+ val global = SelectiveCPSPlugin.this.global
+ val cpsEnabled = pluginEnabled
+ override val enabled = cpsEnabled
+ } with SelectiveCPSTransform {
val runsAfter = List("selectiveanf")
override val runsBefore = List("uncurry")
}
val components = List[PluginComponent](anfPhase, cpsPhase)
- val checker = new { val global: SelectiveCPSPlugin.this.global.type = SelectiveCPSPlugin.this.global } with CPSAnnotationChecker
+ val checker = new {
+ val global: SelectiveCPSPlugin.this.global.type = SelectiveCPSPlugin.this.global
+ val cpsEnabled = pluginEnabled
+ } with CPSAnnotationChecker
+
+ // TODO don't muck up global with unused checkers
global.addAnnotationChecker(checker.checker)
global.analyzer.addAnalyzerPlugin(checker.plugin)
global.log("instantiated cps plugin: " + this)
- def setEnabled(flag: Boolean) = {
- checker.cpsEnabled = flag
- anfPhase.cpsEnabled = flag
- cpsPhase.cpsEnabled = flag
- }
-
- // TODO: require -enabled command-line flag
-
- override def processOptions(options: List[String], error: String => Unit) = {
- var enabled = false
- for (option <- options) {
- if (option == "enable") {
- enabled = true
- } else {
- error("Option not understood: "+option)
- }
+ override def init(options: List[String], error: String => Unit) = {
+ options foreach {
+ case "enable" => // in initializer
+ case arg => error(s"Bad argument: $arg")
}
- setEnabled(enabled)
+ pluginEnabled
}
override val optionsHelp: Option[String] =