diff -r 1376481f15e7 -r 2377bb30dd1b emul/src/main/java/java/lang/Math.java --- a/emul/src/main/java/java/lang/Math.java Tue Oct 16 11:55:56 2012 +0200 +++ b/emul/src/main/java/java/lang/Math.java Tue Oct 30 23:33:29 2012 +0100 @@ -118,8 +118,9 @@ * @param a an angle, in radians. * @return the sine of the argument. */ + @JavaScriptBody(args="a", body="return Math.sin(a);") public static double sin(double a) { - return StrictMath.sin(a); // default impl. delegates to StrictMath + throw new UnsupportedOperationException(); } /** @@ -133,8 +134,9 @@ * @param a an angle, in radians. * @return the cosine of the argument. */ + @JavaScriptBody(args="a", body="return Math.cos(a);") public static double cos(double a) { - return StrictMath.cos(a); // default impl. delegates to StrictMath + throw new UnsupportedOperationException(); } /** @@ -150,8 +152,9 @@ * @param a an angle, in radians. * @return the tangent of the argument. */ + @JavaScriptBody(args="a", body="return Math.tan(a);") public static double tan(double a) { - return StrictMath.tan(a); // default impl. delegates to StrictMath + throw new UnsupportedOperationException(); } /** @@ -168,8 +171,9 @@ * @param a the value whose arc sine is to be returned. * @return the arc sine of the argument. */ + @JavaScriptBody(args="a", body="return Math.asin(a);") public static double asin(double a) { - return StrictMath.asin(a); // default impl. delegates to StrictMath + throw new UnsupportedOperationException(); } /** @@ -184,8 +188,9 @@ * @param a the value whose arc cosine is to be returned. * @return the arc cosine of the argument. */ + @JavaScriptBody(args="a", body="return Math.acos(a);") public static double acos(double a) { - return StrictMath.acos(a); // default impl. delegates to StrictMath + throw new UnsupportedOperationException(); } /** @@ -201,8 +206,9 @@ * @param a the value whose arc tangent is to be returned. * @return the arc tangent of the argument. */ + @JavaScriptBody(args="a", body="return Math.atan(a);") public static double atan(double a) { - return StrictMath.atan(a); // default impl. delegates to StrictMath + throw new UnsupportedOperationException(); } /** @@ -251,8 +257,9 @@ * @return the value e{@code a}, * where e is the base of the natural logarithms. */ + @JavaScriptBody(args="a", body="return Math.exp(a);") public static double exp(double a) { - return StrictMath.exp(a); // default impl. delegates to StrictMath + throw new UnsupportedOperationException(); } /** @@ -272,8 +279,9 @@ * @return the value ln {@code a}, the natural logarithm of * {@code a}. */ + @JavaScriptBody(args="a", body="return Math.log(a);") public static double log(double a) { - return StrictMath.log(a); // default impl. delegates to StrictMath + throw new UnsupportedOperationException(); } /** @@ -297,8 +305,9 @@ * @return the base 10 logarithm of {@code a}. * @since 1.5 */ + @JavaScriptBody(args="a", body="return Math.log(a) / Math.LN10;") public static double log10(double a) { - return StrictMath.log10(a); // default impl. delegates to StrictMath + throw new UnsupportedOperationException(); } /** @@ -318,69 +327,9 @@ * @return the positive square root of {@code a}. * If the argument is NaN or less than zero, the result is NaN. */ + @JavaScriptBody(args="a", body="return Math.sqrt(a);") public static double sqrt(double a) { - return StrictMath.sqrt(a); // default impl. delegates to StrictMath - // Note that hardware sqrt instructions - // frequently can be directly used by JITs - // and should be much faster than doing - // Math.sqrt in software. - } - - - /** - * Returns the cube root of a {@code double} value. For - * positive finite {@code x}, {@code cbrt(-x) == - * -cbrt(x)}; that is, the cube root of a negative value is - * the negative of the cube root of that value's magnitude. - * - * Special cases: - * - * - * - *

The computed result must be within 1 ulp of the exact result. - * - * @param a a value. - * @return the cube root of {@code a}. - * @since 1.5 - */ - public static double cbrt(double a) { - return StrictMath.cbrt(a); - } - - /** - * Computes the remainder operation on two arguments as prescribed - * by the IEEE 754 standard. - * The remainder value is mathematically equal to - * f1 - f2 × n, - * where n is the mathematical integer closest to the exact - * mathematical value of the quotient {@code f1/f2}, and if two - * mathematical integers are equally close to {@code f1/f2}, - * then n is the integer that is even. If the remainder is - * zero, its sign is the same as the sign of the first argument. - * Special cases: - *

- * - * @param f1 the dividend. - * @param f2 the divisor. - * @return the remainder when {@code f1} is divided by - * {@code f2}. - */ - public static double IEEEremainder(double f1, double f2) { - return StrictMath.IEEEremainder(f1, f2); // delegate to StrictMath + throw new UnsupportedOperationException(); } /** @@ -402,8 +351,9 @@ * floating-point value that is greater than or equal to * the argument and is equal to a mathematical integer. */ + @JavaScriptBody(args="a", body="return Math.ceil(a);") public static double ceil(double a) { - return StrictMath.ceil(a); // default impl. delegates to StrictMath + throw new UnsupportedOperationException(); } /** @@ -421,27 +371,9 @@ * floating-point value that less than or equal to the argument * and is equal to a mathematical integer. */ + @JavaScriptBody(args="a", body="return Math.floor(a);") public static double floor(double a) { - return StrictMath.floor(a); // default impl. delegates to StrictMath - } - - /** - * Returns the {@code double} value that is closest in value - * to the argument and is equal to a mathematical integer. If two - * {@code double} values that are mathematical integers are - * equally close, the result is the integer value that is - * even. Special cases: - * - * - * @param a a {@code double} value. - * @return the closest floating-point value to {@code a} that is - * equal to a mathematical integer. - */ - public static double rint(double a) { - return StrictMath.rint(a); // default impl. delegates to StrictMath + throw new UnsupportedOperationException(); } /** @@ -496,8 +428,9 @@ * in polar coordinates that corresponds to the point * (xy) in Cartesian coordinates. */ + @JavaScriptBody(args={"y", "x"}, body="return Math.atan2(y, x);") public static double atan2(double y, double x) { - return StrictMath.atan2(y, x); // default impl. delegates to StrictMath + throw new UnsupportedOperationException(); } /** @@ -623,8 +556,9 @@ * @param b the exponent. * @return the value {@code a}{@code b}. */ + @JavaScriptBody(args={"a", "b"}, body="return Math.pow(a, b);") public static double pow(double a, double b) { - return StrictMath.pow(a, b); // default impl. delegates to StrictMath + throw new UnsupportedOperationException(); } /** @@ -647,11 +581,9 @@ * @see java.lang.Integer#MAX_VALUE * @see java.lang.Integer#MIN_VALUE */ + @JavaScriptBody(args="a", body="return Math.round(a);") public static int round(float a) { - if (a != 0x1.fffffep-2f) // greatest float value less than 0.5 - return (int)floor(a + 0.5f); - else - return 0; + throw new UnsupportedOperationException(); } /** @@ -674,11 +606,9 @@ * @see java.lang.Long#MAX_VALUE * @see java.lang.Long#MIN_VALUE */ + @JavaScriptBody(args="a", body="return Math.round(a);") public static long round(double a) { - if (a != 0x1.fffffffffffffp-2) // greatest double value less than 0.5 - return (long)floor(a + 0.5d); - else - return 0; + throw new UnsupportedOperationException(); } // private static Random randomNumberGenerator; @@ -1024,207 +954,6 @@ // } /** - * Returns the hyperbolic sine of a {@code double} value. - * The hyperbolic sine of x is defined to be - * (ex - e-x)/2 - * where e is {@linkplain Math#E Euler's number}. - * - *

Special cases: - *

- * - *

The computed result must be within 2.5 ulps of the exact result. - * - * @param x The number whose hyperbolic sine is to be returned. - * @return The hyperbolic sine of {@code x}. - * @since 1.5 - */ - public static double sinh(double x) { - return StrictMath.sinh(x); - } - - /** - * Returns the hyperbolic cosine of a {@code double} value. - * The hyperbolic cosine of x is defined to be - * (ex + e-x)/2 - * where e is {@linkplain Math#E Euler's number}. - * - *

Special cases: - *

- * - *

The computed result must be within 2.5 ulps of the exact result. - * - * @param x The number whose hyperbolic cosine is to be returned. - * @return The hyperbolic cosine of {@code x}. - * @since 1.5 - */ - public static double cosh(double x) { - return StrictMath.cosh(x); - } - - /** - * Returns the hyperbolic tangent of a {@code double} value. - * The hyperbolic tangent of x is defined to be - * (ex - e-x)/(ex + e-x), - * in other words, {@linkplain Math#sinh - * sinh(x)}/{@linkplain Math#cosh cosh(x)}. Note - * that the absolute value of the exact tanh is always less than - * 1. - * - *

Special cases: - *

- * - *

The computed result must be within 2.5 ulps of the exact result. - * The result of {@code tanh} for any finite input must have - * an absolute value less than or equal to 1. Note that once the - * exact result of tanh is within 1/2 of an ulp of the limit value - * of ±1, correctly signed ±{@code 1.0} should - * be returned. - * - * @param x The number whose hyperbolic tangent is to be returned. - * @return The hyperbolic tangent of {@code x}. - * @since 1.5 - */ - public static double tanh(double x) { - return StrictMath.tanh(x); - } - - /** - * Returns sqrt(x2 +y2) - * without intermediate overflow or underflow. - * - *

Special cases: - *

- * - *

The computed result must be within 1 ulp of the exact - * result. If one parameter is held constant, the results must be - * semi-monotonic in the other parameter. - * - * @param x a value - * @param y a value - * @return sqrt(x2 +y2) - * without intermediate overflow or underflow - * @since 1.5 - */ - public static double hypot(double x, double y) { - return StrictMath.hypot(x, y); - } - - /** - * Returns ex -1. Note that for values of - * x near 0, the exact sum of - * {@code expm1(x)} + 1 is much closer to the true - * result of ex than {@code exp(x)}. - * - *

Special cases: - *

- * - *

The computed result must be within 1 ulp of the exact result. - * Results must be semi-monotonic. The result of - * {@code expm1} for any finite input must be greater than or - * equal to {@code -1.0}. Note that once the exact result of - * e{@code x} - 1 is within 1/2 - * ulp of the limit value -1, {@code -1.0} should be - * returned. - * - * @param x the exponent to raise e to in the computation of - * e{@code x} -1. - * @return the value e{@code x} - 1. - * @since 1.5 - */ - public static double expm1(double x) { - return StrictMath.expm1(x); - } - - /** - * Returns the natural logarithm of the sum of the argument and 1. - * Note that for small values {@code x}, the result of - * {@code log1p(x)} is much closer to the true result of ln(1 - * + {@code x}) than the floating-point evaluation of - * {@code log(1.0+x)}. - * - *

Special cases: - * - *

- * - *

The computed result must be within 1 ulp of the exact result. - * Results must be semi-monotonic. - * - * @param x a value - * @return the value ln({@code x} + 1), the natural - * log of {@code x} + 1 - * @since 1.5 - */ - public static double log1p(double x) { - return StrictMath.log1p(x); - } - - /** * Returns the first floating-point argument with the sign of the * second floating-point argument. Note that unlike the {@link * StrictMath#copySign(double, double) StrictMath.copySign}