Author: Ronan Lamy <[email protected]>
Branch: less-stringly-ops
Changeset: r67648:21eaaa4e4ef3
Date: 2013-10-19 23:00 +0100
http://bitbucket.org/pypy/pypy/changeset/21eaaa4e4ef3/

Log:    unstringlify getitem_idx_key et al.

diff --git a/rpython/flowspace/operation.py b/rpython/flowspace/operation.py
--- a/rpython/flowspace/operation.py
+++ b/rpython/flowspace/operation.py
@@ -266,6 +266,9 @@
 add_operator('setattr', 3, pyfunc=setattr)
 add_operator('delattr', 2, pyfunc=delattr)
 add_operator('getitem', 2, pure=True)
+add_operator('getitem_idx', 2, pure=True)
+add_operator('getitem_key', 2, pure=True)
+add_operator('getitem_idx_key', 2, pure=True)
 add_operator('setitem', 3)
 add_operator('delitem', 2)
 add_operator('getslice', 3, pyfunc=do_getslice, pure=True)
@@ -457,6 +460,9 @@
 # allows the annotator to be more precise, see test_reraiseAnything/KeyError in
 # the annotator tests
 op.getitem.canraise = [IndexError, KeyError, Exception]
+op.getitem_idx.canraise = [IndexError, KeyError, Exception]
+op.getitem_key.canraise = [IndexError, KeyError, Exception]
+op.getitem_idx_key.canraise = [IndexError, KeyError, Exception]
 op.setitem.canraise = [IndexError, KeyError, Exception]
 op.delitem.canraise = [IndexError, KeyError, Exception]
 op.contains.canraise = [Exception]    # from an r_dict
diff --git a/rpython/translator/simplify.py b/rpython/translator/simplify.py
--- a/rpython/translator/simplify.py
+++ b/rpython/translator/simplify.py
@@ -8,7 +8,7 @@
 
 from rpython.flowspace.model import (SpaceOperation, Variable, Constant,
                                      c_last_exception, checkgraph, mkentrymap)
-from rpython.flowspace.operation import OverflowingOperation
+from rpython.flowspace.operation import OverflowingOperation, op
 from rpython.rlib import rarithmetic
 from rpython.translator import unsimplify
 from rpython.translator.backendopt import ssa
@@ -204,7 +204,10 @@
                     elif exit.exitcase is KeyError:
                         postfx.append('key')
                 if postfx:
-                    last_op.opname = last_op.opname + '_' + '_'.join(postfx)
+                    Op = getattr(op, '_'.join(['getitem'] + postfx))
+                    newop = Op(*last_op.args)
+                    newop.result = last_op.result
+                    block.operations[-1] = newop
 
 
 def remove_dead_exceptions(graph):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to