[pypy-svn] r13210 - in pypy/dist/pypy/rpython: . test
pedronis at codespeak.net
pedronis at codespeak.net
Thu Jun 9 02:26:41 CEST 2005
Author: pedronis
Date: Thu Jun 9 02:26:40 2005
New Revision: 13210
Modified:
pypy/dist/pypy/rpython/rstr.py
pypy/dist/pypy/rpython/test/test_rstr.py
Log:
string concatenation
Modified: pypy/dist/pypy/rpython/rstr.py
==============================================================================
--- pypy/dist/pypy/rpython/rstr.py (original)
+++ pypy/dist/pypy/rpython/rstr.py Thu Jun 9 02:26:40 2005
@@ -88,6 +88,11 @@
return hop.gendirectcall(llfn, v_str, v_index)
+class __extend__(pairtype(StringRepr, StringRepr)):
+ def rtype_add(_, hop):
+ v_str1, v_str2 = hop.inputargs(string_repr, string_repr)
+ return hop.gendirectcall(ll_strconcat, v_str1, v_str2)
+
class __extend__(CharRepr):
def rtype_len(_, hop):
@@ -165,3 +170,22 @@
x = -1
s.hash = intmask(x)
return x
+
+def ll_strconcat(s1, s2):
+ len1 = len(s1.chars)
+ len2 = len(s2.chars)
+ newstr = malloc(STR, len1 + len2)
+ i = 0
+ j = 0
+ while i < len1:
+ newstr.chars[j].ch = s1.chars[i].ch
+ i += 1
+ j += 1
+ i = 0
+ while i < len2:
+ newstr.chars[j].ch = s2.chars[i].ch
+ i += 1
+ j += 1
+ return newstr
+
+
Modified: pypy/dist/pypy/rpython/test/test_rstr.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rstr.py (original)
+++ pypy/dist/pypy/rpython/test/test_rstr.py Thu Jun 9 02:26:40 2005
@@ -42,3 +42,14 @@
typer.specialize()
#t.view()
t.checkgraphs()
+
+def test_concat():
+ def dummyfn(s1, s2):
+ return s1 + s2
+
+ t = Translator(dummyfn)
+ t.annotate([str, str])
+ typer = RPythonTyper(t.annotator)
+ typer.specialize()
+ #t.view()
+ t.checkgraphs()
More information about the Pypy-commit
mailing list