[pypy-svn] r62600 - in pypy/branch/pyjitpl5/pypy/jit/backend/llgraph: . test

arigo at codespeak.net arigo at codespeak.net
Thu Mar 5 17:50:20 CET 2009


Author: arigo
Date: Thu Mar  5 17:50:19 2009
New Revision: 62600

Modified:
   pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
   pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py
   pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/test/test_llgraph.py
Log:
newstr, strsetitem


Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py	Thu Mar  5 17:50:19 2009
@@ -994,6 +994,14 @@
     newvalue = cast_from_ptr(FIELDTYPE, newvalue)
     setattr(ptr, fieldname, newvalue)
 
+def do_newstr(length):
+    x = rstr.mallocstr(length)
+    return cast_to_ptr(x)
+
+def do_strsetitem(string, index, newvalue):
+    str = lltype.cast_opaque_ptr(lltype.Ptr(rstr.STR), string)
+    str.chars[index] = chr(newvalue)
+
 # ____________________________________________________________
 
 
@@ -1092,3 +1100,5 @@
 setannotation(do_setfield_gc_ptr, annmodel.s_None)
 setannotation(do_setfield_raw_int, annmodel.s_None)
 setannotation(do_setfield_raw_ptr, annmodel.s_None)
+setannotation(do_newstr, annmodel.SomePtr(llmemory.GCREF))
+setannotation(do_strsetitem, annmodel.s_None)

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py	Thu Mar  5 17:50:19 2009
@@ -406,6 +406,16 @@
             llimpl.do_setfield_raw_int(struct, fielddescr, newvalue,
                                        self.memo_cast)
 
+    def do_newstr(self, args):
+        length = args[0].getint()
+        return history.BoxPtr(llimpl.do_newstr(length))
+
+    def do_strsetitem(self, args):
+        string = args[0].getptr_base()
+        index = args[1].getint()
+        newvalue = args[2].getint()
+        llimpl.do_strsetitem(string, index, newvalue)
+
 
 class GuardFailed(object):
     returns = False

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/test/test_llgraph.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/test/test_llgraph.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/test/test_llgraph.py	Thu Mar  5 17:50:19 2009
@@ -278,3 +278,10 @@
             [BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, b)), descrbox_B,
              BoxInt(1), x])
         assert b[1] == x.getptr(lltype.Ptr(A))
+        #
+        x = cpu.do_newstr([BoxInt(5)])
+        assert isinstance(x, BoxPtr)
+        assert len(x.getptr(lltype.Ptr(rstr.STR)).chars) == 5
+        #
+        cpu.do_strsetitem([x, BoxInt(4), BoxInt(ord('/'))])
+        assert x.getptr(lltype.Ptr(rstr.STR)).chars[4] == '/'



More information about the Pypy-commit mailing list