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

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

Issue 9240005: Add number checks to the numeric operations in dartc. (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
« no previous file with comments | « compiler/lib/implementation/number.dart ('k') | tests/co19/co19-compiler.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/lib/implementation/number.js
diff --git a/compiler/lib/implementation/number.js b/compiler/lib/implementation/number.js
index d7ecd4ca0cbdfe2344e4484e0ee6e215b7509ef7..aa2767af0d675b9288f1edb49cc1c7afc3bc3b7c 100644
--- a/compiler/lib/implementation/number.js
+++ b/compiler/lib/implementation/number.js
@@ -6,51 +6,81 @@
function native_NumberImplementation_BIT_OR(other) {
"use strict";
+ if (typeof other != 'number') {
+ native__NumberJsUtil__throwIllegalArgumentException(other);
+ }
return this | other;
}
function native_NumberImplementation_BIT_XOR(other) {
"use strict";
+ if (typeof other != 'number') {
+ native__NumberJsUtil__throwIllegalArgumentException(other);
+ }
return this ^ other;
}
function native_NumberImplementation_BIT_AND(other) {
"use strict";
+ if (typeof other != 'number') {
+ native__NumberJsUtil__throwIllegalArgumentException(other);
+ }
return this & other;
}
function native_NumberImplementation_SHL(other) {
"use strict";
+ if (typeof other != 'number') {
+ native__NumberJsUtil__throwIllegalArgumentException(other);
+ }
return this << other;
}
function native_NumberImplementation_SAR(other) {
"use strict";
+ if (typeof other != 'number') {
+ native__NumberJsUtil__throwIllegalArgumentException(other);
+ }
return this >> other;
}
function native_NumberImplementation_ADD(other) {
"use strict";
+ if (typeof other != 'number') {
+ native__NumberJsUtil__throwIllegalArgumentException(other);
+ }
return this + other;
}
function native_NumberImplementation_SUB(other) {
"use strict";
- return this - other;
+ if (typeof other != 'number') {
+ native__NumberJsUtil__throwIllegalArgumentException(other);
+ }
+ return this - other;
}
function native_NumberImplementation_MUL(other) {
"use strict";
+ if (typeof other != 'number') {
+ native__NumberJsUtil__throwIllegalArgumentException(other);
+ }
return this * other;
}
function native_NumberImplementation_DIV(other) {
"use strict";
+ if (typeof other != 'number') {
+ native__NumberJsUtil__throwIllegalArgumentException(other);
+ }
return this / 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);
@@ -75,26 +105,41 @@ function number$euclideanModulo(a, b) {
function native_NumberImplementation_MOD(other) {
"use strict";
+ if (typeof other != 'number') {
+ native__NumberJsUtil__throwIllegalArgumentException(other);
+ }
return number$euclideanModulo(this, other);
}
function native_NumberImplementation_LT(other) {
"use strict";
+ if (typeof other != 'number') {
+ native__NumberJsUtil__throwIllegalArgumentException(other);
+ }
return this < other;
}
function native_NumberImplementation_GT(other) {
"use strict";
+ if (typeof other != 'number') {
+ native__NumberJsUtil__throwIllegalArgumentException(other);
+ }
return this > other;
}
function native_NumberImplementation_LTE(other) {
"use strict";
+ if (typeof other != 'number') {
+ native__NumberJsUtil__throwIllegalArgumentException(other);
+ }
return this <= other;
}
function native_NumberImplementation_GTE(other) {
"use strict";
+ if (typeof other != 'number') {
+ native__NumberJsUtil__throwIllegalArgumentException(other);
+ }
return this >= other;
}
@@ -115,6 +160,9 @@ function native_NumberImplementation_negate() {
function native_NumberImplementation_remainder(other) {
"use strict";
+ if (typeof other != 'number') {
+ native__NumberJsUtil__throwIllegalArgumentException(other);
+ }
return this % other;
}
« no previous file with comments | « compiler/lib/implementation/number.dart ('k') | tests/co19/co19-compiler.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698