From 8d2fff4eff3ba0f92437b290985b35afbb0ed565 Mon Sep 17 00:00:00 2001 From: ducky Date: Wed, 1 Feb 2017 16:07:09 -0800 Subject: Name all the things --- .../internal/sourceinfo/NamingAnnotations.scala | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'coreMacros/src') diff --git a/coreMacros/src/main/scala/chisel3/internal/sourceinfo/NamingAnnotations.scala b/coreMacros/src/main/scala/chisel3/internal/sourceinfo/NamingAnnotations.scala index 1f7c1cac..952e9f91 100644 --- a/coreMacros/src/main/scala/chisel3/internal/sourceinfo/NamingAnnotations.scala +++ b/coreMacros/src/main/scala/chisel3/internal/sourceinfo/NamingAnnotations.scala @@ -82,9 +82,12 @@ class NamingTransforms(val c: Context) { tree // don't recurse into inner classes case q"$mods def $tname[..$tparams](...$paramss): $tpt = $expr" => { val Modifiers(_, _, annotations) = mods + // don't apply naming transform twice val containsChiselName = annotations.map({q"new chiselName()" equalsStructure _}).fold(false)({_||_}) - if (containsChiselName) { - tree // don't apply the transform multiple times + // transforming overloaded initializers causes errors, and the transform isn't helpful + val isInitializer = tname == TermName("") + if (containsChiselName || isInitializer) { + tree } else { // apply chiselName transform by default val transformedExpr = transformHierarchicalMethod(expr) @@ -178,3 +181,16 @@ class NamingTransforms(val c: Context) { q"..$transformed" } } + +@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 +} -- cgit v1.2.3