[pypy-commit] lang-smalltalk rbigint: merge with tip

lwassermann noreply at buildbot.pypy.org
Thu Apr 25 12:11:51 CEST 2013


Author: Lars Wassermann <lars.wassermann at gmail.com>
Branch: rbigint
Changeset: r335:8c1cadf26ba3
Date: 2013-04-24 17:48 +0200
http://bitbucket.org/pypy/lang-smalltalk/changeset/8c1cadf26ba3/

Log:	merge with tip

diff --git a/spyvm/display.py b/spyvm/display.py
--- a/spyvm/display.py
+++ b/spyvm/display.py
@@ -24,6 +24,7 @@
         SDLCursor.has_display = True
         self.has_surface = False
         self.mouse_position = [0, 0]
+        self.interrupt_key = 15 << 8 # pushing all four meta keys, of which we support three...
         self.button = 0
         self.key = 0
 
diff --git a/spyvm/fieldtypes.py b/spyvm/fieldtypes.py
--- a/spyvm/fieldtypes.py
+++ b/spyvm/fieldtypes.py
@@ -1,6 +1,7 @@
 from spyvm import model, shadow
 
 from rpython.rlib import objectmodel, jit, signature
+from rpython.rlib.listsort import TimSort
 
 class TypeTag():
     pass
@@ -10,6 +11,13 @@
 flt = TypeTag()
 obj = TypeTag()
 
+# may be used during debugging
+# LPI, SInt, flt, obj = 'LPI', 'SInt', 'float', 'object'
+
+class FieldSort(TimSort):
+    def lt(self, a, b):
+        return a[0] < b[0]
+
 maps = {}
 
 class VarSizedFieldTypes():
@@ -74,16 +82,24 @@
         elif parent is None:
             return self.descent([change])
         else:
-            new_fieldtype = parent.ascent([change, self.diff])
+            if n0 == self.diff[0]:
+                diff = [change]
+            else:
+                diff = [change, self.diff]
+
+            new_fieldtype = parent.ascent(diff)
+
             if not objectmodel.we_are_translated():
-                assert new_fieldtype.types == self.types[0:n0] + [changed_type] + self.types[n0+1:]
+                new_types = list(self.types)
+                new_types[n0] = changed_type
+                assert new_fieldtype.types == new_types
             siblings[change] = new_fieldtype
             return new_fieldtype
 
     def ascent(self, changes):
         parent = self.parent
         if parent is None:
-            sort(changes)
+            FieldSort(changes).sort()
             return self.descent(changes)
         else:
             change = self.diff
@@ -96,11 +112,14 @@
             return self
 
         change = changes[0]
+        if change[1] is obj:
+            return self.descent(changes[1:])
         siblings = self.siblings
         if change in siblings:
             return siblings[change].descent(changes[1:])
         else:
             new_types = list(self.types)
+            assert new_types[change[0]] == obj
             new_types[change[0]] = change[1]
             new_fieldtype = FieldTypes(new_types, self, change)
             siblings[change] = new_fieldtype
@@ -137,32 +156,3 @@
             return typer
     except AttributeError:
         return nilTyper
-
-def sort(an_array):
-    end = len(an_array) - 1
-    sort_quick_inplace(an_array, 0, end)
-
-
-def sort_quick_inplace(an_array, start, end):
-    assert start >= 0 and end < len(an_array)
-
-    def partition(an_array, start, end):
-        key = an_array[start][0]
-        i = start - 1
-        j = end + 1
-        while True:
-            i += 1
-            j -= 1
-            while not an_array[j][0] <= key:
-                j -= 1
-            while not an_array[i][0] >= key:
-                i += 1
-            if j <= i:
-                return j
-            else:
-                an_array[i], an_array[j] = an_array[j], an_array[i]
-
-    if start < end:
-        mid = partition(an_array, start, end)
-        sort_quick_inplace(an_array, start, mid)
-        sort_quick_inplace(an_array, mid + 1, end)
diff --git a/spyvm/primitives.py b/spyvm/primitives.py
--- a/spyvm/primitives.py
+++ b/spyvm/primitives.py
@@ -1352,14 +1352,14 @@
 IDLE_FOR_MICROSECONDS = 230
 FORCE_DISPLAY_UPDATE = 231
 
- at expose_primitive(IDLE_FOR_MICROSECONDS, unwrap_spec=[object, int])
+ at expose_primitive(IDLE_FOR_MICROSECONDS, unwrap_spec=[object, int], no_result=True, clean_stack=False)
 def func(interp, s_frame, w_rcvr, time_mu_s):
     import time
     time_s = time_mu_s / 1000000.0
     time.sleep(time_s)
     interp.interrupt_check_counter = 0
+    s_frame.pop()
     interp.quick_check_for_interrupt(s_frame, dec=0)
-    return w_rcvr
 
 @expose_primitive(FORCE_DISPLAY_UPDATE, unwrap_spec=[object])
 def func(interp, s_frame, w_rcvr):
diff --git a/spyvm/test/test_fieldtypes.py b/spyvm/test/test_fieldtypes.py
--- a/spyvm/test/test_fieldtypes.py
+++ b/spyvm/test/test_fieldtypes.py
@@ -2,7 +2,7 @@
 from spyvm import model, fieldtypes
 from spyvm import objspace
 
-from spyvm.fieldtypes import obj, SInt
+from spyvm.fieldtypes import obj, SInt, LPI, flt
 
 def test_simple_changes():
 	a = fieldtypes.FieldTypes.of_length(3)
@@ -30,4 +30,16 @@
 	assert len(a.siblings) == 3
 	assert len(a.sibling(0, SInt).siblings) == 2
 	assert len(a.sibling(1, SInt).siblings) == 2
-	assert len(a.sibling(2, SInt).siblings) == 1 # link to [o, i, i] not created
\ No newline at end of file
+	assert len(a.sibling(2, SInt).siblings) == 1 # link to [o, i, i] not created
+
+def test_multiple_changes():
+	a = fieldtypes.FieldTypes.of_length(3)
+	b = a.sibling(0, SInt)
+	for tag in [LPI, flt]:
+		assert b.sibling(0, tag).types == [tag, obj, obj]
+
+def test_obj_replacement():
+	a = fieldtypes.FieldTypes.of_length(3)
+	b = a.sibling(0, SInt).sibling(1, SInt)
+	c = a.sibling(1, SInt)
+	assert b.sibling(0, obj) is c


More information about the pypy-commit mailing list