summaryrefslogtreecommitdiff
path: root/chiselFrontend/src/main
diff options
context:
space:
mode:
authorAndrew Waterman2016-07-01 11:54:49 -0700
committerAndrew Waterman2016-07-01 11:55:33 -0700
commit378edecbf797f19cf26f5a4d6a3ed3df701ba66d (patch)
tree314cd760a1d6ec1b8380fc83dd706cb0a85540e7 /chiselFrontend/src/main
parentbc3813ebd752646a92987c74136bb2adb476b687 (diff)
Reflectively name Module fields declared in superclasses
Closes #229 h/t @sdtwigg @davidbiancolin
Diffstat (limited to 'chiselFrontend/src/main')
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/Module.scala8
1 files changed, 6 insertions, 2 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Module.scala b/chiselFrontend/src/main/scala/chisel3/core/Module.scala
index 7032e762..cde7032d 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/Module.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/Module.scala
@@ -2,7 +2,7 @@
package chisel3.core
-import scala.collection.mutable.{ArrayBuffer, HashSet}
+import scala.collection.mutable.ArrayBuffer
import scala.language.experimental.macros
import chisel3.internal._
@@ -96,7 +96,11 @@ extends HasId {
}
// Suggest names to nodes using runtime reflection
- val valNames = HashSet[String](getClass.getDeclaredFields.map(_.getName):_*)
+ def getValNames(c: Class[_]): Set[String] = {
+ if (c == classOf[Module]) Set()
+ else getValNames(c.getSuperclass) ++ c.getDeclaredFields.map(_.getName)
+ }
+ val valNames = getValNames(this.getClass)
def isPublicVal(m: java.lang.reflect.Method) =
m.getParameterTypes.isEmpty && valNames.contains(m.getName)
val methods = getClass.getMethods.sortWith(_.getName > _.getName)