[pypy-svn] r39838 - in pypy/dist/pypy: rpython translator/c translator/c/test translator/llvm

antocuni at codespeak.net antocuni at codespeak.net
Sat Mar 3 18:57:23 CET 2007


Author: antocuni
Date: Sat Mar  3 18:56:54 2007
New Revision: 39838

Modified:
   pypy/dist/pypy/rpython/extfunc.py
   pypy/dist/pypy/translator/c/node.py
   pypy/dist/pypy/translator/c/test/test_standalone.py
   pypy/dist/pypy/translator/llvm/database.py
Log:
(antocuni, pedronis)

fix the translation again. We don't want to attach _entry to the
functions, because they doesn't compare equal and can confuse
backends.




Modified: pypy/dist/pypy/rpython/extfunc.py
==============================================================================
--- pypy/dist/pypy/rpython/extfunc.py	(original)
+++ pypy/dist/pypy/rpython/extfunc.py	Sat Mar  3 18:56:54 2007
@@ -56,7 +56,7 @@
                 impl.im_func, self.signature_args, self.signature_result)
         else:
             obj = rtyper.type_system.getexternalcallable(args_ll, ll_result,
-                                 name, _entry=self, _callable=fakeimpl)
+                                 name, _external_name=self.name, _callable=fakeimpl)
         vlist = [hop.inputconst(typeOf(obj), obj)] + hop.inputargs(*args_r)
         hop.exception_is_here()
         return hop.genop('direct_call', vlist, r_result)
@@ -84,13 +84,13 @@
         signature_result = annotation(result, None)
         name=export_name
         if llimpl:
-            lltypeimpl = llimpl
+            lltypeimpl = staticmethod(llimpl)
         if ooimpl:
-            ootypeimpl = ooimpl
+            ootypeimpl = staticmethd(ooimpl)
         if llfakeimpl:
-            lltypefakeimpl = llfakeimpl
+            lltypefakeimpl = staticmethod(llfakeimpl)
         if oofakeimpl:
-            ootypefakeimpl = oofakeimpl
+            ootypefakeimpl = staticmethod(oofakeimpl)
         if annotation_hook:
             ann_hook = staticmethod(annotation_hook)
 
@@ -104,7 +104,6 @@
         func = func.value
     if getattr(func._callable, 'suggested_primitive', False):
         return True
-    if hasattr(func, '_entry'):
-        if isinstance(func._entry, ExtFuncEntry):
-            return True
+    if hasattr(func, '_external_name'):
+        return True
     return False

Modified: pypy/dist/pypy/translator/c/node.py
==============================================================================
--- pypy/dist/pypy/translator/c/node.py	(original)
+++ pypy/dist/pypy/translator/c/node.py	Sat Mar  3 18:56:54 2007
@@ -688,8 +688,8 @@
         funcgen.implementation_end()
 
 def select_function_code_generators(fnobj, db, functionname):
-    if hasattr(fnobj, '_entry'):
-        db.externalfuncs[fnobj._entry.name] = fnobj
+    if hasattr(fnobj, '_external_name'):
+        db.externalfuncs[fnobj._external_name] = fnobj
         return []
     elif fnobj._callable in extfunc.EXTERNALS:
         # 'fnobj' is one of the ll_xyz() functions with the suggested_primitive

Modified: pypy/dist/pypy/translator/c/test/test_standalone.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_standalone.py	(original)
+++ pypy/dist/pypy/translator/c/test/test_standalone.py	Sat Mar  3 18:56:54 2007
@@ -118,3 +118,20 @@
     out = py.process.cmdexec("%s 500" % exe)
     assert int(out) == 500*501/2
     
+def test_frexp():
+    import math
+    def entry_point(argv):
+        m, e = math.frexp(0)
+        x, y = math.frexp(0)
+        print m, x
+        return 0
+
+    t = TranslationContext()
+    t.buildannotator().build_types(entry_point, [s_list_of_strings])
+    t.buildrtyper().specialize()
+
+    cbuilder = CStandaloneBuilder(t, entry_point, t.config)
+    cbuilder.generate_source()
+    cbuilder.compile()
+    data = cbuilder.cmdexec('hi there')
+    assert map(float, data.split()) == [0.0, 0.0]

Modified: pypy/dist/pypy/translator/llvm/database.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/database.py	(original)
+++ pypy/dist/pypy/translator/llvm/database.py	Sat Mar  3 18:56:54 2007
@@ -58,8 +58,8 @@
         if isinstance(type_, lltype.FuncType):
             if getattr(value._callable, "suggested_primitive", False):
                 node = ExternalFuncNode(self, value)
-            elif hasattr(value, '_entry'):
-                node = ExternalFuncNode(self, value, value._entry.name)
+            elif hasattr(value, '_external_name'):
+                node = ExternalFuncNode(self, value, value._external_name)
 
             elif getattr(value, 'external', None) == 'C':
                 node = SimplerExternalFuncNode(self, value)


More information about the pypy-svn mailing list