[pypy-svn] r22830 - in pypy/dist/pypy/jit: . test

arigo at codespeak.net arigo at codespeak.net
Sun Jan 29 13:09:55 CET 2006


Author: arigo
Date: Sun Jan 29 13:09:54 2006
New Revision: 22830

Modified:
   pypy/dist/pypy/jit/hintvlist.py
   pypy/dist/pypy/jit/test/test_hint_annotation.py
Log:
List copy and concat.
Now the hint annotator has as many list operations as the llabstractinterp.



Modified: pypy/dist/pypy/jit/hintvlist.py
==============================================================================
--- pypy/dist/pypy/jit/hintvlist.py	(original)
+++ pypy/dist/pypy/jit/hintvlist.py	Sun Jan 29 13:09:54 2006
@@ -58,10 +58,15 @@
         pass
 
     def oop_copy(self):
-        XXX
+        bk = self.bookkeeper
+        vlistdef = bk.getvirtualcontainerdef(self.T, VirtualListDef)
+        vlistdef.generalize_item(self.read_item())
+        return hintmodel.SomeLLAbstractContainer(vlistdef)
 
     def oop_concat(self, hs_other):
-        XXX
+        assert isinstance(hs_other, hintmodel.SomeLLAbstractContainer) # for now
+        assert hs_other.contentdef.T == self.T
+        return self.oop_copy()
 
 # ____________________________________________________________
 

Modified: pypy/dist/pypy/jit/test/test_hint_annotation.py
==============================================================================
--- pypy/dist/pypy/jit/test/test_hint_annotation.py	(original)
+++ pypy/dist/pypy/jit/test/test_hint_annotation.py	Sun Jan 29 13:09:54 2006
@@ -227,6 +227,17 @@
     assert hs.concretetype == lltype.Signed
     assert len(hs.origins) == 2
 
+def test_some_more_list_operations():
+    def ll_function(x, y, index):
+        l = []
+        l.append(x)
+        l[0] = y
+        return (l+list(l))[index]
+    hs = hannotate(ll_function, [int, int, int], policy=P_OOPSPEC)
+    assert isinstance(hs, SomeLLAbstractConstant)
+    assert hs.concretetype == lltype.Signed
+    assert len(hs.origins) == 2
+
 def test_simple_cast_pointer():
     GCS1 = lltype.GcStruct('s1', ('x', lltype.Signed))
     GCS2 = lltype.GcStruct('s2', ('sub', GCS1), ('y', lltype.Signed))



More information about the Pypy-commit mailing list