[pypy-svn] r26322 - in pypy/dist/pypy/rpython/ootypesystem: . test
nik at codespeak.net
nik at codespeak.net
Tue Apr 25 12:47:31 CEST 2006
Author: nik
Date: Tue Apr 25 12:47:23 2006
New Revision: 26322
Added:
pypy/dist/pypy/rpython/ootypesystem/test/test_oorecord.py
- copied, changed from r26319, pypy/dist/pypy/rpython/ootypesystem/test/test_ootuple.py
Removed:
pypy/dist/pypy/rpython/ootypesystem/test/test_ootuple.py
Modified:
pypy/dist/pypy/rpython/ootypesystem/ootype.py
pypy/dist/pypy/rpython/ootypesystem/rdict.py
pypy/dist/pypy/rpython/ootypesystem/rrange.py
pypy/dist/pypy/rpython/ootypesystem/rtuple.py
pypy/dist/pypy/rpython/ootypesystem/test/test_oolist.py
Log:
rename the Tuple type to "Record". Tuple was really too misleading.
Modified: pypy/dist/pypy/rpython/ootypesystem/ootype.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/ootype.py (original)
+++ pypy/dist/pypy/rpython/ootypesystem/ootype.py Tue Apr 25 12:47:23 2006
@@ -192,15 +192,15 @@
def _get_interp_class(self):
raise NotImplementedError
-class Tuple(BuiltinType):
+class Record(BuiltinType):
- # We try to keep Tuple as similar to Instance as possible, so backends
+ # We try to keep Record as similar to Instance as possible, so backends
# can treat them polymorphically, if they choose to do so.
def __init__(self, fields):
self._fields = frozendict()
self._add_fields(fields)
- self._null = _null_tuple(self)
+ self._null = _null_record(self)
def _add_fields(self, fields):
fields.copy()
@@ -212,7 +212,7 @@
return self._null
def _get_interp_class(self):
- return _tuple
+ return _record
def _field_type(self, name):
try:
@@ -836,7 +836,7 @@
self.__dict__["_TYPE"] = ITER
-class _tuple(object):
+class _record(object):
def __init__(self, TYPE):
self._items = {}
@@ -862,10 +862,10 @@
else:
return 0 # for all null tuples
-class _null_tuple(_null_mixin(_tuple), _tuple):
+class _null_record(_null_mixin(_record), _record):
- def __init__(self, TUPLE):
- self.__dict__["_TYPE"] = TUPLE
+ def __init__(self, RECORD):
+ self.__dict__["_TYPE"] = RECORD
def new(TYPE):
@@ -942,7 +942,7 @@
return instance._downcast(INSTANCE)
def ooidentityhash(inst):
- assert isinstance(typeOf(inst), (Instance, Tuple))
+ assert isinstance(typeOf(inst), (Instance, Record))
return inst._identityhash()
def setItemType(LIST, ITEMTYPE):
Modified: pypy/dist/pypy/rpython/ootypesystem/rdict.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/rdict.py (original)
+++ pypy/dist/pypy/rpython/ootypesystem/rdict.py Tue Apr 25 12:47:23 2006
@@ -220,7 +220,7 @@
KEYTYPE = self.r_dict.key_repr.lowleveltype
VALUETYPE = self.r_dict.value_repr.lowleveltype
ITER = ootype.DictItemsIterator(KEYTYPE, VALUETYPE)
- return ootype.Tuple({"iterator": ITER})
+ return ootype.Record({"iterator": ITER})
def ll_dictiter(ITER, d):
Modified: pypy/dist/pypy/rpython/ootypesystem/rrange.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/rrange.py (original)
+++ pypy/dist/pypy/rpython/ootypesystem/rrange.py Tue Apr 25 12:47:23 2006
@@ -1,11 +1,11 @@
-from pypy.rpython.ootypesystem.ootype import Signed, Tuple, new
+from pypy.rpython.ootypesystem.ootype import Signed, Record, new
from pypy.rpython.rrange import AbstractRangeRepr, AbstractRangeIteratorRepr
-RANGE = Tuple({"start": Signed, "stop": Signed})
-RANGEITER = Tuple({"next": Signed, "stop": Signed})
+RANGE = Record({"start": Signed, "stop": Signed})
+RANGEITER = Record({"next": Signed, "stop": Signed})
-RANGEST = Tuple({"start": Signed, "stop": Signed, "step": Signed})
-RANGESTITER = Tuple({"next": Signed, "stop": Signed, "step": Signed})
+RANGEST = Record({"start": Signed, "stop": Signed, "step": Signed})
+RANGESTITER = Record({"next": Signed, "stop": Signed, "step": Signed})
class RangeRepr(AbstractRangeRepr):
Modified: pypy/dist/pypy/rpython/ootypesystem/rtuple.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/rtuple.py (original)
+++ pypy/dist/pypy/rpython/ootypesystem/rtuple.py Tue Apr 25 12:47:23 2006
@@ -8,7 +8,7 @@
def __init__(self, rtyper, items_r):
AbstractTupleRepr.__init__(self, rtyper, items_r)
- #self.lowleveltype = ootype.Tuple(dict(zip(self.fieldnames, self.lltypes)))
+ #self.lowleveltype = ootype.Record(dict(zip(self.fieldnames, self.lltypes)))
self.lowleveltype = tuple_type(self.fieldnames, self.lltypes)
def newtuple(cls, llops, r_tuple, items_v):
Modified: pypy/dist/pypy/rpython/ootypesystem/test/test_oolist.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/test/test_oolist.py (original)
+++ pypy/dist/pypy/rpython/ootypesystem/test/test_oolist.py Tue Apr 25 12:47:23 2006
@@ -132,7 +132,7 @@
res = interpret(f, [3], type_system="ootype")
assert res == 3
- def dont_test_listtype_explosion(self):
+ def test_listtype_explosion(self):
def f(x):
l1 = [x]
l2 = [x]
@@ -148,3 +148,19 @@
r_l2 = typer.getrepr(s_l2)
assert r_l1.lowleveltype == r_l2.lowleveltype
+ def test_tupletype_explosion(self):
+ def f(x):
+ t1 = ([x], [x, x])
+ t2 = ([x, x], [x])
+ return t1, t2
+ t = TranslationContext()
+ a = t.buildannotator()
+ s = a.build_types(f, [int])
+ typer = t.buildrtyper(type_system="ootype")
+ typer.specialize()
+
+ s_t1, s_t2 = s.items
+ r_t1 = typer.getrepr(s_t1)
+ r_t2 = typer.getrepr(s_t2)
+ assert r_t1.lowleveltype == r_t2.lowleveltype
+
More information about the Pypy-commit
mailing list