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

Unified Diff: src/string.js

Issue 1378533002: [es6] Introduce %ToInteger and %ToLength. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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 | « src/runtime/runtime-object.cc ('k') | src/typedarray.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/string.js
diff --git a/src/string.js b/src/string.js
index 2ee8a221df4e5818e6da616e1b39084dc37d8c3d..bd20226757d879347c80ecdce3a3dc50868bc183 100644
--- a/src/string.js
+++ b/src/string.js
@@ -155,8 +155,7 @@ function StringMatchJS(regexp) {
if (IS_REGEXP(regexp)) {
// Emulate RegExp.prototype.exec's side effect in step 5, even though
// value is discarded.
- var lastIndex = regexp.lastIndex;
- TO_INTEGER_FOR_SIDE_EFFECT(lastIndex);
+ var lastIndex = TO_INTEGER(regexp.lastIndex);
if (!regexp.global) return RegExpExecNoTests(regexp, subject, 0);
var result = %StringMatch(subject, regexp, RegExpLastMatchInfo);
if (result !== null) $regexpLastMatchInfoOverride = null;
@@ -227,8 +226,7 @@ function StringReplace(search, replace) {
if (IS_REGEXP(search)) {
// Emulate RegExp.prototype.exec's side effect in step 5, even if
// value is discarded.
- var lastIndex = search.lastIndex;
- TO_INTEGER_FOR_SIDE_EFFECT(lastIndex);
+ var lastIndex = TO_INTEGER(search.lastIndex);
if (!IS_CALLABLE(replace)) {
replace = TO_STRING(replace);
@@ -936,7 +934,7 @@ function StringRepeat(count) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.repeat");
var s = TO_STRING(this);
- var n = $toInteger(count);
+ var n = TO_INTEGER(count);
// The maximum string length is stored in a smi, so a longer repeat
// must result in a range error.
if (n < 0 || n > %_MaxSmi()) throw MakeRangeError(kInvalidCountValue);
@@ -966,7 +964,7 @@ function StringStartsWith(searchString /* position */) { // length == 1
if (%_ArgumentsLength() > 1) {
var arg = %_Arguments(1); // position
if (!IS_UNDEFINED(arg)) {
- pos = $toInteger(arg);
+ pos = TO_INTEGER(arg);
}
}
@@ -1005,7 +1003,7 @@ function StringEndsWith(searchString /* position */) { // length == 1
if (%_ArgumentsLength() > 1) {
var arg = %_Arguments(1); // position
if (!IS_UNDEFINED(arg)) {
- pos = $toInteger(arg);
+ pos = TO_INTEGER(arg);
}
}
@@ -1115,7 +1113,7 @@ function StringRaw(callSite) {
var numberOfSubstitutions = %_ArgumentsLength();
var cooked = TO_OBJECT(callSite);
var raw = TO_OBJECT(cooked.raw);
- var literalSegments = $toLength(raw.length);
+ var literalSegments = TO_LENGTH(raw.length);
if (literalSegments <= 0) return "";
var result = TO_STRING(raw[0]);
« no previous file with comments | « src/runtime/runtime-object.cc ('k') | src/typedarray.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698