[pypy-svn] r53660 - pypy/branch/io-improvements/pypy/rpython

fijal at codespeak.net fijal at codespeak.net
Thu Apr 10 17:46:12 CEST 2008


Author: fijal
Date: Thu Apr 10 17:46:11 2008
New Revision: 53660

Modified:
   pypy/branch/io-improvements/pypy/rpython/annlowlevel.py
Log:
Ah. A function for tests in previous checkin :)


Modified: pypy/branch/io-improvements/pypy/rpython/annlowlevel.py
==============================================================================
--- pypy/branch/io-improvements/pypy/rpython/annlowlevel.py	(original)
+++ pypy/branch/io-improvements/pypy/rpython/annlowlevel.py	Thu Apr 10 17:46:11 2008
@@ -400,6 +400,28 @@
         return hop.genop('same_as', [v_ll_str],
                          resulttype = hop.r_result.lowleveltype)
 
+def llstr(s):
+    from pypy.rpython.lltypesystem.rstr import mallocstr
+    # XXX not sure what to do with ootypesystem
+    ll_s = mallocstr(len(s))
+    for i, c in enumerate(s):
+        ll_s.chars[i] = c
+    return ll_s
+
+class LLStrEntry(extregistry.ExtRegistryEntry):
+    _about_ = llstr
+
+    def compute_result_annotation(self, s_str):
+        from pypy.rpython.lltypesystem.rstr import STR
+        return annmodel.lltype_to_annotation(lltype.Ptr(STR))
+
+    def specialize_call(self, hop):
+        hop.exception_cannot_occur()
+        assert hop.args_r[0].lowleveltype == hop.r_result.lowleveltype
+        v_ll_str, = hop.inputargs(*hop.args_r)
+        return hop.genop('same_as', [v_ll_str],
+                         resulttype = hop.r_result.lowleveltype)        
+
 # ____________________________________________________________
 
 def cast_object_to_ptr(PTR, object):



More information about the Pypy-commit mailing list