[pypy-svn] r21766 - in pypy/dist/pypy/translator/llvm: . test

rxe at codespeak.net rxe at codespeak.net
Sat Jan 7 00:04:25 CET 2006


Author: rxe
Date: Sat Jan  7 00:04:23 2006
New Revision: 21766

Modified:
   pypy/dist/pypy/translator/llvm/opwriter.py
   pypy/dist/pypy/translator/llvm/test/test_genllvm.py
Log:
indirect_call() - remove XXX and add a test. 



Modified: pypy/dist/pypy/translator/llvm/opwriter.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/opwriter.py	(original)
+++ pypy/dist/pypy/translator/llvm/opwriter.py	Sat Jan  7 00:04:23 2006
@@ -255,7 +255,7 @@
         self.codewriter.call(opr.retref, opr.rettype, opr.argrefs[0],
                              opr.argtypes[1:], opr.argrefs[1:])
 
-    indirect_call = direct_call # XXX for now
+    indirect_call = direct_call
 
     def malloc(self, opr):
         arg_type = opr.op.args[0].value

Modified: pypy/dist/pypy/translator/llvm/test/test_genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/test/test_genllvm.py	(original)
+++ pypy/dist/pypy/translator/llvm/test/test_genllvm.py	Sat Jan  7 00:04:23 2006
@@ -45,6 +45,28 @@
     assert f(0) == invokepointer(0)
     assert f(1) == invokepointer(1)
 
+def test_invoke_function_pointer2(): 
+    def f1(x):
+        if x>0:
+            raise Exception("bla")
+        return 10
+    def f2(x):
+        return 5
+
+    l = [f1, f2]
+
+    def invokepointer(i,j): 
+        try:
+            return l[i](i)
+        except:
+            return 123
+
+    f = compile_function(invokepointer, [int, int])
+    assert f(0, 0) == invokepointer(0, 0)
+    assert f(0, 1) == invokepointer(0, 1)
+    assert f(1, 0) == invokepointer(1, 0)
+    assert f(1, 1) == invokepointer(1, 1)
+
 def test_simple_branching():
     def simple5(b):
         if b:



More information about the Pypy-commit mailing list