[pypy-svn] r64471 - in pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem: . test

antocuni at codespeak.net antocuni at codespeak.net
Mon Apr 20 18:57:06 CEST 2009


Author: antocuni
Date: Mon Apr 20 18:57:05 2009
New Revision: 64471

Modified:
   pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/rclass.py
   pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/test/test_oortype.py
Log:
make sure that the _immutable_ hint is propagated to Instance._hints


Modified: pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/rclass.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/rclass.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/rclass.py	Mon Apr 20 18:57:05 2009
@@ -182,6 +182,9 @@
                 hints = classdef.classdesc.pyobj._rpython_hints
             else:
                 hints = {}
+            if '_immutable_' in self.classdef.classdesc.classdict:
+                hints = hints.copy()
+                hints['immutable'] = True
             self.lowleveltype = ootype.Instance(classdef.name, b, {}, {}, _hints = hints)
         self.prebuiltinstances = {}   # { id(x): (x, _ptr) }
         self.object_type = self.lowleveltype

Modified: pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/test/test_oortype.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/test/test_oortype.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/test/test_oortype.py	Mon Apr 20 18:57:05 2009
@@ -391,3 +391,15 @@
     assert res is c3
     res = interpret(fn, [3], type_system='ootype')
     assert res is c4
+
+def test_immutable_hint():
+    class I(object):
+        _immutable_ = True
+
+    i = I()
+    def f():
+        return i
+
+    g = gengraph(f)
+    rettype = g.getreturnvar().concretetype
+    assert rettype._hints['immutable']



More information about the Pypy-commit mailing list