src/jdk/nashorn/internal/objects/NativeMath.java

Print this page
rev 745 : 8029332: Do not require nasgen-generated functions to return Object
Reviewed-by: lagergren, jlaskey, hannesw

*** 90,100 **** * @param x argument * * @return abs of value */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static Object abs(final Object self, final Object x) { return Math.abs(JSType.toNumber(x)); } /** * ECMA 15.8.2.1 abs(x) - specialization for int values --- 90,100 ---- * @param x argument * * @return abs of value */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static double abs(final Object self, final Object x) { return Math.abs(JSType.toNumber(x)); } /** * ECMA 15.8.2.1 abs(x) - specialization for int values
*** 142,152 **** * @param x argument * * @return acos of argument */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static Object acos(final Object self, final Object x) { return Math.acos(JSType.toNumber(x)); } /** * ECMA 15.8.2.2 acos(x) - specialization for double values --- 142,152 ---- * @param x argument * * @return acos of argument */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static double acos(final Object self, final Object x) { return Math.acos(JSType.toNumber(x)); } /** * ECMA 15.8.2.2 acos(x) - specialization for double values
*** 168,178 **** * @param x argument * * @return asin of argument */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static Object asin(final Object self, final Object x) { return Math.asin(JSType.toNumber(x)); } /** * ECMA 15.8.2.3 asin(x) - specialization for double values --- 168,178 ---- * @param x argument * * @return asin of argument */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static double asin(final Object self, final Object x) { return Math.asin(JSType.toNumber(x)); } /** * ECMA 15.8.2.3 asin(x) - specialization for double values
*** 194,204 **** * @param x argument * * @return atan of argument */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static Object atan(final Object self, final Object x) { return Math.atan(JSType.toNumber(x)); } /** * ECMA 15.8.2.4 atan(x) - specialization for double values --- 194,204 ---- * @param x argument * * @return atan of argument */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static double atan(final Object self, final Object x) { return Math.atan(JSType.toNumber(x)); } /** * ECMA 15.8.2.4 atan(x) - specialization for double values
*** 221,231 **** * @param y second argument * * @return atan2 of x and y */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static Object atan2(final Object self, final Object y, final Object x) { return Math.atan2(JSType.toNumber(y), JSType.toNumber(x)); } /** * ECMA 15.8.2.5 atan2(x,y) - specialization for double values --- 221,231 ---- * @param y second argument * * @return atan2 of x and y */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static double atan2(final Object self, final Object y, final Object x) { return Math.atan2(JSType.toNumber(y), JSType.toNumber(x)); } /** * ECMA 15.8.2.5 atan2(x,y) - specialization for double values
*** 248,258 **** * @param x argument * * @return ceil of argument */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static Object ceil(final Object self, final Object x) { return Math.ceil(JSType.toNumber(x)); } /** * ECMA 15.8.2.6 ceil(x) - specialized version for ints --- 248,258 ---- * @param x argument * * @return ceil of argument */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static double ceil(final Object self, final Object x) { return Math.ceil(JSType.toNumber(x)); } /** * ECMA 15.8.2.6 ceil(x) - specialized version for ints
*** 300,310 **** * @param x argument * * @return cos of argument */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static Object cos(final Object self, final Object x) { return Math.cos(JSType.toNumber(x)); } /** * ECMA 15.8.2.7 cos(x) - specialized version for doubles --- 300,310 ---- * @param x argument * * @return cos of argument */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static double cos(final Object self, final Object x) { return Math.cos(JSType.toNumber(x)); } /** * ECMA 15.8.2.7 cos(x) - specialized version for doubles
*** 326,336 **** * @param x argument * * @return exp of argument */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static Object exp(final Object self, final Object x) { return Math.exp(JSType.toNumber(x)); } /** * ECMA 15.8.2.9 floor(x) --- 326,336 ---- * @param x argument * * @return exp of argument */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static double exp(final Object self, final Object x) { return Math.exp(JSType.toNumber(x)); } /** * ECMA 15.8.2.9 floor(x)
*** 339,349 **** * @param x argument * * @return floor of argument */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static Object floor(final Object self, final Object x) { return Math.floor(JSType.toNumber(x)); } /** * ECMA 15.8.2.9 floor(x) - specialized version for ints --- 339,349 ---- * @param x argument * * @return floor of argument */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static double floor(final Object self, final Object x) { return Math.floor(JSType.toNumber(x)); } /** * ECMA 15.8.2.9 floor(x) - specialized version for ints
*** 391,401 **** * @param x argument * * @return log of argument */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static Object log(final Object self, final Object x) { return Math.log(JSType.toNumber(x)); } /** * ECMA 15.8.2.10 log(x) - specialized version for doubles --- 391,401 ---- * @param x argument * * @return log of argument */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static double log(final Object self, final Object x) { return Math.log(JSType.toNumber(x)); } /** * ECMA 15.8.2.10 log(x) - specialized version for doubles
*** 417,427 **** * @param args arguments * * @return the largest of the arguments, {@link Double#NEGATIVE_INFINITY} if no args given, or identity if one arg is given */ @Function(arity = 2, attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static Object max(final Object self, final Object... args) { switch (args.length) { case 0: return Double.NEGATIVE_INFINITY; case 1: return JSType.toNumber(args[0]); --- 417,427 ---- * @param args arguments * * @return the largest of the arguments, {@link Double#NEGATIVE_INFINITY} if no args given, or identity if one arg is given */ @Function(arity = 2, attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static double max(final Object self, final Object... args) { switch (args.length) { case 0: return Double.NEGATIVE_INFINITY; case 1: return JSType.toNumber(args[0]);
*** 495,505 **** * @param args arguments * * @return the smallest of the arguments, {@link Double#NEGATIVE_INFINITY} if no args given, or identity if one arg is given */ @Function(arity = 2, attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static Object min(final Object self, final Object... args) { switch (args.length) { case 0: return Double.POSITIVE_INFINITY; case 1: return JSType.toNumber(args[0]); --- 495,505 ---- * @param args arguments * * @return the smallest of the arguments, {@link Double#NEGATIVE_INFINITY} if no args given, or identity if one arg is given */ @Function(arity = 2, attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static double min(final Object self, final Object... args) { switch (args.length) { case 0: return Double.POSITIVE_INFINITY; case 1: return JSType.toNumber(args[0]);
*** 574,584 **** * @param y second argument * * @return x raised to the power of y */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static Object pow(final Object self, final Object x, final Object y) { return Math.pow(JSType.toNumber(x), JSType.toNumber(y)); } /** * ECMA 15.8.2.13 pow(x,y) - specialized version for doubles --- 574,584 ---- * @param y second argument * * @return x raised to the power of y */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static double pow(final Object self, final Object x, final Object y) { return Math.pow(JSType.toNumber(x), JSType.toNumber(y)); } /** * ECMA 15.8.2.13 pow(x,y) - specialized version for doubles
*** 600,610 **** * @param self self reference * * @return random number in the range [0..1) */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static Object random(final Object self) { return Math.random(); } /** * ECMA 15.8.2.15 round(x) --- 600,610 ---- * @param self self reference * * @return random number in the range [0..1) */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static double random(final Object self) { return Math.random(); } /** * ECMA 15.8.2.15 round(x)
*** 613,623 **** * @param x argument * * @return x rounded */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static Object round(final Object self, final Object x) { final double d = JSType.toNumber(x); if (Math.getExponent(d) >= 52) { return d; } return Math.copySign(Math.floor(d + 0.5), d); --- 613,623 ---- * @param x argument * * @return x rounded */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static double round(final Object self, final Object x) { final double d = JSType.toNumber(x); if (Math.getExponent(d) >= 52) { return d; } return Math.copySign(Math.floor(d + 0.5), d);
*** 630,640 **** * @param x argument * * @return sin of x */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static Object sin(final Object self, final Object x) { return Math.sin(JSType.toNumber(x)); } /** * ECMA 15.8.2.16 sin(x) - specialized version for doubles --- 630,640 ---- * @param x argument * * @return sin of x */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static double sin(final Object self, final Object x) { return Math.sin(JSType.toNumber(x)); } /** * ECMA 15.8.2.16 sin(x) - specialized version for doubles
*** 656,666 **** * @param x argument * * @return sqrt of x */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static Object sqrt(final Object self, final Object x) { return Math.sqrt(JSType.toNumber(x)); } /** * ECMA 15.8.2.17 sqrt(x) - specialized version for doubles --- 656,666 ---- * @param x argument * * @return sqrt of x */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) ! public static double sqrt(final Object self, final Object x) { return Math.sqrt(JSType.toNumber(x)); } /** * ECMA 15.8.2.17 sqrt(x) - specialized version for doubles
*** 682,692 **** * @param x argument * * @return tan of x */ @Function(attributes = Attribute.NOT_ENUMERABLE, where=Where.CONSTRUCTOR) ! public static Object tan(final Object self, final Object x) { return Math.tan(JSType.toNumber(x)); } /** * ECMA 15.8.2.18 tan(x) - specialized version for doubles --- 682,692 ---- * @param x argument * * @return tan of x */ @Function(attributes = Attribute.NOT_ENUMERABLE, where=Where.CONSTRUCTOR) ! public static double tan(final Object self, final Object x) { return Math.tan(JSType.toNumber(x)); } /** * ECMA 15.8.2.18 tan(x) - specialized version for doubles