[pypy-svn] r33229 - in pypy/dist/pypy/translator/cli: . src src/stub
antocuni at codespeak.net
antocuni at codespeak.net
Thu Oct 12 16:27:30 CEST 2006
Author: antocuni
Date: Thu Oct 12 16:27:28 2006
New Revision: 33229
Modified:
pypy/dist/pypy/translator/cli/prebuiltnodes.py
pypy/dist/pypy/translator/cli/src/ll_math.cs
pypy/dist/pypy/translator/cli/src/stub/main.il
Log:
Fix ll_math_{fmod,exp,sqrt}. Now lib-python/2.4.1/test/test_math
passes.
Modified: pypy/dist/pypy/translator/cli/prebuiltnodes.py
==============================================================================
--- pypy/dist/pypy/translator/cli/prebuiltnodes.py (original)
+++ pypy/dist/pypy/translator/cli/prebuiltnodes.py Thu Oct 12 16:27:28 2006
@@ -11,7 +11,16 @@
def raise_RuntimeError():
raise RuntimeError
-HELPERS = [(raise_RuntimeError, [])]
+def raise_OverflowError():
+ raise OverflowError
+
+def raise_ValueError():
+ raise ValueError
+
+HELPERS = [(raise_RuntimeError, []),
+ (raise_OverflowError, []),
+ (raise_ValueError, []),
+ ]
def _build_helpers(translator, db):
functions = set()
Modified: pypy/dist/pypy/translator/cli/src/ll_math.cs
==============================================================================
--- pypy/dist/pypy/translator/cli/src/ll_math.cs (original)
+++ pypy/dist/pypy/translator/cli/src/ll_math.cs Thu Oct 12 16:27:28 2006
@@ -14,7 +14,7 @@
public static double ll_math_fmod(double x, double y)
{
- return Math.IEEERemainder(x, y);
+ return x % y;
}
public static Record_Float_Float ll_math_modf(double x)
@@ -166,7 +166,10 @@
static public double ll_math_exp(double x)
{
- return Math.Exp(x);
+ double res = Math.Exp(x);
+ if (double.IsPositiveInfinity(res))
+ Helpers.raise_OverflowError();
+ return res;
}
static public double ll_math_fabs(double x)
@@ -206,7 +209,10 @@
static public double ll_math_sqrt(double x)
{
- return Math.Sqrt(x);
+ double res = Math.Sqrt(x);
+ if (double.IsNaN(res))
+ Helpers.raise_ValueError();
+ return res;
}
static public double ll_math_tan(double x)
Modified: pypy/dist/pypy/translator/cli/src/stub/main.il
==============================================================================
--- pypy/dist/pypy/translator/cli/src/stub/main.il (original)
+++ pypy/dist/pypy/translator/cli/src/stub/main.il Thu Oct 12 16:27:28 2006
@@ -42,5 +42,21 @@
throw
ret
}
+
+ .method public static void raise_OverflowError() il managed
+ {
+ ldstr "This is only a stub, it should not be called"
+ newobj instance void class [mscorlib]System.ApplicationException::.ctor(string)
+ throw
+ ret
+ }
+
+ .method public static void raise_ValueError() il managed
+ {
+ ldstr "This is only a stub, it should not be called"
+ newobj instance void class [mscorlib]System.ApplicationException::.ctor(string)
+ throw
+ ret
+ }
}
}
More information about the Pypy-commit
mailing list