[pypy-svn] r46295 - in pypy/dist/pypy/translator/jvm: . src/pypy test

antocuni at codespeak.net antocuni at codespeak.net
Mon Sep 3 22:37:28 CEST 2007


Author: antocuni
Date: Mon Sep  3 22:37:28 2007
New Revision: 46295

Modified:
   pypy/dist/pypy/translator/jvm/database.py
   pypy/dist/pypy/translator/jvm/generator.py
   pypy/dist/pypy/translator/jvm/src/pypy/PyPy.java
   pypy/dist/pypy/translator/jvm/test/test_builtin.py
Log:
correctly implement generator.call_primitive. Implement ll_math.{fmod,floor}.



Modified: pypy/dist/pypy/translator/jvm/database.py
==============================================================================
--- pypy/dist/pypy/translator/jvm/database.py	(original)
+++ pypy/dist/pypy/translator/jvm/database.py	Mon Sep  3 22:37:28 2007
@@ -119,12 +119,15 @@
         then the return would be:
           ( (jString, jString), jBool )
         """
-        argtypes = [arg.concretetype for arg in graph.getargs()
-                    if arg.concretetype is not ootype.Void]
-        jargtypes = tuple([self.lltype_to_cts(argty) for argty in argtypes])
-        rettype = graph.getreturnvar().concretetype
-        jrettype = self.lltype_to_cts(rettype)
-        return jargtypes, jrettype        
+        ARGS = [v.concretetype for v in graph.getargs()]
+        RESULT = graph.getreturnvar().concretetype
+        return self.types_for_signature(ARGS, RESULT)
+
+    def types_for_signature(self, ARGS, RESULT):
+        ARGS = [ARG for ARG in ARGS if ARG is not ootype.Void]
+        jargtypes = tuple([self.lltype_to_cts(ARG) for ARG in ARGS])
+        jrettype = self.lltype_to_cts(RESULT)
+        return jargtypes, jrettype
     
     def _function_for_graph(self, classobj, funcnm, is_static, graph):
         

Modified: pypy/dist/pypy/translator/jvm/generator.py
==============================================================================
--- pypy/dist/pypy/translator/jvm/generator.py	(original)
+++ pypy/dist/pypy/translator/jvm/generator.py	Mon Sep  3 22:37:28 2007
@@ -1015,9 +1015,9 @@
             self.prepare_generic_result(RETTYPE)
 
     def call_primitive(self, op, module, name):
-        graph = op.args[0].value # XXX
-        argtypes, rettype = self.db.types_for_graph(graph)
-        mthd = Method.s(jPyPy, graph.func.func_name, argtypes, rettype)
+        callee = op.args[0].value
+        argtypes, rettype = self.db.types_for_signature(callee._TYPE.ARGS, callee._TYPE.RESULT)
+        mthd = Method.s(jPyPy, name, argtypes, rettype)
         self.emit(mthd)
 
     def call_oostring(self, OOTYPE):

Modified: pypy/dist/pypy/translator/jvm/src/pypy/PyPy.java
==============================================================================
--- pypy/dist/pypy/translator/jvm/src/pypy/PyPy.java	(original)
+++ pypy/dist/pypy/translator/jvm/src/pypy/PyPy.java	Mon Sep  3 22:37:28 2007
@@ -884,6 +884,19 @@
     }
 
     // ----------------------------------------------------------------------
+    // ll_math
+
+    public static double ll_math_floor(double x)
+    {
+        return Math.floor(x);
+    }
+
+    public static double ll_math_fmod(double x, double y)
+    {
+        return x % y;
+    }
+
+    // ----------------------------------------------------------------------
     // Convenient Helpers for throwing exceptions
     //
     // Also, an abstraction barrier: at a later date we may want to

Modified: pypy/dist/pypy/translator/jvm/test/test_builtin.py
==============================================================================
--- pypy/dist/pypy/translator/jvm/test/test_builtin.py	(original)
+++ pypy/dist/pypy/translator/jvm/test/test_builtin.py	Mon Sep  3 22:37:28 2007
@@ -27,13 +27,7 @@
     
     def test_os_isdir(self):
         py.test.skip("ll_os_stat is not currently implemented in the Jvm backed")
-    
-    def test_builtin_math_floor(self):
-        py.test.skip("metavm.py needs to be updated to handle this math op; graphless extrernal")
-        
-    def test_builtin_math_fmod(self):
-        py.test.skip("metavm.py needs to be updated to handle this math op; graphless extrernal")
-        
+            
     def test_builtin_math_frexp(self):
         py.test.skip("metavm.py needs to be updated to handle this math op; graphless extrernal")
         


More information about the pypy-svn mailing list