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

Unified Diff: src/runtime.js

Issue 1092353002: [strong] Disallow implicit conversions for binary arithmetic operations (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: cl feedback 5 Created 5 years, 8 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: src/runtime.js
diff --git a/src/runtime.js b/src/runtime.js
index aaaa4fecba110c4e5e3edc0a88ea9f6a3e946e89..a4677da316d1cb28a3c96ce730e0fb1cc5926573 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -199,6 +199,15 @@ function SUB(y) {
}
+// ECMA-262, section 11.6.2, page 50.
+function SUB_STRONG(y) {
+ if (IS_NUMBER(this) && IS_NUMBER(y)) {
+ return %NumberSub(this, y);
+ }
+ throw %MakeTypeError('strong_implicit_cast');
+}
+
+
// ECMA-262, section 11.5.1, page 48.
function MUL(y) {
var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this);
@@ -207,6 +216,15 @@ function MUL(y) {
}
+// ECMA-262, section 11.5.1, page 48.
+function MUL_STRONG(y) {
+ if (IS_NUMBER(this) && IS_NUMBER(y)) {
+ return %NumberMul(this, y);
+ }
+ throw %MakeTypeError('strong_implicit_cast');
+}
+
+
// ECMA-262, section 11.5.2, page 49.
function DIV(y) {
var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this);
@@ -215,6 +233,15 @@ function DIV(y) {
}
+// ECMA-262, section 11.5.2, page 49.
+function DIV_STRONG(y) {
+ if (IS_NUMBER(this) && IS_NUMBER(y)) {
+ return %NumberDiv(this, y);
+ }
+ throw %MakeTypeError('strong_implicit_cast');
+}
+
+
// ECMA-262, section 11.5.3, page 49.
function MOD(y) {
var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this);
@@ -223,6 +250,14 @@ function MOD(y) {
}
+// ECMA-262, section 11.5.3, page 49.
+function MOD_STRONG(y) {
+ if (IS_NUMBER(this) && IS_NUMBER(y)) {
+ return %NumberMod(this, y);
+ }
+ throw %MakeTypeError('strong_implicit_cast');
+}
+
/* -------------------------------------------
- - - B i t o p e r a t i o n s - - -

Powered by Google App Engine
This is Rietveld 408576698