summaryrefslogtreecommitdiff
path: root/chiselFrontend/src/main/scala/chisel3/core/Module.scala
diff options
context:
space:
mode:
authorAndrew Waterman2016-10-27 01:36:46 -0700
committerJack Koenig2016-10-27 01:36:46 -0700
commit5272db0bc2ab5a1653168906c636b9099a96348b (patch)
tree2d702832f4710a72eb5fc5c15386314374160eec /chiselFrontend/src/main/scala/chisel3/core/Module.scala
parent1bdce3f8784da6f75ef2121bbe8638b445ff8b5f (diff)
Refactor and fix field reflection (#342)
No more need for e.g. new Bundle { def foo(dummy: Int): Data } as now you can write new Bundle { def foo: Data } This also removes code duplication with Module. h/t @sdtwigg
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/core/Module.scala')
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/Module.scala12
1 files changed, 1 insertions, 11 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Module.scala b/chiselFrontend/src/main/scala/chisel3/core/Module.scala
index 55522b4a..c700dc1b 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/Module.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/Module.scala
@@ -162,15 +162,6 @@ extends HasId {
port.setRef(ModuleIO(this, _namespace.name(name)))
}
- // Suggest names to nodes using runtime reflection
- 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)
-
/** Recursively suggests names to supported "container" classes
* Arbitrary nestings of supported classes are allowed so long as the
* innermost element is of type HasId
@@ -189,8 +180,7 @@ extends HasId {
}
case _ => // Do nothing
}
- val methods = getClass.getMethods.sortWith(_.getName > _.getName)
- for (m <- methods if isPublicVal(m)) {
+ for (m <- getPublicFields(classOf[Module])) {
nameRecursively(m.getName, m.invoke(this))
}