Author: Carl Friedrich Bolz <[email protected]>
Branch: 
Changeset: r85959:2246f93d2550
Date: 2016-08-01 18:07 +0200
http://bitbucket.org/pypy/pypy/changeset/2246f93d2550/

Log:    make int * string work too in RPython

diff --git a/rpython/rtyper/rstr.py b/rpython/rtyper/rstr.py
--- a/rpython/rtyper/rstr.py
+++ b/rpython/rtyper/rstr.py
@@ -591,7 +591,9 @@
 
 class __extend__(pairtype(IntegerRepr, AbstractStringRepr)):
     def rtype_mul((r_int, r_str), hop):
-        return pair(r_str, r_int).rtype_mul(hop)
+        str_repr = r_str.repr
+        v_int, v_str = hop.inputargs(Signed, str_repr)
+        return hop.gendirectcall(r_str.ll.ll_str_mul, v_str, v_int)
     rtype_inplace_mul = rtype_mul
 
 
diff --git a/rpython/rtyper/test/test_rstr.py b/rpython/rtyper/test/test_rstr.py
--- a/rpython/rtyper/test/test_rstr.py
+++ b/rpython/rtyper/test/test_rstr.py
@@ -220,11 +220,12 @@
         const = self.const
         def fn(i, mul):
             s = ["", "a", "aba"][i]
-            return s * mul
+            return s * mul + mul * s
         for i in xrange(3):
             for m in [0, 1, 4]:
+                res1 = fn(i, m)
                 res = self.interpret(fn, [i, m])
-                assert self.ll_to_string(res) == fn(i, m)
+                assert self.ll_to_string(res) == res1
 
     def test_is_none(self):
         const = self.const
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to