[pypy-commit] pypy less-stringly-ops: Fix duplication between 'nonzero' and 'is_true' ops.

rlamy noreply at buildbot.pypy.org
Mon Aug 19 23:15:16 CEST 2013


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: less-stringly-ops
Changeset: r66240:7cb877b832f4
Date: 2013-08-19 17:42 +0100
http://bitbucket.org/pypy/pypy/changeset/7cb877b832f4/

Log:	Fix duplication between 'nonzero' and 'is_true' ops.

	Call the merged operation 'bool'.

diff --git a/rpython/annotator/argument.py b/rpython/annotator/argument.py
--- a/rpython/annotator/argument.py
+++ b/rpython/annotator/argument.py
@@ -25,7 +25,7 @@
             return [Ellipsis]
         raise CallPatternTooComplex("'*' argument must be SomeTuple")
 
-    def is_true(self, s_tup):
+    def bool(self, s_tup):
         assert isinstance(s_tup, SomeTuple)
         return bool(s_tup.items)
 
@@ -210,7 +210,7 @@
             args_w = data_args_w[:need_cnt]
             for argname, w_arg in zip(argnames[need_cnt:], data_args_w[need_cnt:]):
                 unfiltered_kwds_w[argname] = w_arg
-            assert not space.is_true(data_w_stararg)
+            assert not space.bool(data_w_stararg)
         else:
             stararg_w = space.unpackiterable(data_w_stararg)
             args_w = data_args_w + stararg_w
diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py
--- a/rpython/annotator/bookkeeper.py
+++ b/rpython/annotator/bookkeeper.py
@@ -688,7 +688,7 @@
         fn, block, i = self.position_key
         op = block.operations[i]
         if opname is not None:
-            assert op.opname == opname or op.opname in opname
+            assert op.opname == opname
         if arity is not None:
             assert len(op.args) == arity
         if pos is not None:
diff --git a/rpython/annotator/builtin.py b/rpython/annotator/builtin.py
--- a/rpython/annotator/builtin.py
+++ b/rpython/annotator/builtin.py
@@ -94,7 +94,7 @@
 
 
 def builtin_bool(s_obj):
-    return s_obj.is_true()
+    return s_obj.bool()
 
 def builtin_int(s_obj, s_base=None):
     if isinstance(s_obj, SomeInteger):
diff --git a/rpython/annotator/test/test_annrpython.py b/rpython/annotator/test/test_annrpython.py
--- a/rpython/annotator/test/test_annrpython.py
+++ b/rpython/annotator/test/test_annrpython.py
@@ -1490,7 +1490,7 @@
         s = a.build_types(snippet.prime, [int])
         assert s.knowntype == bool
 
-    def test_and_is_true_coalesce(self):
+    def test_and_bool_coalesce(self):
         def f(a,b,c,d,e):
             x = a and b
             if x:
@@ -1500,7 +1500,7 @@
         s = a.build_types(f, [int, str, a.bookkeeper.immutablevalue(1.0), a.bookkeeper.immutablevalue('d'), a.bookkeeper.immutablevalue('e')])
         assert s == annmodel.SomeTuple([annmodel.SomeChar(), a.bookkeeper.immutablevalue(1.0)])
 
-    def test_is_true_coalesce2(self):
+    def test_bool_coalesce2(self):
         def f(a,b,a1,b1,c,d,e):
             x = (a or  b) and (a1 or b1)
             if x:
@@ -1514,7 +1514,7 @@
         assert s == annmodel.SomeTuple([annmodel.SomeChar(),
                                         a.bookkeeper.immutablevalue(1.0)])
 
-    def test_is_true_coalesce_sanity(self):
+    def test_bool_coalesce_sanity(self):
         def f(a):
             while a:
                 pass
diff --git a/rpython/annotator/test/test_argument.py b/rpython/annotator/test/test_argument.py
--- a/rpython/annotator/test/test_argument.py
+++ b/rpython/annotator/test/test_argument.py
@@ -7,7 +7,7 @@
     def newtuple(self, items):
         return tuple(items)
 
