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

Unified Diff: src/js/regexp.js

Issue 1846303002: Further ES2015 RegExp spec compliance fixes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix cctest Created 4 years, 9 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 | « no previous file | test/cctest/test-regexp.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/regexp.js
diff --git a/src/js/regexp.js b/src/js/regexp.js
index fc5e0f54b8180945ef79dbb5be755f6387246878..d39771e9e329981871be76e825e2327059e6d145 100644
--- a/src/js/regexp.js
+++ b/src/js/regexp.js
@@ -194,8 +194,8 @@ function RegExpSubclassExecJS(string) {
// algorithm, step 4) even if the value is discarded for non-global RegExps.
var i = TO_LENGTH(lastIndex);
- var global = TO_BOOLEAN(this.global);
- var sticky = TO_BOOLEAN(this.sticky);
+ var global = TO_BOOLEAN(REGEXP_GLOBAL(this));
+ var sticky = TO_BOOLEAN(REGEXP_STICKY(this));
var updateLastIndex = global || sticky;
if (updateLastIndex) {
if (i > string.length) {
@@ -370,27 +370,14 @@ function TrimRegExp(regexp) {
function RegExpToString() {
- if (!IS_REGEXP(this)) {
- // RegExp.prototype.toString() returns '/(?:)/' as a compatibility fix;
- // a UseCounter is incremented to track it.
- // TODO(littledan): Remove this workaround or standardize it
- if (this === GlobalRegExpPrototype) {
- %IncrementUseCounter(kRegExpPrototypeToString);
- return '/(?:)/';
- }
- if (!IS_RECEIVER(this)) {
- throw MakeTypeError(
- kIncompatibleMethodReceiver, 'RegExp.prototype.toString', this);
- }
- return '/' + TO_STRING(this.source) + '/' + TO_STRING(this.flags);
+ if (!IS_RECEIVER(this)) {
+ throw MakeTypeError(
+ kIncompatibleMethodReceiver, 'RegExp.prototype.toString', this);
}
- var result = '/' + REGEXP_SOURCE(this) + '/';
- if (REGEXP_GLOBAL(this)) result += 'g';
- if (REGEXP_IGNORE_CASE(this)) result += 'i';
- if (REGEXP_MULTILINE(this)) result += 'm';
- if (REGEXP_UNICODE(this)) result += 'u';
- if (REGEXP_STICKY(this)) result += 'y';
- return result;
+ if (this === GlobalRegExpPrototype) {
+ %IncrementUseCounter(kRegExpPrototypeToString);
+ }
+ return '/' + TO_STRING(this.source) + '/' + TO_STRING(this.flags);
}
@@ -1126,7 +1113,7 @@ function RegExpGetSource() {
// TODO(littledan): Remove this RegExp compat workaround
if (this === GlobalRegExpPrototype) {
%IncrementUseCounter(kRegExpPrototypeSourceGetter);
- return UNDEFINED;
+ return "(?:)";
}
throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.source");
}
« no previous file with comments | « no previous file | test/cctest/test-regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698