# HG changeset patch # User Paul Boddie # Date 1219523537 -7200 # Node ID b62d613c3ca1c538a49de5af80b722592c2290fd # Parent 8ee002746854476408354a9ae1d13486687d225b Fixed known_target optimisation. Simplified the binary operator method invocation code slightly. diff -r 8ee002746854 -r b62d613c3ca1 micropython/ast.py --- a/micropython/ast.py Sat Aug 23 21:57:29 2008 +0200 +++ b/micropython/ast.py Sat Aug 23 22:32:17 2008 +0200 @@ -498,7 +498,7 @@ """ if self._should_optimise_known_target() and self._have_known_target(): - last = self.last_op() + last = self.active_value target = last.attr.value context = last.attr.context @@ -1249,7 +1249,6 @@ end_attempt_label = self.new_label() - self._startCallFunc() self.new_op(temp1) # Get method on temp1. @@ -1262,6 +1261,7 @@ # Add arguments. # NOTE: No support for defaults. + self._startCallFunc() self.new_op(temp1) self.new_op(StoreFrame(0)) self.new_op(temp2) @@ -1280,7 +1280,6 @@ # End method attempt. self.set_label(end_attempt_label) - self._endCallFunc(load_result=0) # From the method call. def _handleAttributeError(self, node, end_call_label): diff -r 8ee002746854 -r b62d613c3ca1 tests/compare.py --- a/tests/compare.py Sat Aug 23 21:57:29 2008 +0200 +++ b/tests/compare.py Sat Aug 23 22:32:17 2008 +0200 @@ -4,16 +4,6 @@ b = 2 c = 3 -class X: - def __contains__(self, other): - return 1 - a < b < c -x = X() - -a == x != b -a is x is not b -a in x - # vim: tabstop=4 expandtab shiftwidth=4 diff -r 8ee002746854 -r b62d613c3ca1 tests/compare2.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/compare2.py Sat Aug 23 22:32:17 2008 +0200 @@ -0,0 +1,17 @@ +#!/usr/bin/env python + +a = 1 +b = 2 +c = 3 + +class X: + def __contains__(self, other): + return 1 + +x = X() + +a == x != b +a is x is not b +a in x + +# vim: tabstop=4 expandtab shiftwidth=4