[pypy-commit] lang-smalltalk bitblt: support 32bit large integers in bit operations

timfel noreply at buildbot.pypy.org
Mon Mar 18 13:58:52 CET 2013


Author: Tim Felgentreff <timfelgentreff at gmail.com>
Branch: bitblt
Changeset: r197:27c34fed4f35
Date: 2013-03-18 09:56 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/27c34fed4f35/

Log:	support 32bit large integers in bit operations

diff --git a/spyvm/primitives.py b/spyvm/primitives.py
--- a/spyvm/primitives.py
+++ b/spyvm/primitives.py
@@ -11,6 +11,11 @@
 
 from rpython.rlib import rarithmetic, rfloat, unroll, jit
 
+
+# for 32bit unwrap spec
+uint = object()
+
+
 def assert_bounds(n0, minimum, maximum):
     if not minimum <= n0 < maximum:
         raise PrimitiveFailedError()
@@ -96,6 +101,11 @@
                     w_arg = s_frame.peek(index)
                     if spec is int:
                         args += (interp.space.unwrap_int(w_arg), )
+                    elif spec is uint:
+                        if isinstance(w_arg, model.W_SmallInteger):
+                            args += (interp.space.unwrap_int(w_arg), )
+                        else:
+                            args += (interp.space.unwrap_uint(w_arg), )
                     elif spec is index1_0:
                         args += (interp.space.unwrap_int(w_arg)-1, )
                     elif spec is float:
@@ -174,10 +184,10 @@
     }
 for (code,op) in bitwise_binary_ops.items():
     def make_func(op):
-        @expose_primitive(code, unwrap_spec=[int, int])
+        @expose_primitive(code, unwrap_spec=[uint, uint])
         def func(interp, s_frame, receiver, argument):
-            res = op(receiver, argument)
-            return interp.space.wrap_int(res)
+            res = abs(op(receiver, argument))
+            return interp.space.wrap_uint(res)
     make_func(op)
 
 # #/ -- return the result of a division, only succeed if the division is exact


More information about the pypy-commit mailing list