1.1 --- a/micropython/trans.py Fri Apr 19 23:38:12 2013 +0200
1.2 +++ b/micropython/trans.py Sat Apr 20 00:59:58 2013 +0200
1.3 @@ -251,33 +251,18 @@
1.4 # Attempt to deduce the target of an attribute access by searching for a
1.5 # unique type providing the names associated with the accessed object.
1.6
1.7 - elif self.optimiser.should_optimise_accesses_by_attribute_usage():
1.8 -
1.9 - target_names = self.possible_accessor_types(node)
1.10 -
1.11 - if target_names is not None and len(target_names) == 1:
1.12 - target_name, is_static = list(target_names)[0]
1.13 -
1.14 - # Check for class.__class__.
1.15 + elif self.optimiser.should_optimise_accesses_by_attribute_usage() and \
1.16 + isinstance(node, compiler.ast.AttributeAccessor):
1.17
1.18 - if attrname == "__class__":
1.19 - if is_static:
1.20 - self.load_builtin("type", node)
1.21 - return
1.22 -
1.23 - # Access the object table to get the attribute.
1.24 + targets = self.possible_accessors_from_usage(node)
1.25
1.26 - try:
1.27 - attr = self.objtable.access(target_name, attrname)
1.28 -
1.29 - # Disallow non-class/instance optimisations.
1.30 -
1.31 - except TableError, exc:
1.32 - print "Possible optimisation for", target_name, "not permissable."
1.33 + if targets and len(targets) == 1:
1.34 + target = list(targets)[0]
1.35 + attr = target.all_attributes().get(attrname)
1.36
1.37 # Produce a suitable instruction.
1.38
1.39 - else:
1.40 + if attr:
1.41 if AddressContextCondInstruction is not None and attr.is_static_attribute():
1.42 self.new_op(AddressContextCondInstruction(attr))
1.43 elif AttrInstruction is not None and not attr.is_static_attribute():