| Index: runtime/lib/math_patch.dart
|
| diff --git a/runtime/lib/math_patch.dart b/runtime/lib/math_patch.dart
|
| index b07a6bd9bf1c5f47b546e219c88bf8239ead4245..a09ad93b62a3f85891cbae5ee7d353b7f4f4e1d8 100644
|
| --- a/runtime/lib/math_patch.dart
|
| +++ b/runtime/lib/math_patch.dart
|
| @@ -8,7 +8,8 @@ import "dart:typed_data";
|
|
|
| // If [x] is an [int] and [exponent] is a non-negative [int], the result is
|
| // an [int], otherwise the result is a [double].
|
| -@patch num pow(num x, num exponent) {
|
| +@patch
|
| +num pow(num x, num exponent) {
|
| if ((x is int) && (exponent is int) && (exponent >= 0)) {
|
| return _intPow(x, exponent);
|
| }
|
| @@ -17,7 +18,7 @@ import "dart:typed_data";
|
|
|
| double _doublePow(double base, double exponent) {
|
| if (exponent == 0.0) {
|
| - return 1.0; // ECMA-262 15.8.2.13
|
| + return 1.0; // ECMA-262 15.8.2.13
|
| }
|
| // Speed up simple cases.
|
| if (exponent == 1.0) return base;
|
| @@ -56,16 +57,26 @@ int _intPow(int base, int exponent) {
|
| return result;
|
| }
|
|
|
| -@patch double atan2(num a, num b) => _atan2(a.toDouble(), b.toDouble());
|
| -@patch double sin(num x) => _sin(x.toDouble());
|
| -@patch double cos(num x) => _cos(x.toDouble());
|
| -@patch double tan(num x) => _tan(x.toDouble());
|
| -@patch double acos(num x) => _acos(x.toDouble());
|
| -@patch double asin(num x) => _asin(x.toDouble());
|
| -@patch double atan(num x) => _atan(x.toDouble());
|
| -@patch double sqrt(num x) => _sqrt(x.toDouble());
|
| -@patch double exp(num x) => _exp(x.toDouble());
|
| -@patch double log(num x) => _log(x.toDouble());
|
| +@patch
|
| +double atan2(num a, num b) => _atan2(a.toDouble(), b.toDouble());
|
| +@patch
|
| +double sin(num x) => _sin(x.toDouble());
|
| +@patch
|
| +double cos(num x) => _cos(x.toDouble());
|
| +@patch
|
| +double tan(num x) => _tan(x.toDouble());
|
| +@patch
|
| +double acos(num x) => _acos(x.toDouble());
|
| +@patch
|
| +double asin(num x) => _asin(x.toDouble());
|
| +@patch
|
| +double atan(num x) => _atan(x.toDouble());
|
| +@patch
|
| +double sqrt(num x) => _sqrt(x.toDouble());
|
| +@patch
|
| +double exp(num x) => _exp(x.toDouble());
|
| +@patch
|
| +double log(num x) => _log(x.toDouble());
|
|
|
| double _atan2(double a, double b) native "Math_atan2";
|
| double _sin(double x) native "Math_sin";
|
| @@ -78,30 +89,31 @@ double _sqrt(double x) native "Math_sqrt";
|
| double _exp(double x) native "Math_exp";
|
| double _log(double x) native "Math_log";
|
|
|
| -
|
| // TODO(iposva): Handle patch methods within a patch class correctly.
|
| -@patch class Random {
|
| -
|
| - @patch factory Random([int seed]) {
|
| +@patch
|
| +class Random {
|
| + @patch
|
| + factory Random([int seed]) {
|
| var state = _Random._setupSeed((seed == null) ? _Random._nextSeed() : seed);
|
| // Crank a couple of times to distribute the seed bits a bit further.
|
| - return new _Random._withState(state).._nextState()
|
| - .._nextState()
|
| - .._nextState()
|
| - .._nextState();
|
| + return new _Random._withState(state)
|
| + .._nextState()
|
| + .._nextState()
|
| + .._nextState()
|
| + .._nextState();
|
| }
|
|
|
| - @patch factory Random.secure() {
|
| + @patch
|
| + factory Random.secure() {
|
| return new _SecureRandom();
|
| }
|
| }
|
|
|
| -
|
| class _Random implements Random {
|
| // Internal state of the random number generator.
|
| final Uint32List _state;
|
| static const _kSTATE_LO = 0;
|
| - static const _kSTATE_HI = 1; // Unused in Dart code.
|
| + static const _kSTATE_HI = 1; // Unused in Dart code.
|
|
|
| _Random._withState(this._state);
|
|
|
| @@ -122,8 +134,8 @@ class _Random implements Random {
|
| int nextInt(int max) {
|
| const limit = 0x3FFFFFFF;
|
| if ((max <= 0) || ((max > limit) && (max > _POW2_32))) {
|
| - throw new RangeError.range(max, 1, _POW2_32, "max",
|
| - "Must be positive and <= 2^32");
|
| + throw new RangeError.range(
|
| + max, 1, _POW2_32, "max", "Must be positive and <= 2^32");
|
| }
|
| if ((max & -max) == max) {
|
| // Fast case for powers of two.
|
| @@ -173,7 +185,6 @@ class _Random implements Random {
|
| }
|
| }
|
|
|
| -
|
| class _SecureRandom implements Random {
|
| _SecureRandom() {
|
| // Throw early in constructor if entropy source is not hooked up.
|
| @@ -188,7 +199,7 @@ class _SecureRandom implements Random {
|
| max, 1, _POW2_32, "max", "Must be positive and <= 2^32");
|
| final byteCount = ((max - 1).bitLength + 7) >> 3;
|
| if (byteCount == 0) {
|
| - return 0; // Not random if max == 1.
|
| + return 0; // Not random if max == 1.
|
| }
|
| var rnd;
|
| var result;
|
| @@ -211,4 +222,3 @@ class _SecureRandom implements Random {
|
| static const _POW2_32 = 1 << 32;
|
| static const _POW2_53_D = 1.0 * (1 << 53);
|
| }
|
| -
|
|
|