[pypy-svn] r22543 - in pypy/dist/pypy/rpython/l3interp: . test

mwh at codespeak.net mwh at codespeak.net
Mon Jan 23 18:30:18 CET 2006


Author: mwh
Date: Mon Jan 23 18:30:16 2006
New Revision: 22543

Modified:
   pypy/dist/pypy/rpython/l3interp/convertgraph.py
   pypy/dist/pypy/rpython/l3interp/l3interp.py
   pypy/dist/pypy/rpython/l3interp/test/test_convert.py
Log:
(arre, mwh)
Actual, as opposed to pretend, support for void returns in the l3interpreter
and converter.


Modified: pypy/dist/pypy/rpython/l3interp/convertgraph.py
==============================================================================
--- pypy/dist/pypy/rpython/l3interp/convertgraph.py	(original)
+++ pypy/dist/pypy/rpython/l3interp/convertgraph.py	Mon Jan 23 18:30:16 2006
@@ -87,7 +87,8 @@
             return position - stacksizes[kind]    # < 0
 
     for v in block.inputargs:
-        push(v)
+        if v.concretetype is not lltype.Void:
+            push(v)
 
     insns = []
     l3block = model.Block(insns)
@@ -136,8 +137,9 @@
                       'dbl': [],
                       'ptr': []}
         for v in link.args:
-            kind = getkind(v.concretetype)
-            targetregs[kind].append(get(v))
+            if v.concretetype is not lltype.Void:
+                kind = getkind(v.concretetype)
+                targetregs[kind].append(get(v))
         return model.Link(convert_block(link.target, memo),
                           targetregs['int'] or None,
                           targetregs['dbl'] or None,

Modified: pypy/dist/pypy/rpython/l3interp/l3interp.py
==============================================================================
--- pypy/dist/pypy/rpython/l3interp/l3interp.py	(original)
+++ pypy/dist/pypy/rpython/l3interp/l3interp.py	Mon Jan 23 18:30:16 2006
@@ -24,6 +24,8 @@
     def __init__(self, ptrval):
         self.ptrval = ptrval
 
+class L3Nothing(L3Value):
+    pass
 
 def l3interpret(graph, args_int, args_dbl, args_ptr):
     assert len(args_int) == graph.nargs_int
@@ -40,6 +42,8 @@
         return L3Double(args_dbl.pop())
     if nint == 0 and ndbl == 0 and nptr == 1:
         return L3Pointer(args_ptr.pop())
+    if nint == 0 and ndbl == 0 and nptr == 0:
+        return L3Nothing()
     raise AssertionError("stacks corrupted")
 
 constant_offset = OffsetOf(lltype.Void)

Modified: pypy/dist/pypy/rpython/l3interp/test/test_convert.py
==============================================================================
--- pypy/dist/pypy/rpython/l3interp/test/test_convert.py	(original)
+++ pypy/dist/pypy/rpython/l3interp/test/test_convert.py	Mon Jan 23 18:30:16 2006
@@ -46,6 +46,14 @@
     result = l3interp.l3interpret(l3graph, [0], [], [])
     assert isinstance(result, l3interp.L3Integer)
     assert result.intval == 1
+
+def test_void_return():
+    def f():
+        pass
+    l3graph = l3ify(f, [])
+    result = l3interp.l3interpret(l3graph, [], [], [])
+    assert isinstance(result, l3interp.L3Nothing)
+    
     
 def test_convert_getfield():
     class C:



More information about the Pypy-commit mailing list