diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2012-11-24 00:21:41 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2012-11-24 00:21:41 +0100 |
commit | 3ef2995f0923fe7b2346cfd5f816196fce0f00ac (patch) | |
tree | da98967ccca117a452069fd8c117f4caecf64907 /src/main | |
parent | 08bd93c20bcdd1bddc172c1477e811e8fc7f8ebd (diff) | |
download | scala-async-3ef2995f0923fe7b2346cfd5f816196fce0f00ac.tar.gz scala-async-3ef2995f0923fe7b2346cfd5f816196fce0f00ac.tar.bz2 scala-async-3ef2995f0923fe7b2346cfd5f816196fce0f00ac.zip |
Prohibit await in if condition (for now)
Test nested loops.
Control ANF tracing with another system property.
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/scala/scala/async/AnfTransform.scala | 4 | ||||
-rw-r--r-- | src/main/scala/scala/async/AsyncAnalysis.scala | 4 | ||||
-rw-r--r-- | src/main/scala/scala/async/AsyncUtils.scala | 12 |
3 files changed, 14 insertions, 6 deletions
diff --git a/src/main/scala/scala/async/AnfTransform.scala b/src/main/scala/scala/async/AnfTransform.scala index 0756baf..cf6ed04 100644 --- a/src/main/scala/scala/async/AnfTransform.scala +++ b/src/main/scala/scala/async/AnfTransform.scala @@ -77,9 +77,9 @@ private[async] final case class AnfTransform[C <: Context](override val c: C) ex def apply[T](prefix: String, args: Any)(t: => T): T = { indent += 1 try { - //println(s"${indentString}$prefix($args)") + AsyncUtils.trace(s"${indentString}$prefix($args)") val result = t - //println(s"${indentString}= $result") + AsyncUtils.trace(s"${indentString}= $result") result } finally { indent -= 1 diff --git a/src/main/scala/scala/async/AsyncAnalysis.scala b/src/main/scala/scala/async/AsyncAnalysis.scala index e319fe8..c1ee7f4 100644 --- a/src/main/scala/scala/async/AsyncAnalysis.scala +++ b/src/main/scala/scala/async/AsyncAnalysis.scala @@ -62,6 +62,10 @@ private[async] final case class AsyncAnalysis[C <: Context](override val c: C) e tree match { case Try(_, _, _) if containsAwait => reportUnsupportedAwait(tree, "try/catch") + super.traverse(tree) + case If(cond, _, _) if containsAwait => + reportUnsupportedAwait(cond, "condition") + super.traverse(tree) case Return(_) => c.abort(tree.pos, "return is illegal within a async block") case _ => diff --git a/src/main/scala/scala/async/AsyncUtils.scala b/src/main/scala/scala/async/AsyncUtils.scala index b2f6747..525f187 100644 --- a/src/main/scala/scala/async/AsyncUtils.scala +++ b/src/main/scala/scala/async/AsyncUtils.scala @@ -8,8 +8,12 @@ package scala.async */ object AsyncUtils { - private val verbose = false || sys.props.getOrElse("scala.async.debug", "false").equalsIgnoreCase("true") - - private[async] def vprintln(s: => Any): Unit = if (verbose) - println("[async] "+s) + private def enabled(level: String) = sys.props.getOrElse(s"scala.async.$level", "false").equalsIgnoreCase("true") + + private val verbose = enabled("debug") + private val trace = enabled("trace") + + private[async] def vprintln(s: => Any): Unit = if (verbose) println(s"[async] $s") + + private[async] def trace(s: => Any): Unit = if (trace) println(s"[async] $s") } |