Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support using switch without importing SwitchContext #1595

Merged
merged 1 commit into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/src/wiki-deprecated/cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ State transitions are then handled with [`switch`](https://www.chisel-lang.org/a

```scala mdoc:silent:reset
import chisel3._
import chisel3.util._
import chisel3.util.{switch, is}
import chisel3.experimental.ChiselEnum

object DetectTwoOnes {
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/chisel3/util/Conditional.scala
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ object switch {
def apply[T <: Element](cond: T)(x: => Any): Unit = macro impl
def impl(c: Context)(cond: c.Tree)(x: c.Tree): c.Tree = { import c.universe._
val q"..$body" = x
val res = body.foldLeft(q"""new SwitchContext($cond, None, Set.empty)""") {
val res = body.foldLeft(q"""new chisel3.util.SwitchContext($cond, None, Set.empty)""") {
case (acc, tree) => tree match {
// TODO: remove when Chisel compatibility package is removed
case q"Chisel.`package`.is.apply( ..$params )( ..$body )" => q"$acc.is( ..$params )( ..$body )"
Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/chiselTests/SwitchSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package chiselTests

import chisel3._
import chisel3.stage.ChiselStage
import chisel3.util._
import chisel3.util.{switch, is}

class SwitchSpec extends ChiselFlatSpec with Utils {
"switch" should "require literal conditions" in {
Expand Down