changeset bc3a389d1e37 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=bc3a389d1e37
description:
        Python: Make the All proxy traverse SimObject children as well

        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.

diffstat:

 src/python/m5/SimObject.py |  4 ++++
 src/python/m5/proxy.py     |  2 ++
 2 files changed, 6 insertions(+), 0 deletions(-)

diffs (26 lines):

diff -r 570b44fe6e04 -r bc3a389d1e37 src/python/m5/SimObject.py
--- a/src/python/m5/SimObject.py        Tue Apr 03 03:50:14 2012 -0400
+++ b/src/python/m5/SimObject.py        Thu Apr 05 10:44:35 2012 -0400
@@ -865,6 +865,10 @@
             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):
diff -r 570b44fe6e04 -r bc3a389d1e37 src/python/m5/proxy.py
--- a/src/python/m5/proxy.py    Tue Apr 03 03:50:14 2012 -0400
+++ b/src/python/m5/proxy.py    Thu Apr 05 10:44:35 2012 -0400
@@ -184,6 +184,8 @@
     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)
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to