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. This code is not likely to be exercised. 656 # See comment in add_child. |
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. |
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 --- |