[pypy-commit] pypy stm: fix.

arigo noreply at buildbot.pypy.org
Sat Nov 5 18:03:10 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: stm
Changeset: r48795:caad8bf3d4ae
Date: 2011-11-05 18:01 +0100
http://bitbucket.org/pypy/pypy/changeset/caad8bf3d4ae/

Log:	fix.

diff --git a/pypy/translator/stm/funcgen.py b/pypy/translator/stm/funcgen.py
--- a/pypy/translator/stm/funcgen.py
+++ b/pypy/translator/stm/funcgen.py
@@ -4,7 +4,7 @@
 from pypy.translator.stm.rstm import size_of_voidp
 
 
-def _stm_generic_get(funcgen, op, expr):
+def _stm_generic_get(funcgen, op, expr, simple_struct=False):
     T = funcgen.lltypemap(op.result)
     resulttypename = funcgen.db.gettype(T)
     cresulttypename = cdecl(resulttypename, '')
@@ -27,11 +27,11 @@
         return '%s = (%s)%s((long*)&%s);' % (
             newvalue, cresulttypename, funcname, expr)
     else:
-        STRUCT = funcgen.lltypemap(op.args[0]).TO
-        if isinstance(STRUCT, lltype.Struct):
+        if simple_struct:
             # assume that the object is aligned, and any possible misalignment
             # comes from the field offset, so that it can be resolved at
             # compile-time (by using C macros)
+            STRUCT = funcgen.lltypemap(op.args[0]).TO
             structdef = funcgen.db.gettypedefnode(STRUCT)
             basename = funcgen.expr(op.args[0])
             fieldname = op.args[1].value
@@ -85,7 +85,7 @@
 
 def stm_getfield(funcgen, op):
     expr = field_expr(funcgen, op.args)
-    return _stm_generic_get(funcgen, op, expr)
+    return _stm_generic_get(funcgen, op, expr, simple_struct=True)
 
 def stm_setfield(funcgen, op):
     expr = field_expr(funcgen, op.args)


More information about the pypy-commit mailing list