[pypy-commit] pypy bigint-with-int-ops: Support the shift ops.

stian noreply at buildbot.pypy.org
Fri Aug 9 00:11:41 CEST 2013


Author: stian
Branch: bigint-with-int-ops
Changeset: r66021:f49ccf659096
Date: 2013-08-08 18:39 +0200
http://bitbucket.org/pypy/pypy/changeset/f49ccf659096/

Log:	Support the shift ops.

diff --git a/pypy/objspace/std/longobject.py b/pypy/objspace/std/longobject.py
--- a/pypy/objspace/std/longobject.py
+++ b/pypy/objspace/std/longobject.py
@@ -285,6 +285,14 @@
                              space.wrap("shift count too large"))
     return W_LongObject(w_long1.num.lshift(shift))
 
+def lshift__Long_Int(space, w_long1, w_int2):
+    # XXX need to replicate some of the logic, to get the errors right
+    if w_int2.intval < 0:
+        raise OperationError(space.w_ValueError,
+                             space.wrap("negative shift count"))
+
+    return W_LongObject(w_long1.num.lshift(w_int2.intval))
+
 def rshift__Long_Long(space, w_long1, w_long2):
     # XXX need to replicate some of the logic, to get the errors right
     if w_long2.num.sign < 0:
@@ -297,6 +305,14 @@
                              space.wrap("shift count too large"))
     return newlong(space, w_long1.num.rshift(shift))
 
+def rshift__Long_Int(space, w_long1, w_int2):
+    # XXX need to replicate some of the logic, to get the errors right
+    if w_int2.intval < 0:
+        raise OperationError(space.w_ValueError,
+                             space.wrap("negative shift count"))
+
+    return newlong(space, w_long1.num.rshift(w_int2.intval))
+
 def and__Long_Long(space, w_long1, w_long2):
     return newlong(space, w_long1.num.and_(w_long2.num))
 


More information about the pypy-commit mailing list