Python: Make the All proxy traverse SimObject children as well
authorAndreas Hansson <andreas.hansson@arm.com>
Thu, 5 Apr 2012 14:44:35 +0000 (10:44 -0400)
committerAndreas Hansson <andreas.hansson@arm.com>
Thu, 5 Apr 2012 14:44:35 +0000 (10:44 -0400)
This patch changes the behaviour of the All proxy parameter to not
only consider the direct children, but also do a pre-order depth-first
traversal of the object tree and append all results from the
children.

This is used in a later patch to find all the memories in the system,
independent of where they are located in the hierarchy.

src/python/m5/SimObject.py
src/python/m5/proxy.py

index 8c14be28730acc8cd22c0b6cbf5b6312c5bb1cba..c1f0ff63ee1642bad65595d4c42b5e3b8c964e47 100644 (file)
@@ -865,6 +865,10 @@ class SimObject(object):
             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):
index a2926589293f66ab9d6a3ca73390ab1a1d63de86..8c1a46909cb6dc9141a71896bd0de02b5f474625 100644 (file)
@@ -184,6 +184,8 @@ class AnyProxy(BaseProxy):
     def path(self):
         return 'any'
 
+# The AllProxy traverses the entire sub-tree (not only the children)
+# and adds all objects of a specific type
 class AllProxy(BaseProxy):
     def find(self, obj):
         return obj.find_all(self._pdesc.ptype)