1.1 --- a/micropython/opt.py Sat Feb 28 19:40:15 2009 +0100
1.2 +++ b/micropython/opt.py Mon Mar 02 00:04:55 2009 +0100
1.3 @@ -307,9 +307,11 @@
1.4 if isinstance(value.attr, Const):
1.5 target_name = value.attr.value_type_name()
1.6 else:
1.7 - target = value.attr.value
1.8 + target = value.attr.get_value()
1.9
1.10 - if isinstance(target, Const):
1.11 + if target is None:
1.12 + return None # no clearly defined target
1.13 + elif isinstance(target, Const):
1.14 return target.value_type_name()
1.15 elif isinstance(target, Instance):
1.16 return None # skip production of optimised code
1.17 @@ -329,12 +331,15 @@
1.18
1.19 if self.should_optimise_known_target() and self.have_known_target():
1.20 value = self.active_value
1.21 - target = value.attr.value
1.22 - context = value.attr.context
1.23 + target = value.attr.get_value()
1.24 + context = value.attr.get_context()
1.25 +
1.26 + # Return target details only if this is clearly defined.
1.27
1.28 - return target, context
1.29 - else:
1.30 - return None
1.31 + if target is not None:
1.32 + return target, context
1.33 +
1.34 + return None
1.35
1.36 def optimise_self_access(self, unit, attrname):
1.37