Author: Maciej Fijalkowski <[email protected]>
Branch: rpython-bytearray
Changeset: r59554:4c16a279f553
Date: 2012-12-26 12:19 +0200
http://bitbucket.org/pypy/pypy/changeset/4c16a279f553/
Log: fix the test
diff --git a/pypy/rpython/lltypesystem/rbytearray.py
b/pypy/rpython/lltypesystem/rbytearray.py
--- a/pypy/rpython/lltypesystem/rbytearray.py
+++ b/pypy/rpython/lltypesystem/rbytearray.py
@@ -13,7 +13,7 @@
copy_bytearray_contents_from_str = rstr._new_copy_contents_fun(rstr.STR,
BYTEARRAY,
lltype.Char,
- 'bytearray')
+
'bytearray_from_str')
BYTEARRAY.become(lltype.GcStruct('rpy_bytearray',
('chars', lltype.Array(lltype.Char)), adtmeths={
diff --git a/pypy/rpython/lltypesystem/rstr.py
b/pypy/rpython/lltypesystem/rstr.py
--- a/pypy/rpython/lltypesystem/rstr.py
+++ b/pypy/rpython/lltypesystem/rstr.py
@@ -328,13 +328,13 @@
# a single '+' like this is allowed to overflow: it gets
# a negative result, and the gc will complain
# the typechecks below are if TP == BYTEARRAY
- if typeOf(s1) == STR:
+ if typeOf(s1) == Ptr(STR):
newstr = s2.malloc(len1 + len2)
newstr.copy_contents_from_str(s1, newstr, 0, 0, len1)
else:
newstr = s1.malloc(len1 + len2)
newstr.copy_contents(s1, newstr, 0, 0, len1)
- if typeOf(s2) == STR:
+ if typeOf(s2) == Ptr(STR):
newstr.copy_contents_from_str(s2, newstr, 0, len1, len2)
else:
newstr.copy_contents(s2, newstr, 0, len1, len2)
diff --git a/pypy/rpython/rbytearray.py b/pypy/rpython/rbytearray.py
--- a/pypy/rpython/rbytearray.py
+++ b/pypy/rpython/rbytearray.py
@@ -20,8 +20,12 @@
return hop.gendirectcall(r_b1.ll.ll_strconcat, v_b1, v_str2)
class __extend__(pairtype(AbstractStringRepr, AbstractByteArrayRepr)):
- def rtype_add((r_s2, r_b1), hop):
- xxx
+ def rtype_add((r_s1, r_b2), hop):
+ str_repr = r_s1.repr
+ if hop.s_result.is_constant():
+ return hop.inputconst(r_b2, hop.s_result.const)
+ v_str1, v_b2 = hop.inputargs(str_repr, r_b2)
+ return hop.gendirectcall(r_b2.ll.ll_strconcat, v_str1, v_b2)
class __extend__(annmodel.SomeByteArray):
def rtyper_makekey(self):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit