SimObject.py (7738:e2e8ca8d9640) | SimObject.py (7742:611fe187288e) |
---|---|
1# Copyright (c) 2004-2006 The Regents of The University of Michigan 2# Copyright (c) 2010 Advanced Micro Devices, Inc. 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions are 7# met: redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer; --- 638 unchanged lines hidden (view full) --- 647 def get_name(self): 648 return self._name 649 650 # use this rather than directly accessing _parent for symmetry 651 # with SimObjectVector 652 def get_parent(self): 653 return self._parent 654 | 1# Copyright (c) 2004-2006 The Regents of The University of Michigan 2# Copyright (c) 2010 Advanced Micro Devices, Inc. 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions are 7# met: redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer; --- 638 unchanged lines hidden (view full) --- 647 def get_name(self): 648 return self._name 649 650 # use this rather than directly accessing _parent for symmetry 651 # with SimObjectVector 652 def get_parent(self): 653 return self._parent 654 |
655 # clear out child with given name | 655 # clear out child with given name. This code is not likely to be exercised. 656 # See comment in add_child. |
656 def clear_child(self, name): 657 child = self._children[name] 658 child.clear_parent(self) 659 del self._children[name] 660 661 # Add a new child to this object. 662 def add_child(self, name, child): 663 child = coerceSimObjectOrVector(child) 664 if child.get_parent(): 665 raise RuntimeError, \ 666 "add_child('%s'): child '%s' already has parent '%s'" % \ 667 (name, child._name, child._parent) 668 if self._children.has_key(name): | 657 def clear_child(self, name): 658 child = self._children[name] 659 child.clear_parent(self) 660 del self._children[name] 661 662 # Add a new child to this object. 663 def add_child(self, name, child): 664 child = coerceSimObjectOrVector(child) 665 if child.get_parent(): 666 raise RuntimeError, \ 667 "add_child('%s'): child '%s' already has parent '%s'" % \ 668 (name, child._name, child._parent) 669 if self._children.has_key(name): |
670 # This code path had an undiscovered bug that would make it fail 671 # at runtime. It had been here for a long time and was only 672 # exposed by a buggy script. Changes here will probably not be 673 # exercised without specialized testing. |
|
669 self.clear_child(name) 670 child.set_parent(self, name) 671 self._children[name] = child 672 673 # Take SimObject-valued parameters that haven't been explicitly 674 # assigned as children and make them children of the object that 675 # they were assigned to as a parameter value. This guarantees 676 # that when we instantiate all the parameter objects we're still --- 295 unchanged lines hidden --- | 674 self.clear_child(name) 675 child.set_parent(self, name) 676 self._children[name] = child 677 678 # Take SimObject-valued parameters that haven't been explicitly 679 # assigned as children and make them children of the object that 680 # they were assigned to as a parameter value. This guarantees 681 # that when we instantiate all the parameter objects we're still --- 295 unchanged lines hidden --- |