[pypy-commit] pypy value-classes: GcStruct support for value_class hint

sbauman pypy.commits at gmail.com
Tue Sep 20 15:04:59 EDT 2016


Author: Spenser Bauman <sabauma at gmail.com>
Branch: value-classes
Changeset: r87260:c37f0db2879f
Date: 2016-09-20 15:03 -0400
http://bitbucket.org/pypy/pypy/changeset/c37f0db2879f/

Log:	GcStruct support for value_class hint

diff --git a/rpython/rtyper/lltypesystem/lltype.py b/rpython/rtyper/lltypesystem/lltype.py
--- a/rpython/rtyper/lltypesystem/lltype.py
+++ b/rpython/rtyper/lltypesystem/lltype.py
@@ -370,7 +370,8 @@
         return _struct(self, n, initialization='example')
 
     def _immutable_field(self, field):
-        if self._hints.get('immutable'):
+        if (self._hints.get('immutable') or
+            self._hints.get('value_class')):
             return True
         if 'immutable_fields' in self._hints:
             try:
diff --git a/rpython/rtyper/lltypesystem/test/test_lltype.py b/rpython/rtyper/lltypesystem/test/test_lltype.py
--- a/rpython/rtyper/lltypesystem/test/test_lltype.py
+++ b/rpython/rtyper/lltypesystem/test/test_lltype.py
@@ -787,6 +787,11 @@
                  hints={'immutable_fields': FieldListAccessor({'x': 1234})})
     assert S._immutable_field('x') == 1234
 
+def test_value_class_hint():
+    S = GcStruct('S', ('x', lltype.Signed), hints={'value_class': True})
+    assert S._immutable_field('x') == True
+    assert S._hints.get('value_class', False) == True
+
 def test_typedef():
     T = Typedef(Signed, 'T')
     assert T == Signed


More information about the pypy-commit mailing list