[pypy-svn] r20881 - in pypy/dist/pypy/translator/c: src test

mwh at codespeak.net mwh at codespeak.net
Thu Dec 8 12:08:36 CET 2005


Author: mwh
Date: Thu Dec  8 12:08:34 2005
New Revision: 20881

Modified:
   pypy/dist/pypy/translator/c/src/int.h
   pypy/dist/pypy/translator/c/test/test_annotated.py
Log:
(mwh, johahn)

Copy test over from the rpython tests (...) and made it pass by
implementing a couple more operations in int.h


Modified: pypy/dist/pypy/translator/c/src/int.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/int.h	(original)
+++ pypy/dist/pypy/translator/c/src/int.h	Thu Dec  8 12:08:34 2005
@@ -156,6 +156,7 @@
 #define OP_CAST_BOOL_TO_UINT(x,r,err)   r = (unsigned long)(x)
 #define OP_CAST_UINT_TO_INT(x,r,err)    r = (long)(x)
 #define OP_CAST_INT_TO_UINT(x,r,err)    r = (unsigned long)(x)
+#define OP_CAST_INT_TO_LONGLONG(x,r,err) r = (long long)(x)
 #define OP_CAST_CHAR_TO_INT(x,r,err)    r = (long)((unsigned char)(x))
 #define OP_CAST_INT_TO_CHAR(x,r,err)    r = (char)(x)
 #define OP_CAST_PTR_TO_INT(x,r,err)     r = (long)(x)    /* XXX */
@@ -280,3 +281,4 @@
 
 #define OP_LLONG_MUL OP_INT_MUL
 #define OP_LLONG_EQ OP_INT_EQ
+#define OP_LLONG_ADD OP_INT_ADD

Modified: pypy/dist/pypy/translator/c/test/test_annotated.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_annotated.py	(original)
+++ pypy/dist/pypy/translator/c/test/test_annotated.py	Thu Dec  8 12:08:34 2005
@@ -245,3 +245,18 @@
             return 4*i
         gn = self.getcompiled(g, view=False)
         assert gn(sys.maxint) == 4*sys.maxint
+
+    def test_specializing_int_functions(self):
+        from pypy.rpython.rarithmetic import r_longlong
+        def f(i):
+            return i + 1
+        f._annspecialcase_ = "specialize:argtype0"
+        def g(n=int):
+            if n > 0:
+                return f(r_longlong(0))
+            else:
+                return f(0)
+
+        fn = self.getcompiled(g)
+        assert g(0) == 1
+        assert g(1) == 1



More information about the Pypy-commit mailing list