1.1 --- a/micropython/opt.py Sun Sep 28 21:42:03 2008 +0200
1.2 +++ b/micropython/opt.py Sun Sep 28 21:54:03 2008 +0200
1.3 @@ -238,12 +238,15 @@
1.4
1.5 return self.is_input(self.active_value)
1.6
1.7 - def have_self_input(self):
1.8 + def have_self_input(self, unit):
1.9
1.10 - "Return whether the active instruction is a reference to self."
1.11 + """
1.12 + Return whether the active instruction is a reference to self in the
1.13 + given 'unit'.
1.14 + """
1.15
1.16 - return isinstance(self.translation.unit, Function) and \
1.17 - self.translation.unit.is_method() and isinstance(self.active_value, LoadName) and \
1.18 + return isinstance(unit, Function) and \
1.19 + unit.is_method() and isinstance(self.active_value, LoadName) and \
1.20 self.active_value.attr.name == "self"
1.21
1.22 def have_temp_compatible_access(self):
1.23 @@ -260,13 +263,13 @@
1.24 isinstance(self.active_value, LoadResult) and self.active_value is self.active or \
1.25 isinstance(self.active_value, LoadException) and self.active_value is self.active
1.26
1.27 - def have_correct_self_for_target(self, context):
1.28 + def have_correct_self_for_target(self, context, unit):
1.29
1.30 - "Return whether the 'context' is compatible with the current value."
1.31 + "Return whether the 'context' is compatible with the given 'unit'."
1.32
1.33 - if context is not None and self.have_self_input():
1.34 + if context is not None and self.have_self_input(unit):
1.35
1.36 - parent = self.translation.unit.parent
1.37 + parent = unit.parent
1.38 if parent is context or parent.has_subclass(context) or context.has_subclass(parent):
1.39 return 1
1.40
1.41 @@ -338,7 +341,7 @@
1.42 """
1.43
1.44 return self.should_optimise_self_access() and \
1.45 - self.have_self_input() and not unit.is_relocated(attrname)
1.46 + self.have_self_input(unit) and not unit.is_relocated(attrname)
1.47
1.48 def optimise_temp_storage(self):
1.49