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

Unified Diff: src/regexp/jsregexp.cc

Issue 1472323002: [es6] Correct parsing of regular expression literal flags. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix oversight in interpreter Created 5 years, 1 month 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/prettyprinter.cc ('k') | src/runtime/runtime-literals.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/regexp/jsregexp.cc
diff --git a/src/regexp/jsregexp.cc b/src/regexp/jsregexp.cc
index 224a27ddbbf7c8a374e9672f56188359bc9d0ca6..5988eccf36e9ce70fbe7aefa4995ccea276f256e 100644
--- a/src/regexp/jsregexp.cc
+++ b/src/regexp/jsregexp.cc
@@ -146,25 +146,21 @@ MaybeHandle<Object> RegExpImpl::Compile(Handle<JSRegExp> re,
RegExpCompileData parse_result;
FlatStringReader reader(isolate, pattern);
if (!RegExpParser::ParseRegExp(re->GetIsolate(), &zone, &reader,
- flags.is_multiline(), flags.is_unicode(),
- &parse_result)) {
+ flags & JSRegExp::kMultiline,
+ flags & JSRegExp::kUnicode, &parse_result)) {
// Throw an exception if we fail to parse the pattern.
return ThrowRegExpException(re, pattern, parse_result.error);
}
bool has_been_compiled = false;
- if (parse_result.simple &&
- !flags.is_ignore_case() &&
- !flags.is_sticky() &&
- !HasFewDifferentCharacters(pattern)) {
+ if (parse_result.simple && !(flags & JSRegExp::kIgnoreCase) &&
+ !(flags & JSRegExp::kSticky) && !HasFewDifferentCharacters(pattern)) {
// Parse-tree is a single atom that is equal to the pattern.
AtomCompile(re, pattern, flags, pattern);
has_been_compiled = true;
- } else if (parse_result.tree->IsAtom() &&
- !flags.is_ignore_case() &&
- !flags.is_sticky() &&
- parse_result.capture_count == 0) {
+ } else if (parse_result.tree->IsAtom() && !(flags & JSRegExp::kIgnoreCase) &&
+ !(flags & JSRegExp::kSticky) && parse_result.capture_count == 0) {
RegExpAtom* atom = parse_result.tree->AsAtom();
Vector<const uc16> atom_pattern = atom->data();
Handle<String> atom_string;
@@ -375,17 +371,18 @@ bool RegExpImpl::CompileIrregexp(Handle<JSRegExp> re,
pattern = String::Flatten(pattern);
RegExpCompileData compile_data;
FlatStringReader reader(isolate, pattern);
- if (!RegExpParser::ParseRegExp(isolate, &zone, &reader, flags.is_multiline(),
- flags.is_unicode(), &compile_data)) {
+ if (!RegExpParser::ParseRegExp(isolate, &zone, &reader,
+ flags & JSRegExp::kMultiline,
+ flags & JSRegExp::kUnicode, &compile_data)) {
// Throw an exception if we fail to parse the pattern.
// THIS SHOULD NOT HAPPEN. We already pre-parsed it successfully once.
USE(ThrowRegExpException(re, pattern, compile_data.error));
return false;
}
RegExpEngine::CompilationResult result = RegExpEngine::Compile(
- isolate, &zone, &compile_data, flags.is_ignore_case(), flags.is_global(),
- flags.is_multiline(), flags.is_sticky(), pattern, sample_subject,
- is_one_byte);
+ isolate, &zone, &compile_data, flags & JSRegExp::kIgnoreCase,
+ flags & JSRegExp::kGlobal, flags & JSRegExp::kMultiline,
+ flags & JSRegExp::kSticky, pattern, sample_subject, is_one_byte);
if (result.error_message != NULL) {
// Unable to compile regexp.
Handle<String> error_message = isolate->factory()->NewStringFromUtf8(
« no previous file with comments | « src/prettyprinter.cc ('k') | src/runtime/runtime-literals.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698