1.1 --- a/micropython/ast.py Mon May 05 00:43:26 2008 +0200
1.2 +++ b/micropython/ast.py Mon May 05 00:46:38 2008 +0200
1.3 @@ -89,7 +89,6 @@
1.4
1.5 self.code = None
1.6 self.temp_position = 0
1.7 - self.capture_start = None
1.8
1.9 def calculate_stack_usage(self):
1.10 max_stack_usage = 0
1.11 @@ -214,31 +213,23 @@
1.12
1.13 del self.code[-n:]
1.14
1.15 - def last_ops(self, n, ops=None):
1.16 + def last_ops(self, n):
1.17
1.18 "Return the last 'n' added instructions in reverse chronological order."
1.19
1.20 - ops = (ops or self.code)[-n:]
1.21 + ops = self.code[-n:]
1.22 ops.reverse()
1.23 return ops
1.24
1.25 - def last_op(self, ops=None):
1.26 + def last_op(self):
1.27
1.28 "Return the last added instruction."
1.29
1.30 try:
1.31 - return (ops or self.code)[-1]
1.32 + return self.code[-1]
1.33 except IndexError:
1.34 return None
1.35
1.36 - def capture_ops(self):
1.37 - self.capture_start = len(self.code)
1.38 -
1.39 - def get_captured_ops(self):
1.40 - l = self.code[self.capture_start:]
1.41 - del self.code[self.capture_start:]
1.42 - return l
1.43 -
1.44 # Internal helper methods.
1.45
1.46 def _visitAttr(self, node, classes):
1.47 @@ -578,13 +569,13 @@
1.48 def _should_optimise_temp_storage(self):
1.49 return "temp_storage" in self.optimisations
1.50
1.51 - def _have_constant_input(self, n, ops=None):
1.52 - last = self.last_ops(n+1, ops)
1.53 + def _have_constant_input(self, n):
1.54 + last = self.last_ops(n+1)
1.55 return len(last) > n and (isinstance(last[n], LoadAddress) and last[n].attr.assignments == 1 or
1.56 isinstance(last[n], LoadConst)) # and not isinstance(last[n].attr, micropython.inspect.Instance)
1.57
1.58 - def _have_known_target(self, ops=None):
1.59 - return self._have_constant_input(0, ops)
1.60 + def _have_known_target(self):
1.61 + return self._have_constant_input(0)
1.62
1.63 def _have_self_input(self):
1.64 last = self.last_op()
1.65 @@ -660,7 +651,7 @@
1.66 else:
1.67 return 0
1.68
1.69 - def _optimise_known_target(self, ops=None):
1.70 + def _optimise_known_target(self):
1.71
1.72 """
1.73 Where the target of an invocation is known, provide information about it
1.74 @@ -668,8 +659,8 @@
1.75 appropriate, get information about the specific initialiser.
1.76 """
1.77
1.78 - if self._should_optimise_known_target() and self._have_known_target(ops):
1.79 - last = self.last_op(ops)
1.80 + if self._should_optimise_known_target() and self._have_known_target():
1.81 + last = self.last_op()
1.82 target = last.attr.value
1.83 context = last.attr.parent
1.84