1.1 --- a/micropython/trans.py Sun Feb 21 22:26:08 2010 +0100
1.2 +++ b/micropython/trans.py Tue Feb 23 01:30:51 2010 +0100
1.3 @@ -315,37 +315,13 @@
1.4
1.5 for name, names_used in node._attrnames.items():
1.6
1.7 - # Consider alternatives.
1.8 -
1.9 - if node._alternative_attrnames.has_key(name):
1.10 - all_names_used = set()
1.11 - all_names_used.update(node._alternative_attrnames[name])
1.12 - all_names_used.add(tuple(names_used))
1.13 - else:
1.14 - all_names_used = [names_used]
1.15 -
1.16 # Get the names of all object types supporting these names.
1.17
1.18 - targets = set()
1.19 - common_targets = None
1.20 -
1.21 - for names_used in all_names_used:
1.22 - found_targets = self.objtable.all_possible_objects_plus_status(names_used)
1.23 - found_target_names = [target_name for (target_name, is_static) in found_targets]
1.24 - targets.update(found_targets)
1.25 -
1.26 - if common_targets is None:
1.27 - common_targets = set(found_target_names)
1.28 - else:
1.29 - common_targets.intersection_update(found_target_names)
1.30 -
1.31 - # Report cases where no common targets can be found.
1.32 -
1.33 - if not common_targets:
1.34 - raise TranslateError(self.module.full_name(), node, "No common types found for expected attribute usage.")
1.35 + targets = self.objtable.all_possible_objects_plus_status(names_used)
1.36 + #found_target_names = [target_name for (target_name, is_static) in targets]
1.37
1.38 # NOTE: Need to merge targets using the same type but suggesting
1.39 - # NOTE: different kinds of attributes.
1.40 + # NOTE: different kinds of attributes (instance vs. class).
1.41
1.42 # Where only one object type is suggested, produce a guard.
1.43 # NOTE: This only supports classes as types, not modules.
1.44 @@ -534,16 +510,17 @@
1.45
1.46 # Attempt to deduce the target of an attribute access by searching for a
1.47 # unique type providing the names associated with the accessed object.
1.48 - # NOTE: This should re-use type information defined at assignment
1.49 - # NOTE: locations.
1.50
1.51 elif self.optimiser.should_optimise_accesses_by_attribute_usage():
1.52
1.53 - if hasattr(node, "_attrnames"):
1.54 - target_names = self.objtable.all_possible_objects(node._attrnames)
1.55 + if hasattr(node, "_attrusers"):
1.56 + target_names = set()
1.57 +
1.58 + for user in node._attrusers:
1.59 + target_names.update(self.objtable.all_possible_objects(user._attrnames[node._username]))
1.60
1.61 if len(target_names) == 1:
1.62 - target_name = target_names[0]
1.63 + target_name = list(target_names)[0]
1.64
1.65 # Access the object table to get the attribute.
1.66