summaryrefslogtreecommitdiff
path: root/macros/src/main/scala/chisel3
diff options
context:
space:
mode:
Diffstat (limited to 'macros/src/main/scala/chisel3')
-rw-r--r--macros/src/main/scala/chisel3/internal/InstantiableMacro.scala34
-rw-r--r--macros/src/main/scala/chisel3/internal/sourceinfo/SourceInfoTransform.scala4
2 files changed, 23 insertions, 15 deletions
diff --git a/macros/src/main/scala/chisel3/internal/InstantiableMacro.scala b/macros/src/main/scala/chisel3/internal/InstantiableMacro.scala
index d66b51ac..a001b284 100644
--- a/macros/src/main/scala/chisel3/internal/InstantiableMacro.scala
+++ b/macros/src/main/scala/chisel3/internal/InstantiableMacro.scala
@@ -16,21 +16,25 @@ private[chisel3] object instantiableMacro {
// Note the triple `_` prefixing `module` is to avoid conflicts if a user marks a 'val module'
// with @public; in this case, the lookup code is ambiguous between the generated `def module`
// function and the argument to the generated implicit class.
- val resultStats = stats.flatMap {
- case x @ q"@public val $tpname: $tpe = $name" if tpname.toString() == name.toString() =>
- extensions += atPos(x.pos)(q"def $tpname = ___module._lookup(_.$tpname)")
- Nil
- case x @ q"@public val $tpname: $tpe = $_" =>
- extensions += atPos(x.pos)(q"def $tpname = ___module._lookup(_.$tpname)")
- Seq(x)
- case x @ q"@public val $tpname: $tpe" =>
- extensions += atPos(x.pos)(q"def $tpname = ___module._lookup(_.$tpname)")
- Seq(x)
- case x @ q"@public lazy val $tpname: $tpe = $_" =>
- extensions += atPos(x.pos)(q"def $tpname = ___module._lookup(_.$tpname)")
- Seq(x)
- case other =>
- Seq(other)
+ val resultStats = stats.flatMap { stat =>
+ stat match {
+ case hasPublic: ValOrDefDef if hasPublic.mods.annotations.toString.contains("new public()") =>
+ hasPublic match {
+ case aDef: DefDef =>
+ c.error(aDef.pos, s"Cannot mark a def as @public")
+ Nil
+ // For now, we only omit protected/private vals
+ case aVal: ValDef
+ if aVal.mods.hasFlag(c.universe.Flag.PRIVATE) || aVal.mods.hasFlag(c.universe.Flag.PROTECTED) =>
+ c.error(aVal.pos, s"Cannot mark a private or protected val as @public")
+ Nil
+ case aVal: ValDef =>
+ extensions += atPos(aVal.pos)(q"def ${aVal.name} = ___module._lookup(_.${aVal.name})")
+ if (aVal.name.toString == aVal.children.last.toString) Nil else Seq(aVal)
+ case other => Seq(other)
+ }
+ case other => Seq(other)
+ }
}
(resultStats, extensions)
}
diff --git a/macros/src/main/scala/chisel3/internal/sourceinfo/SourceInfoTransform.scala b/macros/src/main/scala/chisel3/internal/sourceinfo/SourceInfoTransform.scala
index 01e0acd6..3e310774 100644
--- a/macros/src/main/scala/chisel3/internal/sourceinfo/SourceInfoTransform.scala
+++ b/macros/src/main/scala/chisel3/internal/sourceinfo/SourceInfoTransform.scala
@@ -200,6 +200,10 @@ class SourceInfoTransform(val c: Context) extends AutoSourceTransform {
q"$thisObj.$doFuncTerm($x, $y)($implicitSourceInfo, $implicitCompileOptions)"
}
+ def xyzArg(idx: c.Tree, en: c.Tree, clock: c.Tree): c.Tree = {
+ q"$thisObj.$doFuncTerm($idx, $en, $clock)($implicitSourceInfo, $implicitCompileOptions)"
+ }
+
def xEnArg(x: c.Tree, en: c.Tree): c.Tree = {
q"$thisObj.$doFuncTerm($x, $en)($implicitSourceInfo, $implicitCompileOptions)"
}