[pypy-svn] r14931 - in pypy/dist/pypy: rpython translator/c/src translator/c/test translator/goal

arigo at codespeak.net arigo at codespeak.net
Fri Jul 22 18:57:08 CEST 2005


Author: arigo
Date: Fri Jul 22 18:57:04 2005
New Revision: 14931

Modified:
   pypy/dist/pypy/rpython/rfloat.py
   pypy/dist/pypy/rpython/rint.py
   pypy/dist/pypy/translator/c/src/float.h
   pypy/dist/pypy/translator/c/test/test_annotated.py
   pypy/dist/pypy/translator/goal/ISSUES.txt
Log:
abs(float) in the rtyper and the C back-end.


Modified: pypy/dist/pypy/rpython/rfloat.py
==============================================================================
--- pypy/dist/pypy/rpython/rfloat.py	(original)
+++ pypy/dist/pypy/rpython/rfloat.py	Fri Jul 22 18:57:04 2005
@@ -124,6 +124,10 @@
         vlist = hop.inputargs(Float)
         return vlist[0]
 
+    def rtype_abs(_, hop):
+        vlist = hop.inputargs(Float)
+        return hop.genop('float_abs', vlist, resulttype=Float)
+
     def rtype_int(_, hop):
         vlist = hop.inputargs(Float)
         return hop.genop('cast_float_to_int', vlist, resulttype=Signed)

Modified: pypy/dist/pypy/rpython/rint.py
==============================================================================
--- pypy/dist/pypy/rpython/rint.py	(original)
+++ pypy/dist/pypy/rpython/rint.py	Fri Jul 22 18:57:04 2005
@@ -202,10 +202,6 @@
     def get_ll_eq_function(self):
         return None 
 
-    def rtype_float(_, hop):
-        vlist = hop.inputargs(Float)
-        return vlist[0]
-
     def rtype_chr(_, hop):
         vlist =  hop.inputargs(Signed)
         return hop.genop('cast_int_to_char', vlist, resulttype=Char)

Modified: pypy/dist/pypy/translator/c/src/float.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/float.h	(original)
+++ pypy/dist/pypy/translator/c/src/float.h	Fri Jul 22 18:57:04 2005
@@ -3,14 +3,11 @@
  /***  C header subsection: operations between floats      ***/
 
 
-/* XXX INCOMPLETE */
-
-
 /*** unary operations ***/
 
 #define OP_FLOAT_IS_TRUE(x,r,err)   OP_FLOAT_NE(x,0.0,r,err)
-#define OP_FLOAT_NEG(x,r,err)       r = -x; 
-
+#define OP_FLOAT_NEG(x,r,err)       r = -x;
+#define OP_FLOAT_ABS(x,r,err)       r = fabs(x);
 
 /***  binary operations ***/
 

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	Fri Jul 22 18:57:04 2005
@@ -158,3 +158,10 @@
             return g3.next.next.value
         fn = self.getcompiled(do_things)
         assert fn() == 1
+
+    def test_float_ops(self):
+        def f(x=float):
+            return abs((-x) ** 3 + 1)
+        fn = self.getcompiled(f)
+        assert fn(-4.5) == 92.125
+        assert fn(4.5) == 90.125

Modified: pypy/dist/pypy/translator/goal/ISSUES.txt
==============================================================================
--- pypy/dist/pypy/translator/goal/ISSUES.txt	(original)
+++ pypy/dist/pypy/translator/goal/ISSUES.txt	Fri Jul 22 18:57:04 2005
@@ -178,11 +178,6 @@
     .. block at 183 with 1 exits
     .. v437078 = simple_call((builtin_function_or_method ldexp), v437014, v437038)
 
-    TyperError-47: (pypy.objspace.std.floatobject:abs__Float)
-    unimplemented operation: 'abs' on <FloatRepr Float>
-    .. block at -1 EH with 1 exits
-    .. v588581 = abs(v588570)
-
     TyperError-48: (pypy.objspace.std.tupleobject:unwrap)
     missing PyObjRepr.rtype_method_append
     .. block at 38 with 1 exits



More information about the Pypy-commit mailing list