Author: Ronan Lamy <[email protected]>
Branch: kill-typesystem
Changeset: r65906:6cc0c7449118
Date: 2013-08-02 14:05 +0100
http://bitbucket.org/pypy/pypy/changeset/6cc0c7449118/
Log: merge lltypesystem.rtupletype into lltypesystem.rtuple
diff --git a/rpython/rtyper/lltypesystem/rtuple.py
b/rpython/rtyper/lltypesystem/rtuple.py
--- a/rpython/rtyper/lltypesystem/rtuple.py
+++ b/rpython/rtyper/lltypesystem/rtuple.py
@@ -3,7 +3,6 @@
from rpython.rtyper.rtuple import AbstractTupleRepr, AbstractTupleIteratorRepr
from rpython.rtyper.lltypesystem.lltype import \
Ptr, GcStruct, Void, Signed, malloc, typeOf, nullptr
-from rpython.rtyper.lltypesystem.rtupletype import TUPLE_TYPE
from rpython.rtyper.lltypesystem import rstr
# ____________________________________________________________
@@ -17,6 +16,16 @@
# ...
# }
+def TUPLE_TYPE(field_lltypes):
+ if len(field_lltypes) == 0:
+ return Void # empty tuple
+ else:
+ fields = [('item%d' % i, TYPE) for i, TYPE in enumerate(field_lltypes)]
+ kwds = {'hints': {'immutable': True,
+ 'noidentity': True}}
+ return Ptr(GcStruct('tuple%d' % len(field_lltypes), *fields, **kwds))
+
+
class TupleRepr(AbstractTupleRepr):
rstr_ll = rstr.LLHelpers
diff --git a/rpython/rtyper/lltypesystem/rtupletype.py
b/rpython/rtyper/lltypesystem/rtupletype.py
deleted file mode 100644
--- a/rpython/rtyper/lltypesystem/rtupletype.py
+++ /dev/null
@@ -1,15 +0,0 @@
-# Helper to build the lowleveltype corresponding to an RPython tuple.
-# This is not in rtuple.py so that it can be imported without bringing
-# the whole rtyper in.
-
-from rpython.rtyper.lltypesystem.lltype import Void, Ptr, GcStruct
-
-
-def TUPLE_TYPE(field_lltypes):
- if len(field_lltypes) == 0:
- return Void # empty tuple
- else:
- fields = [('item%d' % i, TYPE) for i, TYPE in enumerate(field_lltypes)]
- kwds = {'hints': {'immutable': True,
- 'noidentity': True}}
- return Ptr(GcStruct('tuple%d' % len(field_lltypes), *fields, **kwds))
diff --git a/rpython/rtyper/module/ll_os_stat.py
b/rpython/rtyper/module/ll_os_stat.py
--- a/rpython/rtyper/module/ll_os_stat.py
+++ b/rpython/rtyper/module/ll_os_stat.py
@@ -13,7 +13,7 @@
from rpython.rtyper.annlowlevel import hlstr
from rpython.rtyper.extfunc import extdef
from rpython.rtyper.lltypesystem import rffi, lltype
-from rpython.rtyper.lltypesystem.rtupletype import TUPLE_TYPE
+from rpython.rtyper.lltypesystem.rtuple import TUPLE_TYPE
from rpython.rtyper.tool import rffi_platform as platform
from rpython.tool.pairtype import pairtype
from rpython.tool.sourcetools import func_renamer
diff --git a/rpython/rtyper/test/test_rtuple.py
b/rpython/rtyper/test/test_rtuple.py
--- a/rpython/rtyper/test/test_rtuple.py
+++ b/rpython/rtyper/test/test_rtuple.py
@@ -1,15 +1,15 @@
-from rpython.rtyper.lltypesystem import rtupletype
+from rpython.rtyper.lltypesystem.rtuple import TUPLE_TYPE, TupleRepr
from rpython.rtyper.lltypesystem.lltype import Signed, Bool
from rpython.rtyper.rbool import bool_repr
from rpython.rtyper.rint import signed_repr
from rpython.rtyper.test.tool import BaseRtypingTest
+from rpython.rlib.objectmodel import compute_hash
from rpython.translator.translator import TranslationContext
def test_rtuple():
- from rpython.rtyper.lltypesystem.rtuple import TupleRepr
rtuple = TupleRepr(None, [signed_repr, bool_repr])
- assert rtuple.lowleveltype == rtupletype.TUPLE_TYPE([Signed, Bool])
+ assert rtuple.lowleveltype == TUPLE_TYPE([Signed, Bool])
# ____________________________________________________________
@@ -171,7 +171,6 @@
assert r_AB_tup.lowleveltype == r_BA_tup.lowleveltype
def test_tuple_hash(self):
- from rpython.rlib.objectmodel import compute_hash
def f(i, j):
return compute_hash((i, j))
@@ -180,7 +179,6 @@
assert res1 != res2
def test_constant_tuple_hash_str(self):
- from rpython.rlib.objectmodel import compute_hash
def f(i):
if i:
t = (None, "abc")
@@ -312,7 +310,6 @@
assert res is True
def test_tuple_hash_2(self):
- from rpython.rlib.objectmodel import compute_hash
def f(n):
return compute_hash((n, 6)) == compute_hash((3, n*2))
res = self.interpret(f, [3])
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit