[pypy-svn] r47258 - pypy/branch/kill-keepalives-again/pypy/rpython/lltypesystem

arigo at codespeak.net arigo at codespeak.net
Sun Oct 7 13:41:12 CEST 2007


Author: arigo
Date: Sun Oct  7 13:41:12 2007
New Revision: 47258

Modified:
   pypy/branch/kill-keepalives-again/pypy/rpython/lltypesystem/opimpl.py
Log:
op_getinteriorfield() was too strict about checking for _immutable everywhere.


Modified: pypy/branch/kill-keepalives-again/pypy/rpython/lltypesystem/opimpl.py
==============================================================================
--- pypy/branch/kill-keepalives-again/pypy/rpython/lltypesystem/opimpl.py	(original)
+++ pypy/branch/kill-keepalives-again/pypy/rpython/lltypesystem/opimpl.py	Sun Oct  7 13:41:12 2007
@@ -133,15 +133,17 @@
 def op_getinteriorfield(obj, *offsets):
     checkptr(obj)
     ob = obj
-    T = lltype.typeOf(obj).TO
     for o in offsets:
-        if not T._hints.get('immutable'):
-            raise TypeError("cannot fold getinteriorfield on mutable struct")
+        innermostcontainer = ob
         if isinstance(o, str):
             ob = getattr(ob, o)
-            T = getattr(T, o)
         else:
-            raise TypeError("cannot fold getfield on mutable struct")
+            ob = ob[o]
+    # we can constant-fold this if the innermost structure from which we
+    # read the final field is immutable.
+    T = lltype.typeOf(innermostcontainer).TO
+    if not T._hints.get('immutable'):
+        raise TypeError("cannot fold getinteriorfield on mutable struct")
     assert not isinstance(ob, lltype._interior_ptr)
     return ob
 


More information about the pypy-svn mailing list