config: Traverse lists when visiting children in all proxy
authorAndreas Hansson <andreas.hansson@arm.com>
Mon, 7 Jan 2013 18:05:38 +0000 (13:05 -0500)
committerAndreas Hansson <andreas.hansson@arm.com>
Mon, 7 Jan 2013 18:05:38 +0000 (13:05 -0500)
This patch makes the all proxy traverse any potential list that is
encountered in the object hierarchy instead of only looking at
children that are SimObjects. An example of where this is useful is
when creating a multi-channel memory system as a list of controllers,
whilst ensuring that the memories are still visible in the system.

src/python/m5/SimObject.py

index 9f43fc70c4affeac2ae1be17368bee03d780cda3..5db33d4bc25cae069eb5fc879ec594dbeb1f37aa 100644 (file)
@@ -872,13 +872,20 @@ class SimObject(object):
         all = {}
         # search children
         for child in self._children.itervalues():
-            if isinstance(child, ptype) and not isproxy(child) and \
-               not isNullPointer(child):
-                all[child] = True
-            if isSimObject(child):
-                # also add results from the child itself
-                child_all, done = child.find_all(ptype)
-                all.update(dict(zip(child_all, [done] * len(child_all))))
+            # a child could be a list, so ensure we visit each item
+            if isinstance(child, list):
+                children = child
+            else:
+                children = [child]
+
+            for child in children:
+                if isinstance(child, ptype) and not isproxy(child) and \
+                        not isNullPointer(child):
+                    all[child] = True
+                if isSimObject(child):
+                    # also add results from the child itself
+                    child_all, done = child.find_all(ptype)
+                    all.update(dict(zip(child_all, [done] * len(child_all))))
         # search param space
         for pname,pdesc in self._params.iteritems():
             if issubclass(pdesc.ptype, ptype):