Chromium Code Reviews| Index: src/runtime.js |
| diff --git a/src/runtime.js b/src/runtime.js |
| index 9bb02aecb711ab6fbb932075a187905f9b72731f..7b291000e0e42badb2b3913a0465059db82ab463 100644 |
| --- a/src/runtime.js |
| +++ b/src/runtime.js |
| @@ -160,6 +160,15 @@ function ADD(x) { |
| } |
| +//ECMA-262, section 11.6.1, page 50. |
|
Dmitry Lomov (no reviews)
2015/04/30 08:43:59
This comment does not apply anymore I guess.
conradw
2015/04/30 09:19:33
Changed this and similar examples in other places.
|
| +function ADD_STRONG(x) { |
| + if (IS_NUMBER(this) && IS_NUMBER(x)) return %NumberAdd(this, x); |
| + if (IS_STRING(this) && IS_STRING(x)) return %_StringAdd(this, x); |
| + |
| + throw %MakeTypeError('strong_implicit_cast'); |
| +} |
| + |
| + |
| // Left operand (this) is already a string. |
| function STRING_ADD_LEFT(y) { |
| if (!IS_STRING(y)) { |
| @@ -175,6 +184,15 @@ function STRING_ADD_LEFT(y) { |
| } |
| +//Left operand (this) is already a string. |
| +function STRING_ADD_LEFT_STRONG(y) { |
| + if (IS_STRING(y)) { |
| + return %_StringAdd(this, y); |
| + } |
| + throw %MakeTypeError('strong_implicit_cast'); |
| +} |
| + |
| + |
| // Right operand (y) is already a string. |
| function STRING_ADD_RIGHT(y) { |
| var x = this; |
| @@ -191,6 +209,15 @@ function STRING_ADD_RIGHT(y) { |
| } |
| +//Right operand (y) is already a string. |
| +function STRING_ADD_RIGHT_STRONG(y) { |
| + if (IS_STRING(this)) { |
| + return %_StringAdd(this, y); |
| + } |
| + throw %MakeTypeError('strong_implicit_cast'); |
| +} |
| + |
| + |
| // ECMA-262, section 11.6.2, page 50. |
| function SUB(y) { |
| var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this); |