[pypy-commit] pypy stm: Must also be supported if the outermost container is an array.
arigo
noreply at buildbot.pypy.org
Tue Jan 24 16:49:06 CET 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: stm
Changeset: r51711:6776525c81d5
Date: 2012-01-23 18:24 +0100
http://bitbucket.org/pypy/pypy/changeset/6776525c81d5/
Log: Must also be supported if the outermost container is an array.
diff --git a/pypy/rpython/lltypesystem/lltype.py b/pypy/rpython/lltypesystem/lltype.py
--- a/pypy/rpython/lltypesystem/lltype.py
+++ b/pypy/rpython/lltypesystem/lltype.py
@@ -197,6 +197,19 @@
def _container_example(self):
raise NotImplementedError
+ def _immutable_interiorfield(self, fields):
+ T = self
+ for fieldname in fields: # may also be None or an integer, for arrays
+ if T._immutable_field(fieldname):
+ return True
+ if isinstance(fieldname, str):
+ assert isinstance(T, Struct)
+ T = getattr(T, fieldname)
+ else:
+ assert isinstance(T, Array)
+ T = T.OF
+ return False
+
class Typedef(LowLevelType):
"""A typedef is just another name for an existing type"""
@@ -352,19 +365,6 @@
pass
return False
- def _immutable_interiorfield(self, fields):
- T = self
- for fieldname in fields: # may also be None or an integer, for arrays
- if T._immutable_field(fieldname):
- return True
- if isinstance(fieldname, str):
- assert isinstance(T, Struct)
- T = getattr(T, fieldname)
- else:
- assert isinstance(T, Array)
- T = T.OF
- return False
-
class RttiStruct(Struct):
_runtime_type_info = None
diff --git a/pypy/rpython/lltypesystem/test/test_lltype.py b/pypy/rpython/lltypesystem/test/test_lltype.py
--- a/pypy/rpython/lltypesystem/test/test_lltype.py
+++ b/pypy/rpython/lltypesystem/test/test_lltype.py
@@ -829,12 +829,16 @@
S = GcStruct('S', ('ar', A))
immut = S._immutable_interiorfield(['ar', 4, 'a'])
assert immut == expected
+ immut = A._immutable_interiorfield([4, 'a'])
+ assert immut == expected
#
T = Struct('T', ('a', lltype.Signed))
A = Array(T, hints=hints)
S = GcStruct('S', ('ar', A))
immut = S._immutable_interiorfield(['ar', 4, 'a'])
assert immut == expected
+ immut = A._immutable_interiorfield([4, 'a'])
+ assert immut == expected
def test_typedef():
More information about the pypy-commit
mailing list