[pypy-svn] r27627 - in pypy/dist/pypy/translator/stackless: . test

arigo at codespeak.net arigo at codespeak.net
Tue May 23 18:24:04 CEST 2006


Author: arigo
Date: Tue May 23 18:24:03 2006
New Revision: 27627

Modified:
   pypy/dist/pypy/translator/stackless/test/test_transform.py
   pypy/dist/pypy/translator/stackless/transform.py
Log:
Fix for Void variables that are passed around and used later.
(This is a rare situation, so it didn't show up before.)


Modified: pypy/dist/pypy/translator/stackless/test/test_transform.py
==============================================================================
--- pypy/dist/pypy/translator/stackless/test/test_transform.py	(original)
+++ pypy/dist/pypy/translator/stackless/test/test_transform.py	Tue May 23 18:24:03 2006
@@ -226,6 +226,21 @@
             if op.args[0].value._obj._callable is f:
                 assert op != block.operations[-1]
 
+def test_void_around():
+    def f():
+        return 6
+    def getf():
+        return f
+    def g():
+        f1 = getf()
+        for i in range(5):
+            rstack.stack_unwind()
+        return f1
+    def example():
+        return g()()
+    res = llinterp_stackless_function(example)
+    assert res == 6
+
 def rtype_stackless_function(fn):
     t = TranslationContext()
     annotator = t.buildannotator()

Modified: pypy/dist/pypy/translator/stackless/transform.py
==============================================================================
--- pypy/dist/pypy/translator/stackless/transform.py	(original)
+++ pypy/dist/pypy/translator/stackless/transform.py	Tue May 23 18:24:03 2006
@@ -320,11 +320,13 @@
                 assert arg is not resume_point.var_result
                 t = storage_type(arg.concretetype)
                 if t is lltype.Void:
-                    continue
-                fname = model.Constant(resume_point.fieldnames[i], lltype.Void)
-                v_newarg = llops.genop('getfield', [frame_top, fname],
-                                       resulttype = t)
-                v_newarg = gen_cast(llops, arg.concretetype, v_newarg)
+                    v_newarg = model.Constant(None, lltype.Void)
+                else:
+                    fname = model.Constant(resume_point.fieldnames[i],
+                                           lltype.Void)
+                    v_newarg = llops.genop('getfield', [frame_top, fname],
+                                           resulttype = t)
+                    v_newarg = gen_cast(llops, arg.concretetype, v_newarg)
                 varmap[arg] = v_newarg
 
             rettype = storage_type(resume_point.var_result.concretetype)
@@ -460,7 +462,6 @@
                 for l in block.exits:
                     for arg in l.args:
                         if isinstance(arg, model.Variable) \
-                           and arg.concretetype is not lltype.Void \
                            and arg is not op.result \
                            and arg not in args \
                            and arg not in [l.last_exception, l.last_exc_value]:



More information about the Pypy-commit mailing list