1.1 --- a/simplify/fixinstances.py Sat Jun 23 01:57:13 2007 +0200
1.2 +++ b/simplify/fixinstances.py Sat Jun 23 21:10:01 2007 +0200
1.3 @@ -174,6 +174,12 @@
1.4 return node
1.5
1.6 def _replace(self, items, name=None):
1.7 +
1.8 + """
1.9 + Produce a new list or set for the given 'items', acquired from the
1.10 + annotation having the given 'name'.
1.11 + """
1.12 +
1.13 if name == "accesses":
1.14 new_items = []
1.15 else:
1.16 @@ -192,9 +198,29 @@
1.17 return new_items
1.18
1.19 def _get_replacement(self, value):
1.20 +
1.21 + "Get a replacement for the given 'value'."
1.22 +
1.23 + # Find the distinct instance for any given instance.
1.24 +
1.25 if isinstance(value, Instance):
1.26 distinct_instances = value.get_class().get_distinct_instances()
1.27 return distinct_instances[value]
1.28 +
1.29 + # For subprograms, find the distinct instance's copy for the owner
1.30 + # instance; otherwise, return the original subprogram.
1.31 +
1.32 + elif isinstance(value, Subprogram):
1.33 + if hasattr(value, "copy_of") and hasattr(value, "instance"):
1.34 + cls = value.instance.get_class()
1.35 + distinct = cls.get_distinct_instances()
1.36 + instance = distinct[value.instance]
1.37 + return value.copy_of.copies.get(instance, value)
1.38 + else:
1.39 + return value
1.40 +
1.41 + # Return all other values as they are.
1.42 +
1.43 else:
1.44 return value
1.45