From 5272db0bc2ab5a1653168906c636b9099a96348b Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Thu, 27 Oct 2016 01:36:46 -0700 Subject: 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 --- chiselFrontend/src/main/scala/chisel3/core/Module.scala | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'chiselFrontend/src/main/scala/chisel3/core/Module.scala') 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)) } -- cgit v1.2.3