[pypy-svn] r29588 - in pypy/dist/pypy/rpython: . lltypesystem test
arigo at codespeak.net
arigo at codespeak.net
Sun Jul 2 16:13:18 CEST 2006
Author: arigo
Date: Sun Jul 2 16:13:17 2006
New Revision: 29588
Modified:
pypy/dist/pypy/rpython/lltypesystem/rtuple.py
pypy/dist/pypy/rpython/rstr.py
pypy/dist/pypy/rpython/test/test_rtuple.py
Log:
* Support ("%s" % whatever) in RPython, in addition to ("%s" % (whatever,))
* Mark tuple GcStructs as immutable.
Modified: pypy/dist/pypy/rpython/lltypesystem/rtuple.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/rtuple.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/rtuple.py Sun Jul 2 16:13:17 2006
@@ -21,7 +21,10 @@
def __init__(self, rtyper, items_r):
AbstractTupleRepr.__init__(self, rtyper, items_r)
fields = zip(self.fieldnames, self.lltypes)
- self.lowleveltype = Ptr(GcStruct('tuple%d' % len(self.items_r), *fields))
+ kwds = {'hints': {'immutable': True}}
+ self.lowleveltype = Ptr(GcStruct('tuple%d' % len(self.items_r),
+ *fields,
+ **kwds))
def newtuple(cls, llops, r_tuple, items_v):
# items_v should have the lowleveltype of the internal reprs
Modified: pypy/dist/pypy/rpython/rstr.py
==============================================================================
--- pypy/dist/pypy/rpython/rstr.py (original)
+++ pypy/dist/pypy/rpython/rstr.py Sun Jul 2 16:13:17 2006
@@ -203,6 +203,14 @@
def ll_str(self, s):
return s
+
+class __extend__(pairtype(AbstractStringRepr, Repr)):
+ def rtype_mod((r_str, _), hop):
+ # for the case where the 2nd argument is a tuple, see the
+ # overriding rtype_mod() below
+ return r_str.ll.do_stringformat(hop, [(hop.args_v[1], hop.args_r[1])])
+
+
class __extend__(pairtype(AbstractStringRepr, IntegerRepr)):
def rtype_getitem((r_str, r_int), hop):
string_repr = hop.rtyper.type_system.rstr.string_repr
@@ -220,9 +228,6 @@
hop.exception_is_here()
return hop.gendirectcall(llfn, v_str, v_index)
- def rtype_mod((r_str, r_int), hop):
- return r_str.ll.do_stringformat(hop, [(hop.args_v[1], hop.args_r[1])])
-
class __extend__(pairtype(AbstractStringRepr, AbstractSliceRepr)):
@@ -288,9 +293,6 @@
return hop.genop('int_gt', [vres, hop.inputconst(Signed, 0)],
resulttype=Bool)
- def rtype_mod((r_str1, r_str2), hop):
- return r_str1.ll.do_stringformat(hop, [(hop.args_v[1], hop.args_r[1])])
-
class __extend__(pairtype(AbstractStringRepr, AbstractCharRepr)):
def rtype_contains((r_str, r_chr), hop):
rstr = hop.rtyper.type_system.rstr
Modified: pypy/dist/pypy/rpython/test/test_rtuple.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rtuple.py (original)
+++ pypy/dist/pypy/rpython/test/test_rtuple.py Sun Jul 2 16:13:17 2006
@@ -12,7 +12,7 @@
assert rtuple.lowleveltype == Ptr(GcStruct('tuple2',
('item0', Signed),
('item1', Bool),
- ))
+ hints={'immutable': True}))
# ____________________________________________________________
More information about the Pypy-commit
mailing list