Author: Lars Wassermann <[email protected]>
Branch: 
Changeset: r242:868fcedf2f58
Date: 2013-03-28 12:46 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/868fcedf2f58/

Log:    fixed wrap_uint to never create w_LargePositiveInteger instances of
        size <= 4

diff --git a/spyvm/objspace.py b/spyvm/objspace.py
--- a/spyvm/objspace.py
+++ b/spyvm/objspace.py
@@ -185,11 +185,13 @@
         # XXX this code sucks
         import math
         bytes_len = int(math.log(val) / math.log(0xff)) + 1
-        bytes_len = 4 if 4 > bytes_len else bytes_len
-        w_result = 
model.W_BytesObject(self.classtable['w_LargePositiveInteger'], bytes_len)
-        for i in range(bytes_len):
-            w_result.setchar(i, chr(intmask((val >> i*8) & 255)))
-        return w_result
+        if bytes_len <= 4:
+            return self.wrap_positive_32bit_int(intmask(val))
+        else:
+            w_result = 
model.W_BytesObject(self.classtable['w_LargePositiveInteger'], bytes_len)
+            for i in range(bytes_len):
+                w_result.setchar(i, chr(intmask((val >> i*8) & 255)))
+            return w_result
 
     def wrap_positive_32bit_int(self, val):
         # This will always return a positive value.
diff --git a/spyvm/primitives.py b/spyvm/primitives.py
--- a/spyvm/primitives.py
+++ b/spyvm/primitives.py
@@ -1115,8 +1115,8 @@
                   no_result=True, clean_stack=False)
 def func(interp, s_frame, w_rcvr, w_selector, args_w):
     argcount = len(args_w)
-    # pushing the receiver and args to be popped by _sendSelector
-    s_frame.push(w_rcvr)
+    s_frame.pop_n(2) # removing our arguments to be substituted with args_w
+    # pushing the args to be popped by _sendSelector
     s_frame.push_all(args_w)
     s_frame._sendSelector(w_selector, argcount, interp,
                       w_rcvr, w_rcvr.shadow_of_my_class(interp.space))
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to