# HG changeset patch # User Paul Boddie # Date 1209941198 -7200 # Node ID 5790cc867f93d2fcd1518c5e01cbba66349699e1 # Parent 6040897ede2c30c7ad0cb3ce7c476c3e3cdbdd42 Reverted earlier changes around captured sequences of instructions and support for alternative sequences in certain methods. diff -r 6040897ede2c -r 5790cc867f93 micropython/ast.py --- a/micropython/ast.py Mon May 05 00:43:26 2008 +0200 +++ b/micropython/ast.py Mon May 05 00:46:38 2008 +0200 @@ -89,7 +89,6 @@ self.code = None self.temp_position = 0 - self.capture_start = None def calculate_stack_usage(self): max_stack_usage = 0 @@ -214,31 +213,23 @@ del self.code[-n:] - def last_ops(self, n, ops=None): + def last_ops(self, n): "Return the last 'n' added instructions in reverse chronological order." - ops = (ops or self.code)[-n:] + ops = self.code[-n:] ops.reverse() return ops - def last_op(self, ops=None): + def last_op(self): "Return the last added instruction." try: - return (ops or self.code)[-1] + return self.code[-1] except IndexError: return None - def capture_ops(self): - self.capture_start = len(self.code) - - def get_captured_ops(self): - l = self.code[self.capture_start:] - del self.code[self.capture_start:] - return l - # Internal helper methods. def _visitAttr(self, node, classes): @@ -578,13 +569,13 @@ def _should_optimise_temp_storage(self): return "temp_storage" in self.optimisations - def _have_constant_input(self, n, ops=None): - last = self.last_ops(n+1, ops) + def _have_constant_input(self, n): + last = self.last_ops(n+1) return len(last) > n and (isinstance(last[n], LoadAddress) and last[n].attr.assignments == 1 or isinstance(last[n], LoadConst)) # and not isinstance(last[n].attr, micropython.inspect.Instance) - def _have_known_target(self, ops=None): - return self._have_constant_input(0, ops) + def _have_known_target(self): + return self._have_constant_input(0) def _have_self_input(self): last = self.last_op() @@ -660,7 +651,7 @@ else: return 0 - def _optimise_known_target(self, ops=None): + def _optimise_known_target(self): """ Where the target of an invocation is known, provide information about it @@ -668,8 +659,8 @@ appropriate, get information about the specific initialiser. """ - if self._should_optimise_known_target() and self._have_known_target(ops): - last = self.last_op(ops) + if self._should_optimise_known_target() and self._have_known_target(): + last = self.last_op() target = last.attr.value context = last.attr.parent