-    def is_true(self, obj):
+    def bool(self, obj):
         return bool(obj)
 
     def unpackiterable(self, it):
diff --git a/rpython/annotator/unaryop.py b/rpython/annotator/unaryop.py
--- a/rpython/annotator/unaryop.py
+++ b/rpython/annotator/unaryop.py
@@ -20,10 +20,10 @@
 def immutablevalue(x):
     return getbookkeeper().immutablevalue(x)
 
-UNARY_OPERATIONS = set(['len', 'is_true', 'getattr', 'setattr', 'delattr',
+UNARY_OPERATIONS = set(['len', 'bool', 'getattr', 'setattr', 'delattr',
                         'simple_call', 'call_args', 'str', 'repr',
                         'iter', 'next', 'invert', 'type', 'issubtype',
-                        'pos', 'neg', 'nonzero', 'abs', 'hex', 'oct',
+                        'pos', 'neg', 'abs', 'hex', 'oct',
                         'ord', 'int', 'float', 'long',
                         'hash', 'id',    # <== not supported any more
                         'getslice', 'setslice', 'delslice',
@@ -57,7 +57,7 @@
     def len(obj):
         return SomeInteger(nonneg=True)
 
-    def is_true_behavior(obj, s):
+    def bool_behavior(obj, s):
         if obj.is_immutable_constant():
             s.const = bool(obj.const)
         else:
@@ -65,13 +65,13 @@
             if s_len.is_immutable_constant():
                 s.const = s_len.const > 0
 
-    def is_true(s_obj):
+    def bool(s_obj):
         r = SomeBool()
-        s_obj.is_true_behavior(r)
+        s_obj.bool_behavior(r)
 
         bk = getbookkeeper()
         knowntypedata = {}
-        op = bk._find_current_op(opname=("is_true", "nonzero"), arity=1)
+        op = bk._find_current_op(opname="bool", arity=1)
         arg = op.args[0]
         s_nonnone_obj = s_obj
         if s_obj.can_be_none():
@@ -80,9 +80,6 @@
         r.set_knowntypedata(knowntypedata)
         return r
 
-    def nonzero(obj):
-        return obj.is_true()
-
     def hash(obj):
         raise TypeError, ("cannot use hash() in RPython; "
                           "see objectmodel.compute_xxx()")
@@ -179,7 +176,7 @@
 
     abs = neg
 
-    def is_true(self):
+    def bool(self):
         if self.is_immutable_constant():
             return getbookkeeper().immutablevalue(bool(self.const))
         return s_Bool
@@ -211,7 +208,7 @@
     abs_ovf = _clone(abs, [OverflowError])
 
 class __extend__(SomeBool):
-    def is_true(self):
+    def bool(self):
         return self
 
     def invert(self):
@@ -670,7 +667,7 @@
             # create or update the attribute in clsdef
             clsdef.generalize_attr(attr, s_value)
 
-    def is_true_behavior(ins, s):
+    def bool_behavior(ins, s):
         if not ins.can_be_None:
             s.const = True
 
@@ -739,7 +736,7 @@
         d = [desc.bind_under(classdef, name) for desc in pbc.descriptions]
         return SomePBC(d, can_be_None=pbc.can_be_None)
 
-    def is_true_behavior(pbc, s):
+    def bool_behavior(pbc, s):
         if pbc.isNone():
             s.const = False
         elif not pbc.can_be_None:
@@ -799,7 +796,7 @@
         v = p.ll_ptrtype._example()(*llargs)
         return ll_to_annotation(v)
 
-    def is_true(p):
+    def bool(p):
         return s_Bool
 
 class __extend__(SomeLLADTMeth):
@@ -833,5 +830,5 @@
             llmemory.supported_access_types[s_attr.const])
     getattr.can_only_throw = []
 
-    def is_true(s_addr):
+    def bool(s_addr):
         return s_Bool
diff --git a/rpython/flowspace/objspace.py b/rpython/flowspace/objspace.py
--- a/rpython/flowspace/objspace.py
+++ b/rpython/flowspace/objspace.py
@@ -213,7 +213,7 @@
     def is_true(self, w_obj):
         if w_obj.foldable():
             return bool(w_obj.value)
-        w_truthvalue = self.frame.do_operation('is_true', w_obj)
+        w_truthvalue = self.frame.do_operation('bool', w_obj)
         return self.frame.guessbool(w_truthvalue)
 
     def iter(self, w_iterable):
diff --git a/rpython/flowspace/operation.py b/rpython/flowspace/operation.py
--- a/rpython/flowspace/operation.py
+++ b/rpython/flowspace/operation.py
@@ -230,8 +230,8 @@
 add_operator('trunc', 1, 'trunc', pyfunc=unsupported)
 add_operator('pos', 1, 'pos', pure=True)
 add_operator('neg', 1, 'neg', pure=True, ovf=True)
-add_operator('nonzero', 1, 'truth', pyfunc=bool, pure=True)
-op.is_true = op.nonzero
+add_operator('bool', 1, 'truth', pyfunc=bool, pure=True)
+op.is_true = op.nonzero = op.bool  # for llinterp
 add_operator('abs' , 1, 'abs', pyfunc=abs, pure=True, ovf=True)
 add_operator('hex', 1, 'hex', pyfunc=hex, pure=True)
 add_operator('oct', 1, 'oct', pyfunc=oct, pure=True)
@@ -288,7 +288,7 @@
 
 # Other functions that get directly translated to SpaceOperators
 func2op[type] = op.type
-func2op[operator.truth] = op.nonzero
+func2op[operator.truth] = op.bool
 if hasattr(__builtin__, 'next'):
     func2op[__builtin__.next] = op.next
 
diff --git a/rpython/flowspace/test/test_objspace.py b/rpython/flowspace/test/test_objspace.py
--- a/rpython/flowspace/test/test_objspace.py
+++ b/rpython/flowspace/test/test_objspace.py
@@ -104,7 +104,7 @@
     def test_loop(self):
         graph = self.codetest(self.loop)
         assert self.all_operations(graph) == {'abs': 1,
-                                              'is_true': 1,
+                                              'bool': 1,
                                               'sub': 1}
 
     #__________________________________________________________
@@ -532,7 +532,7 @@
         def f(x):
             return not ~-x
         graph = self.codetest(f)
-        assert self.all_operations(graph) == {'is_true': 1, 'invert': 1, 'neg': 1}
+        assert self.all_operations(graph) == {'bool': 1, 'invert': 1, 'neg': 1}
 
     #__________________________________________________________
 
diff --git a/rpython/flowspace/test/test_unroll.py b/rpython/flowspace/test/test_unroll.py
--- a/rpython/flowspace/test/test_unroll.py
+++ b/rpython/flowspace/test/test_unroll.py
@@ -57,7 +57,7 @@
         graph = self.codetest(f)
         ops = self.all_operations(graph)
         assert ops == {'simple_call': 6,
-                       'is_true': 6,
+                       'bool': 6,
                        'lt': 1,
                        'le': 1,
                        'eq': 1,
diff --git a/rpython/rtyper/controllerentry.py b/rpython/rtyper/controllerentry.py
--- a/rpython/rtyper/controllerentry.py
+++ b/rpython/rtyper/controllerentry.py
@@ -126,12 +126,12 @@
         from rpython.rtyper.rcontrollerentry import rtypedelegate
         return rtypedelegate(self.delitem, hop)
 
-    def ctrl_is_true(self, s_obj):
-        return delegate(self.is_true, s_obj)
+    def ctrl_bool(self, s_obj):
+        return delegate(self.bool, s_obj)
 
-    def rtype_is_true(self, hop):
+    def rtype_bool(self, hop):
         from rpython.rtyper.rcontrollerentry import rtypedelegate
-        return rtypedelegate(self.is_true, hop)
+        return rtypedelegate(self.bool, hop)
 
     def ctrl_call(self, s_obj, *args_s):
         return delegate(self.call, s_obj, *args_s)
@@ -236,7 +236,7 @@
         assert s_attr.is_constant()
         s_cin.controller.ctrl_setattr(s_cin.s_real_obj, s_attr, s_value)
 
-    def is_true(s_cin):
+    def bool(s_cin):
         return s_cin.controller.ctrl_is_true(s_cin.s_real_obj)
 
     def simple_call(s_cin, *args_s):
diff --git a/rpython/rtyper/lltypesystem/opimpl.py b/rpython/rtyper/lltypesystem/opimpl.py
--- a/rpython/rtyper/lltypesystem/opimpl.py
+++ b/rpython/rtyper/lltypesystem/opimpl.py
@@ -12,7 +12,7 @@
 ops_returning_a_bool = {'gt': True, 'ge': True,
                         'lt': True, 'le': True,
                         'eq': True, 'ne': True,
-                        'is_true': True}
+                        'bool': True, 'is_true':True}
 
 # global synonyms for some types
 from rpython.rlib.rarithmetic import intmask
diff --git a/rpython/rtyper/lltypesystem/rbuilder.py b/rpython/rtyper/lltypesystem/rbuilder.py
--- a/rpython/rtyper/lltypesystem/rbuilder.py
+++ b/rpython/rtyper/lltypesystem/rbuilder.py
@@ -128,7 +128,7 @@
         return ll_builder.buf
 
     @classmethod
-    def ll_is_true(cls, ll_builder):
+    def ll_bool(cls, ll_builder):
         return ll_builder != nullptr(cls.lowleveltype.TO)
 
 class StringBuilderRepr(BaseStringBuilderRepr):
diff --git a/rpython/rtyper/lltypesystem/rclass.py b/rpython/rtyper/lltypesystem/rclass.py
--- a/rpython/rtyper/lltypesystem/rclass.py
+++ b/rpython/rtyper/lltypesystem/rclass.py
@@ -574,7 +574,7 @@
         self.setfield(vinst, attr, vvalue, hop.llops,
                       flags=hop.args_s[0].flags)
 
-    def rtype_is_true(self, hop):
+    def rtype_bool(self, hop):
         vinst, = hop.inputargs(self)
         return hop.genop('ptr_nonzero', [vinst], resulttype=Bool)
 
diff --git a/rpython/rtyper/lltypesystem/rdict.py b/rpython/rtyper/lltypesystem/rdict.py
--- a/rpython/rtyper/lltypesystem/rdict.py
+++ b/rpython/rtyper/lltypesystem/rdict.py
@@ -252,9 +252,9 @@
         v_dict, = hop.inputargs(self)
         return hop.gendirectcall(ll_dict_len, v_dict)
 
-    def rtype_is_true(self, hop):
+    def rtype_bool(self, hop):
         v_dict, = hop.inputargs(self)
-        return hop.gendirectcall(ll_dict_is_true, v_dict)
+        return hop.gendirectcall(ll_dict_bool, v_dict)
 
     def make_iterator_repr(self, *variant):
         return DictIteratorRepr(self, *variant)
@@ -440,7 +440,7 @@
 def ll_dict_len(d):
     return d.num_items
 
-def ll_dict_is_true(d):
+def ll_dict_bool(d):
     # check if a dict is True, allowing for None
     return bool(d) and d.num_items != 0
 
diff --git a/rpython/rtyper/lltypesystem/rpbc.py b/rpython/rtyper/lltypesystem/rpbc.py
--- a/rpython/rtyper/lltypesystem/rpbc.py
+++ b/rpython/rtyper/lltypesystem/rpbc.py
@@ -241,7 +241,7 @@
                              resulttype=rresult)
         return hop.llops.convertvar(v_result, rresult, hop.r_result)
 
-    def rtype_is_true(self, hop):
+    def rtype_bool(self, hop):
         if not self.s_pbc.can_be_None:
             return inputconst(Bool, True)
         else:
diff --git a/rpython/rtyper/raddress.py b/rpython/rtyper/raddress.py
--- a/rpython/rtyper/raddress.py
+++ b/rpython/rtyper/raddress.py
@@ -41,7 +41,7 @@
         v_access = hop.inputarg(address_repr, 0)
         return v_access
 
-    def rtype_is_true(self, hop):
+    def rtype_bool(self, hop):
         v_addr, = hop.inputargs(address_repr)
         c_null = hop.inputconst(address_repr, NULL)
         return hop.genop('adr_ne', [v_addr, c_null],
diff --git a/rpython/rtyper/rbool.py b/rpython/rtyper/rbool.py
--- a/rpython/rtyper/rbool.py
+++ b/rpython/rtyper/rbool.py
@@ -22,7 +22,7 @@
             raise TyperError("not a bool: %r" % (value,))
         return value
 
-    def rtype_is_true(_, hop):
+    def rtype_bool(_, hop):
         vlist = hop.inputargs(Bool)
         return vlist[0]
 
diff --git a/rpython/rtyper/rbuilder.py b/rpython/rtyper/rbuilder.py
--- a/rpython/rtyper/rbuilder.py
+++ b/rpython/rtyper/rbuilder.py
@@ -49,10 +49,10 @@
         hop.exception_cannot_occur()
         return hop.gendirectcall(self.ll_build, *vlist)
 
-    def rtype_is_true(self, hop):
+    def rtype_bool(self, hop):
         vlist = hop.inputargs(self)
         hop.exception_cannot_occur()
-        return hop.gendirectcall(self.ll_is_true, *vlist)
+        return hop.gendirectcall(self.ll_bool, *vlist)
 
     def convert_const(self, value):
         if not value is None:
diff --git a/rpython/rtyper/rbuiltin.py b/rpython/rtyper/rbuiltin.py
--- a/rpython/rtyper/rbuiltin.py
+++ b/rpython/rtyper/rbuiltin.py
@@ -195,7 +195,7 @@
 def rtype_builtin_bool(hop):
     # not called any more?
     assert hop.nb_args == 1
-    return hop.args_r[0].rtype_is_true(hop)
+    return hop.args_r[0].rtype_bool(hop)
 
 def rtype_builtin_int(hop):
     if isinstance(hop.args_s[0], annmodel.SomeString):
diff --git a/rpython/rtyper/rclass.py b/rpython/rtyper/rclass.py
--- a/rpython/rtyper/rclass.py
+++ b/rpython/rtyper/rclass.py
@@ -385,7 +385,7 @@
     def rtype_setattr(self, hop):
         raise NotImplementedError
 
-    def rtype_is_true(self, hop):
+    def rtype_bool(self, hop):
         raise NotImplementedError
 
     def _emulate_call(self, hop, meth_name):
diff --git a/rpython/rtyper/rcontrollerentry.py b/rpython/rtyper/rcontrollerentry.py
--- a/rpython/rtyper/rcontrollerentry.py
+++ b/rpython/rtyper/rcontrollerentry.py
@@ -28,8 +28,8 @@
     def rtype_setattr(self, hop):
         return self.controller.rtype_setattr(hop)
 
-    def rtype_is_true(self, hop):
-        return self.controller.rtype_is_true(hop)
+    def rtype_bool(self, hop):
+        return self.controller.rtype_bool(hop)
 
     def rtype_simple_call(self, hop):
         return self.controller.rtype_call(hop)
diff --git a/rpython/rtyper/rfloat.py b/rpython/rtyper/rfloat.py
--- a/rpython/rtyper/rfloat.py
+++ b/rpython/rtyper/rfloat.py
@@ -108,7 +108,7 @@
     def get_ll_hash_function(self):
         return _hash_float
 
-    def rtype_is_true(_, hop):
+    def rtype_bool(_, hop):
         vlist = hop.inputargs(Float)
         return hop.genop('float_is_true', vlist, resulttype=Bool)
 
diff --git a/rpython/rtyper/rint.py b/rpython/rtyper/rint.py
--- a/rpython/rtyper/rint.py
+++ b/rpython/rtyper/rint.py
@@ -295,7 +295,7 @@
             hop.exception_cannot_occur()
         return hop.genop('cast_int_to_unichar', vlist, resulttype=UniChar)
 
-    def rtype_is_true(self, hop):
+    def rtype_bool(self, hop):
         assert self is self.as_int   # rtype_is_true() is overridden in BoolRepr
         vlist = hop.inputargs(self)
         return hop.genop(self.opprefix + 'is_true', vlist, resulttype=Bool)
diff --git a/rpython/rtyper/rlist.py b/rpython/rtyper/rlist.py
--- a/rpython/rtyper/rlist.py
+++ b/rpython/rtyper/rlist.py
@@ -129,7 +129,7 @@
             ll_func = ll_len_foldable
         return hop.gendirectcall(ll_func, v_lst)
 
-    def rtype_is_true(self, hop):
+    def rtype_bool(self, hop):
         v_lst, = hop.inputargs(self)
         if hop.args_s[0].listdef.listitem.resized:
             ll_func = ll_list_is_true
diff --git a/rpython/rtyper/rmodel.py b/rpython/rtyper/rmodel.py
--- a/rpython/rtyper/rmodel.py
+++ b/rpython/rtyper/rmodel.py
@@ -199,15 +199,12 @@
         [v_self] = hop.inputargs(self)
         return hop.gendirectcall(self.ll_str, v_self)
 
-    def rtype_nonzero(self, hop):
-        return self.rtype_is_true(hop)   # can call a subclass' rtype_is_true()
-
-    def rtype_is_true(self, hop):
+    def rtype_bool(self, hop):
         try:
             vlen = self.rtype_len(hop)
         except MissingRTypeOperation:
             if not hop.s_result.is_constant():
-                raise TyperError("rtype_is_true(%r) not implemented" % (self,))
+                raise TyperError("rtype_bool(%r) not implemented" % (self,))
             return hop.inputconst(Bool, hop.s_result.const)
         else:
             return hop.genop('int_is_true', [vlen], resulttype=Bool)
@@ -243,7 +240,7 @@
     """A mix-in base class for subclasses of Repr that represent None as
     'null' and true values as non-'null'.
     """
-    def rtype_is_true(self, hop):
+    def rtype_bool(self, hop):
         if hop.s_result.is_constant():
             return hop.inputconst(Bool, hop.s_result.const)
         else:
diff --git a/rpython/rtyper/rpbc.py b/rpython/rtyper/rpbc.py
--- a/rpython/rtyper/rpbc.py
+++ b/rpython/rtyper/rpbc.py
@@ -587,7 +587,7 @@
 class NoneFrozenPBCRepr(Repr):
     lowleveltype = Void
 
-    def rtype_is_true(self, hop):
+    def rtype_bool(self, hop):
         return Constant(False, Bool)
 
     def none_call(self, hop):
diff --git a/rpython/rtyper/rptr.py b/rpython/rtyper/rptr.py
--- a/rpython/rtyper/rptr.py
+++ b/rpython/rtyper/rptr.py
@@ -79,7 +79,7 @@
             return hop.genop('getarraysize', vlist,
                              resulttype = hop.r_result.lowleveltype)
 
-    def rtype_is_true(self, hop):
+    def rtype_bool(self, hop):
         vlist = hop.inputargs(self)
         return hop.genop('ptr_nonzero', vlist, resulttype=lltype.Bool)
 
diff --git a/rpython/rtyper/rstr.py b/rpython/rtyper/rstr.py
--- a/rpython/rtyper/rstr.py
+++ b/rpython/rtyper/rstr.py
@@ -137,7 +137,7 @@
         v_str, = hop.inputargs(string_repr)
         return hop.gendirectcall(self.ll.ll_strlen, v_str)
 
-    def rtype_is_true(self, hop):
+    def rtype_bool(self, hop):
         s_str = hop.args_s[0]
         if s_str.can_be_None:
             string_repr = hop.args_r[0].repr
@@ -145,7 +145,7 @@
             return hop.gendirectcall(self.ll.ll_str_is_true, v_str)
         else:
             # defaults to checking the length
-            return super(AbstractStringRepr, self).rtype_is_true(hop)
+            return super(AbstractStringRepr, self).rtype_bool(hop)
 
     def rtype_method_startswith(self, hop):
         str1_repr = hop.args_r[0].repr
@@ -595,7 +595,7 @@
     def rtype_len(_, hop):
         return hop.inputconst(Signed, 1)
 
-    def rtype_is_true(_, hop):
+    def rtype_bool(_, hop):
         assert not hop.args_s[0].can_be_None
         return hop.inputconst(Bool, True)
 
diff --git a/rpython/rtyper/test/test_rdict.py b/rpython/rtyper/test/test_rdict.py
--- a/rpython/rtyper/test/test_rdict.py
+++ b/rpython/rtyper/test/test_rdict.py
@@ -91,7 +91,7 @@
         res = self.interpret(func, [6])
         assert res == 1
 
-    def test_dict_is_true(self):
+    def test_dict_bool(self):
         def func(i):
             if i:
                 d = {}
diff --git a/rpython/translator/simplify.py b/rpython/translator/simplify.py
--- a/rpython/translator/simplify.py
+++ b/rpython/translator/simplify.py
@@ -389,9 +389,9 @@
 # (they have no side effects, at least in R-Python)
 CanRemove = {}
 for _op in '''
-        newtuple newlist newdict is_true
+        newtuple newlist newdict bool
         is_ id type issubtype repr str len hash getattr getitem
-        pos neg nonzero abs hex oct ord invert add sub mul
+        pos neg abs hex oct ord invert add sub mul
         truediv floordiv div mod divmod pow lshift rshift and_ or_
         xor int float long lt le eq ne gt ge cmp coerce contains
         iter get'''.split():
@@ -580,14 +580,14 @@
                     del link.args[i]
 
 
-def coalesce_is_true(graph):
-    """coalesce paths that go through an is_true and a directly successive
-       is_true both on the same value, transforming the link into the
-       second is_true from the first to directly jump to the correct
+def coalesce_bool(graph):
+    """coalesce paths that go through an bool and a directly successive
+       bool both on the same value, transforming the link into the
+       second bool from the first to directly jump to the correct
        target out of the second."""
     candidates = []
 
-    def has_is_true_exitpath(block):
+    def has_bool_exitpath(block):
         tgts = []
         start_op = block.operations[-1]
         cond_v = start_op.args[0]
@@ -597,15 +597,15 @@
                 if tgt == block:
                     continue
                 rrenaming = dict(zip(tgt.inputargs,exit.args))
-                if len(tgt.operations) == 1 and tgt.operations[0].opname == 'is_true':
+                if len(tgt.operations) == 1 and tgt.operations[0].opname == 'bool':
                     tgt_op = tgt.operations[0]
                     if tgt.exitswitch == tgt_op.result and rrenaming.get(tgt_op.args[0]) == cond_v:
                         tgts.append((exit.exitcase, tgt))
         return tgts
 
     for block in graph.iterblocks():
-        if block.operations and block.operations[-1].opname == 'is_true':
-            tgts = has_is_true_exitpath(block)
+        if block.operations and block.operations[-1].opname == 'bool':
+            tgts = has_bool_exitpath(block)
             if tgts:
                 candidates.append((block, tgts))
 
@@ -621,7 +621,7 @@
             newlink = tgt.exits[case].copy(rename)
             newexits[case] = newlink
         cand.recloseblock(*newexits)
-        newtgts = has_is_true_exitpath(cand)
+        newtgts = has_bool_exitpath(cand)
         if newtgts:
             candidates.append((cand, newtgts))
 
@@ -979,7 +979,7 @@
     eliminate_empty_blocks,
     remove_assertion_errors,
     join_blocks,
-    coalesce_is_true,
+    coalesce_bool,
     transform_dead_op_vars,
     remove_identical_vars,
     transform_ovfcheck,


More information about the pypy-commit mailing list