[pypy-commit] pypy default: fix the case of llstr(char)

fijal noreply at buildbot.pypy.org
Fri Aug 29 16:38:45 CEST 2014


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: 
Changeset: r73165:5ca79366c56e
Date: 2014-08-20 14:38 +0200
http://bitbucket.org/pypy/pypy/changeset/5ca79366c56e/

Log:	fix the case of llstr(char)

diff --git a/rpython/rtyper/annlowlevel.py b/rpython/rtyper/annlowlevel.py
--- a/rpython/rtyper/annlowlevel.py
+++ b/rpython/rtyper/annlowlevel.py
@@ -421,9 +421,13 @@
                 return lltype_to_annotation(lltype.Ptr(UNICODE))
 
         def specialize_call(self, hop):
+            from rpython.rtyper.lltypesystem.rstr import (string_repr,
+                                                          unicode_repr)
             hop.exception_cannot_occur()
-            assert hop.args_r[0].lowleveltype == hop.r_result.lowleveltype
-            v_ll_str, = hop.inputargs(*hop.args_r)
+            if strtype is str:
+                v_ll_str = hop.inputarg(string_repr, 0)
+            else:
+                v_ll_str = hop.inputarg(unicode_repr, 0)
             return hop.genop('same_as', [v_ll_str],
                              resulttype = hop.r_result.lowleveltype)
 
diff --git a/rpython/rtyper/test/test_annlowlevel.py b/rpython/rtyper/test/test_annlowlevel.py
--- a/rpython/rtyper/test/test_annlowlevel.py
+++ b/rpython/rtyper/test/test_annlowlevel.py
@@ -34,6 +34,14 @@
         res = self.interpret(f, [self.string_to_ll("abc")])
         assert res == 3
 
+    def test_llstr_const_char(self):
+        def f(arg):
+            s = llstr(hlstr(arg)[0])
+            return len(s.chars)
+
+        res = self.interpret(f, [self.string_to_ll("abc")])
+        assert res == 1
+
     def test_hlunicode(self):
         s = mallocunicode(3)
         s.chars[0] = u"a"


More information about the pypy-commit mailing list