[pypy-svn] r39842 - in pypy/dist/pypy/rpython: . lltypesystem/module ootypesystem/module
antocuni at codespeak.net
antocuni at codespeak.net
Sat Mar 3 19:36:20 CET 2007
Author: antocuni
Date: Sat Mar 3 19:36:18 2007
New Revision: 39842
Added:
pypy/dist/pypy/rpython/extfuncregistry.py (contents, props changed)
Modified:
pypy/dist/pypy/rpython/extfunctable.py
pypy/dist/pypy/rpython/lltypesystem/module/ll_math.py
pypy/dist/pypy/rpython/ootypesystem/module/ll_math.py
Log:
(antocuni, pedronis)
trying again to fix the translation. Maybe this time we got it :-)
Added: pypy/dist/pypy/rpython/extfuncregistry.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/rpython/extfuncregistry.py Sat Mar 3 19:36:18 2007
@@ -0,0 +1,50 @@
+# this registry use the new interface for external functions
+# all the above declarations in extfunctable should be moved here at some point.
+
+import math
+from extfunc import register_external
+
+# ___________________________
+# math functions
+
+from pypy.rpython.lltypesystem.module import ll_math
+from pypy.rpython.ootypesystem.module import ll_math as oo_math
+
+# the following functions all take one float, return one float
+# and are part of math.h
+simple_math_functions = [
+ 'acos', 'asin', 'atan', 'ceil', 'cos', 'cosh', 'exp', 'fabs',
+ 'floor', 'log', 'log10', 'sin', 'sinh', 'sqrt', 'tan', 'tanh'
+ ]
+for name in simple_math_functions:
+ register_external(getattr(math, name), [float], float, "ll_math.ll_math_%s" % name)
+
+def frexp_hook():
+ from pypy.rpython.extfunctable import record_call
+ from pypy.annotation.model import SomeInteger, SomeTuple, SomeFloat
+ from pypy.rpython.lltypesystem.module.ll_math import ll_frexp_result
+ record_call(ll_frexp_result, (SomeFloat(), SomeInteger()), 'MATH_FREXP')
+
+def modf_hook():
+ from pypy.rpython.extfunctable import record_call
+ from pypy.annotation.model import SomeTuple, SomeFloat
+ from pypy.rpython.lltypesystem.module.ll_math import ll_modf_result
+ record_call(ll_modf_result, (SomeFloat(), SomeFloat()), 'MATH_MODF')
+
+complex_math_functions = [
+ ('frexp', [float], (float, int), frexp_hook),
+ ('atan2', [float, float], float, None),
+ ('fmod', [float, float], float, None),
+ ('ldexp', [float, int], float, None),
+ ('modf', [float], (float, float), modf_hook),
+ ('hypot', [float, float], float, None),
+ ('pow', [float, float], float, None),
+ ]
+
+for name, args, res, hook in complex_math_functions:
+ func = getattr(math, name)
+ llfake = getattr(ll_math, 'll_math_%s' % name, None)
+ oofake = getattr(oo_math, 'll_math_%s' % name, None)
+ register_external(func, args, res, 'll_math.ll_math_%s' % name,
+ llfakeimpl=llfake, oofakeimpl=oofake,
+ annotation_hook = hook)
Modified: pypy/dist/pypy/rpython/extfunctable.py
==============================================================================
--- pypy/dist/pypy/rpython/extfunctable.py (original)
+++ pypy/dist/pypy/rpython/extfunctable.py Sat Mar 3 19:36:18 2007
@@ -1,9 +1,9 @@
"""
information table about external functions for annotation/rtyping and backends
"""
+
import os
import time
-import math
import types
from pypy.rlib.rarithmetic import r_longlong
@@ -292,53 +292,3 @@
RuntimeError : True,
}
-
-
-# ______________________________________________________________
-# this declarations use the new interface for external functions
-# all the above declaration should me moved here at some point.
-
-from extfunc import register_external
-
-# ___________________________
-# math functions
-
-from pypy.rpython.lltypesystem.module import ll_math
-from pypy.rpython.ootypesystem.module import ll_math as oo_math
-
-# the following functions all take one float, return one float
-# and are part of math.h
-simple_math_functions = [
- 'acos', 'asin', 'atan', 'ceil', 'cos', 'cosh', 'exp', 'fabs',
- 'floor', 'log', 'log10', 'sin', 'sinh', 'sqrt', 'tan', 'tanh'
- ]
-for name in simple_math_functions:
- register_external(getattr(math, name), [float], float, "ll_math.ll_math_%s" % name)
-
-def frexp_hook():
- from pypy.annotation.model import SomeInteger, SomeTuple, SomeFloat
- from pypy.rpython.lltypesystem.module.ll_math import ll_frexp_result
- record_call(ll_frexp_result, (SomeFloat(), SomeInteger()), 'MATH_FREXP')
-
-def modf_hook():
- from pypy.annotation.model import SomeTuple, SomeFloat
- from pypy.rpython.lltypesystem.module.ll_math import ll_modf_result
- record_call(ll_modf_result, (SomeFloat(), SomeFloat()), 'MATH_MODF')
-
-complex_math_functions = [
- ('frexp', [float], (float, int), frexp_hook),
- ('atan2', [float, float], float, None),
- ('fmod', [float, float], float, None),
- ('ldexp', [float, int], float, None),
- ('modf', [float], (float, float), modf_hook),
- ('hypot', [float, float], float, None),
- ('pow', [float, float], float, None),
- ]
-
-for name, args, res, hook in complex_math_functions:
- func = getattr(math, name)
- llfake = getattr(ll_math, 'll_math_%s' % name, None)
- oofake = getattr(oo_math, 'll_math_%s' % name, None)
- register_external(func, args, res, 'll_math.ll_math_%s' % name,
- llfakeimpl=llfake, oofakeimpl=oofake,
- annotation_hook = hook)
Modified: pypy/dist/pypy/rpython/lltypesystem/module/ll_math.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/module/ll_math.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/module/ll_math.py Sat Mar 3 19:36:18 2007
@@ -16,10 +16,10 @@
tup.item1 = intpart
return tup
-def ll_math_frexp(cls, x):
+def ll_math_frexp(x):
mantissa, exponent = math.frexp(x)
return ll_frexp_result(mantissa, exponent)
-def ll_math_modf(cls, x):
+def ll_math_modf(x):
fracpart, intpart = math.modf(x)
return ll_modf_result(fracpart, intpart)
Modified: pypy/dist/pypy/rpython/ootypesystem/module/ll_math.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/module/ll_math.py (original)
+++ pypy/dist/pypy/rpython/ootypesystem/module/ll_math.py Sat Mar 3 19:36:18 2007
@@ -16,11 +16,11 @@
tup.item1 = intpart
return tup
-def ll_math_frexp(cls, x):
+def ll_math_frexp(x):
mantissa, exponent = math.frexp(x)
return ll_frexp_result(mantissa, exponent)
-def ll_math_modf(cls, x):
+def ll_math_modf(x):
fracpart, intpart = math.modf(x)
return ll_modf_result(fracpart, intpart)
More information about the Pypy-commit
mailing list