summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorRichard Lin2017-01-25 21:02:04 -0800
committerJack Koenig2017-01-25 21:02:04 -0800
commitfa395b4c22f75d66047c1e835413beb612bc31d3 (patch)
treeffe080afef6e77126ad80e4a11340383cff55b2e /src/main
parent2e6444cc55b54b59f781a14823e219d9a2413f72 (diff)
Better name propagation by macros (#327)
* Name propagation * chiselName everywhere at best-effort level * Better collision handling * Allow recursing into inner anonymous functions * Add for loop and anonymous inner function tests
Diffstat (limited to 'src/main')
-rw-r--r--src/main/scala/chisel3/compatibility.scala27
-rw-r--r--src/main/scala/chisel3/package.scala17
2 files changed, 44 insertions, 0 deletions
diff --git a/src/main/scala/chisel3/compatibility.scala b/src/main/scala/chisel3/compatibility.scala
index abbe8ffe..a919e3b9 100644
--- a/src/main/scala/chisel3/compatibility.scala
+++ b/src/main/scala/chisel3/compatibility.scala
@@ -6,6 +6,10 @@
package object Chisel { // scalastyle:ignore package.object.name
import chisel3.internal.firrtl.Width
+ import scala.language.experimental.macros
+ import scala.annotation.StaticAnnotation
+ import scala.annotation.compileTimeOnly
+
implicit val defaultCompileOptions = chisel3.core.ExplicitCompileOptions.NotStrict
type Direction = chisel3.core.Direction
@@ -333,4 +337,27 @@ package object Chisel { // scalastyle:ignore package.object.name
val Pipe = chisel3.util.Pipe
type Pipe[T <: Data] = chisel3.util.Pipe[T]
+
+ /** Package for experimental features, which may have their API changed, be removed, etc.
+ *
+ * Because its contents won't necessarily have the same level of stability and support as
+ * non-experimental, you must explicitly import this package to use its contents.
+ */
+ object experimental {
+ import scala.annotation.StaticAnnotation
+ import scala.annotation.compileTimeOnly
+
+ @compileTimeOnly("enable macro paradise to expand macro annotations")
+ class dump extends StaticAnnotation {
+ def macroTransform(annottees: Any*): Any = macro chisel3.internal.naming.DebugTransforms.dump
+ }
+ @compileTimeOnly("enable macro paradise to expand macro annotations")
+ class treedump extends StaticAnnotation {
+ def macroTransform(annottees: Any*): Any = macro chisel3.internal.naming.DebugTransforms.treedump
+ }
+ @compileTimeOnly("enable macro paradise to expand macro annotations")
+ class chiselName extends StaticAnnotation {
+ def macroTransform(annottees: Any*): Any = macro chisel3.internal.naming.NamingTransforms.chiselName
+ }
+ }
}
diff --git a/src/main/scala/chisel3/package.scala b/src/main/scala/chisel3/package.scala
index cba8dffe..109bd14e 100644
--- a/src/main/scala/chisel3/package.scala
+++ b/src/main/scala/chisel3/package.scala
@@ -285,5 +285,22 @@ package object chisel3 { // scalastyle:ignore package.object.name
*/
def range(args: Any*): (NumericBound[Int], NumericBound[Int]) = macro chisel3.internal.RangeTransform.apply
}
+
+ import scala.language.experimental.macros
+ import scala.annotation.StaticAnnotation
+ import scala.annotation.compileTimeOnly
+
+ @compileTimeOnly("enable macro paradise to expand macro annotations")
+ class dump extends StaticAnnotation {
+ def macroTransform(annottees: Any*): Any = macro chisel3.internal.naming.DebugTransforms.dump
+ }
+ @compileTimeOnly("enable macro paradise to expand macro annotations")
+ class treedump extends StaticAnnotation {
+ def macroTransform(annottees: Any*): Any = macro chisel3.internal.naming.DebugTransforms.treedump
+ }
+ @compileTimeOnly("enable macro paradise to expand macro annotations")
+ class chiselName extends StaticAnnotation {
+ def macroTransform(annottees: Any*): Any = macro chisel3.internal.naming.NamingTransforms.chiselName
+ }
}
}