Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Unified Diff: compiler/lib/implementation/number.js

Issue 9192007: Simplify equality checks and get rid of unreachable code in number and bool. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: compiler/lib/implementation/number.js
diff --git a/compiler/lib/implementation/number.js b/compiler/lib/implementation/number.js
index aa2767af0d675b9288f1edb49cc1c7afc3bc3b7c..b9604a7968c3dd1539661770449e7bff9ebd6fad 100644
--- a/compiler/lib/implementation/number.js
+++ b/compiler/lib/implementation/number.js
@@ -3,159 +3,91 @@
// BSD-style license that can be found in the LICENSE file.
-
function native_NumberImplementation_BIT_OR(other) {
ahe 2012/01/19 13:27:16 Any method that starts with native_ and immediatel
kasperl 2012/01/19 13:33:10 Yes -- strongly agreed. That is certainly the plan
- "use strict";
- if (typeof other != 'number') {
- native__NumberJsUtil__throwIllegalArgumentException(other);
- }
- return this | other;
+ native__NumberJsUtil__throwIllegalArgumentException(other);
}
function native_NumberImplementation_BIT_XOR(other) {
- "use strict";
- if (typeof other != 'number') {
- native__NumberJsUtil__throwIllegalArgumentException(other);
- }
- return this ^ other;
+ native__NumberJsUtil__throwIllegalArgumentException(other);
}
function native_NumberImplementation_BIT_AND(other) {
- "use strict";
- if (typeof other != 'number') {
- native__NumberJsUtil__throwIllegalArgumentException(other);
- }
- return this & other;
+ native__NumberJsUtil__throwIllegalArgumentException(other);
}
function native_NumberImplementation_SHL(other) {
- "use strict";
- if (typeof other != 'number') {
- native__NumberJsUtil__throwIllegalArgumentException(other);
- }
- return this << other;
+ native__NumberJsUtil__throwIllegalArgumentException(other);
}
function native_NumberImplementation_SAR(other) {
- "use strict";
- if (typeof other != 'number') {
- native__NumberJsUtil__throwIllegalArgumentException(other);
- }
- return this >> other;
+ native__NumberJsUtil__throwIllegalArgumentException(other);
+}
+
+function native_NumberImplementation_BIT_NOT() {
+ throw Error('UNREACHABLE');
}
function native_NumberImplementation_ADD(other) {
- "use strict";
- if (typeof other != 'number') {
- native__NumberJsUtil__throwIllegalArgumentException(other);
- }
- return this + other;
+ native__NumberJsUtil__throwIllegalArgumentException(other);
}
function native_NumberImplementation_SUB(other) {
- "use strict";
- if (typeof other != 'number') {
- native__NumberJsUtil__throwIllegalArgumentException(other);
- }
- return this - other;
+ native__NumberJsUtil__throwIllegalArgumentException(other);
}
function native_NumberImplementation_MUL(other) {
- "use strict";
- if (typeof other != 'number') {
- native__NumberJsUtil__throwIllegalArgumentException(other);
- }
- return this * other;
+ native__NumberJsUtil__throwIllegalArgumentException(other);
}
function native_NumberImplementation_DIV(other) {
- "use strict";
- if (typeof other != 'number') {
- native__NumberJsUtil__throwIllegalArgumentException(other);
- }
- return this / other;
+ native__NumberJsUtil__throwIllegalArgumentException(other);
}
function native_NumberImplementation_TRUNC(other) {
- "use strict";
- if (typeof other != 'number') {
- native__NumberJsUtil__throwIllegalArgumentException(other);
- }
- var tmp = this / other;
- if (tmp < 0) {
- return Math.ceil(tmp);
- } else {
- return Math.floor(tmp);
- }
+ native__NumberJsUtil__throwIllegalArgumentException(other);
}
-function number$euclideanModulo(a, b) {
- var result = a % b;
- if (result == 0) {
- return 0; // Make sure we don't return -0.0.
- } else if (result < 0) {
- if (b < 0) {
- return result - b;
- } else {
- return result + b;
- }
- }
- return result;
+function native_NumberImplementation_MOD(other) {
+ native__NumberJsUtil__throwIllegalArgumentException(other);
}
-function native_NumberImplementation_MOD(other) {
- "use strict";
- if (typeof other != 'number') {
- native__NumberJsUtil__throwIllegalArgumentException(other);
- }
- return number$euclideanModulo(this, other);
+function native_NumberImplementation_negate() {
+ throw Error('UNREACHABLE');
+}
+
+function native_NumberImplementation_EQ(other) {
+ throw Error('UNREACHABLE');
}
function native_NumberImplementation_LT(other) {
- "use strict";
- if (typeof other != 'number') {
- native__NumberJsUtil__throwIllegalArgumentException(other);
- }
- return this < other;
+ native__NumberJsUtil__throwIllegalArgumentException(other);
}
function native_NumberImplementation_GT(other) {
- "use strict";
- if (typeof other != 'number') {
- native__NumberJsUtil__throwIllegalArgumentException(other);
- }
- return this > other;
+ native__NumberJsUtil__throwIllegalArgumentException(other);
}
function native_NumberImplementation_LTE(other) {
- "use strict";
- if (typeof other != 'number') {
- native__NumberJsUtil__throwIllegalArgumentException(other);
- }
- return this <= other;
+ native__NumberJsUtil__throwIllegalArgumentException(other);
}
function native_NumberImplementation_GTE(other) {
- "use strict";
- if (typeof other != 'number') {
- native__NumberJsUtil__throwIllegalArgumentException(other);
- }
- return this >= other;
-}
-
-function native_NumberImplementation_EQ(other) {
- "use strict";
- return typeof other == 'number' && this == other;
+ native__NumberJsUtil__throwIllegalArgumentException(other);
}
-function native_NumberImplementation_BIT_NOT() {
- "use strict";
- return ~this;
-}
-function native_NumberImplementation_negate() {
- "use strict";
- return -this;
+function number$euclideanModulo(a, b) {
+ var result = a % b;
+ if (result == 0) {
+ return 0; // Make sure we don't return -0.0.
+ } else if (result < 0) {
+ if (b < 0) {
+ return result - b;
+ } else {
+ return result + b;
+ }
+ }
+ return result;
}
function native_NumberImplementation_remainder(other) {
@@ -175,36 +107,44 @@ function native_NumberImplementation_round() {
"use strict";
return Math.round(this);
}
+
function native_NumberImplementation_floor() {
"use strict";
return Math.floor(this);
}
+
function native_NumberImplementation_ceil() {
"use strict";
return Math.ceil(this);
}
+
function native_NumberImplementation_truncate() {
"use strict";
return (this < 0) ? Math.ceil(this) : Math.floor(this);
}
+
function native_NumberImplementation_isNegative() {
"use strict";
// TODO(floitsch): is there a faster way to detect -0?
if (this == 0) return (1 / this) < 0;
return this < 0;
}
+
function native_NumberImplementation_isEven() {
"use strict";
return ((this & 1) == 0);
}
+
function native_NumberImplementation_isOdd() {
"use strict";
return ((this & 1) == 1);
}
+
function native_NumberImplementation_isNaN() {
"use strict";
return isNaN(this);
}
+
function native_NumberImplementation_isInfinite() {
"use strict";
return (this == Infinity) || (this == -Infinity);
@@ -218,15 +158,19 @@ function native_NumberImplementation_toDouble() {
function native_NumberImplementation_toString() {
return this.toString();
}
+
function native_NumberImplementation_toStringAsFixed(fractionDigits) {
return this.toFixed(fractionDigits);
}
+
function native_NumberImplementation_toStringAsPrecision(precision) {
return this.toPrecision(precision);
}
+
function native_NumberImplementation_toStringAsExponential(fractionDigits) {
return this.toExponential(fractionDigits);
}
+
function native_NumberImplementation_toRadixString(radix) {
return this.toString(radix);
}

Powered by Google App Engine
This is Rietveld 408576698