1.1 --- a/micropython/ast.py Sun Sep 28 21:42:03 2008 +0200
1.2 +++ b/micropython/ast.py Sun Sep 28 21:54:03 2008 +0200
1.3 @@ -728,7 +728,7 @@
1.4
1.5 # Drop any test if the target and the context are known.
1.6
1.7 - if not self.optimiser.have_correct_self_for_target(context):
1.8 + if not self.optimiser.have_correct_self_for_target(context, self.unit):
1.9
1.10 continue_label = self.new_label()
1.11 self.new_op(CheckSelf())
2.1 --- a/micropython/opt.py Sun Sep 28 21:42:03 2008 +0200
2.2 +++ b/micropython/opt.py Sun Sep 28 21:54:03 2008 +0200
2.3 @@ -238,12 +238,15 @@
2.4
2.5 return self.is_input(self.active_value)
2.6
2.7 - def have_self_input(self):
2.8 + def have_self_input(self, unit):
2.9
2.10 - "Return whether the active instruction is a reference to self."
2.11 + """
2.12 + Return whether the active instruction is a reference to self in the
2.13 + given 'unit'.
2.14 + """
2.15
2.16 - return isinstance(self.translation.unit, Function) and \
2.17 - self.translation.unit.is_method() and isinstance(self.active_value, LoadName) and \
2.18 + return isinstance(unit, Function) and \
2.19 + unit.is_method() and isinstance(self.active_value, LoadName) and \
2.20 self.active_value.attr.name == "self"
2.21
2.22 def have_temp_compatible_access(self):
2.23 @@ -260,13 +263,13 @@
2.24 isinstance(self.active_value, LoadResult) and self.active_value is self.active or \
2.25 isinstance(self.active_value, LoadException) and self.active_value is self.active
2.26
2.27 - def have_correct_self_for_target(self, context):
2.28 + def have_correct_self_for_target(self, context, unit):
2.29
2.30 - "Return whether the 'context' is compatible with the current value."
2.31 + "Return whether the 'context' is compatible with the given 'unit'."
2.32
2.33 - if context is not None and self.have_self_input():
2.34 + if context is not None and self.have_self_input(unit):
2.35
2.36 - parent = self.translation.unit.parent
2.37 + parent = unit.parent
2.38 if parent is context or parent.has_subclass(context) or context.has_subclass(parent):
2.39 return 1
2.40
2.41 @@ -338,7 +341,7 @@
2.42 """
2.43
2.44 return self.should_optimise_self_access() and \
2.45 - self.have_self_input() and not unit.is_relocated(attrname)
2.46 + self.have_self_input(unit) and not unit.is_relocated(attrname)
2.47
2.48 def optimise_temp_storage(self):
2.49