python: remove SimObject children on NULL assignment
Before this commit, on assigning NULL to an 'attr' that is a SimObject, the corresponding children SimObject was not set to NULL. This makes some SimObject being initialized in the c++ world even if they are not needed. This commit set the children to NULL in that case. Change-Id: I2030d9d1b80c020fa28e50c0eca4f87b756763d6 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/51647 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Maintainer: Jason Lowe-Power <power.jg@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
committed by
Tom Rollet
parent
66a056b828
commit
7eb8fb927f
@@ -1443,6 +1443,12 @@ class SimObject(object, metaclass=MetaSimObject):
|
||||
e.args = (msg, )
|
||||
raise
|
||||
self._values[attr] = value
|
||||
|
||||
# If we assign NULL to an attr that is a SimObject,
|
||||
# remove the corresponding children
|
||||
if attr in self._children and isNullPointer(value):
|
||||
self.clear_child(attr)
|
||||
|
||||
# implicitly parent unparented objects assigned as params
|
||||
if isSimObjectOrVector(value) and not value.has_parent():
|
||||
self.add_child(attr, value)
|
||||
|
||||
Reference in New Issue
Block a user