summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorHenry Cook2015-08-03 22:26:57 -0700
committerHenry Cook2015-08-03 22:26:57 -0700
commit9edc01e6843f319522ec6252b5228fea8328b6a9 (patch)
tree71fe6a2232b737931ee35a5a6ce47523428d808d /src/main
parent8e856389bd4a11f7d9a269faf32b47b5afc61a70 (diff)
improve macro hygiene
Diffstat (limited to 'src/main')
-rw-r--r--src/main/scala/Chisel/utils.scala7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/main/scala/Chisel/utils.scala b/src/main/scala/Chisel/utils.scala
index 6d073e3d..b0255ef9 100644
--- a/src/main/scala/Chisel/utils.scala
+++ b/src/main/scala/Chisel/utils.scala
@@ -4,7 +4,7 @@ import scala.math._
import scala.language.reflectiveCalls
import scala.language.experimental.macros
import scala.reflect.runtime.universe._
-import scala.reflect.macros.whitebox._
+import scala.reflect.macros.blackbox._
object log2Up
{
@@ -143,13 +143,14 @@ object is { // Begin deprecation of non-type-parameterized is statements.
object switch {
def apply[T <: Bits](cond: T)(x: => Unit): Unit = macro impl
def impl(c: Context)(cond: c.Tree)(x: c.Tree) = { import c.universe._
+ val sc = c.universe.internal.reificationSupport.freshTermName("sc")
def extractIsStatement(tree: Tree): List[c.universe.Tree] = tree match {
- case q"Chisel.is.apply( ..$params )( ..$body )" => List(q"sc.is( ..$params )( ..$body )")
+ case q"Chisel.is.apply( ..$params )( ..$body )" => List(q"$sc.is( ..$params )( ..$body )")
case b => throw new Exception(s"Cannot include blocks that do not begin with is() in switch.")
}
val q"..$body" = x
val ises = body.flatMap(extractIsStatement(_))
- q"""{ val sc = new SwitchContext($cond); ..$ises }"""
+ q"""{ val $sc = new SwitchContext($cond); ..$ises }"""
}
}