Commit ffc84ec3 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[scanner] capture_raw and in_template_literal mean the same, drop the second

Change-Id: If008d618d3cb27c38cf814b1858244578d0c4e84
Reviewed-on: https://chromium-review.googlesource.com/1169213Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55090}
parent 38e0fb84
......@@ -904,17 +904,16 @@ void Scanner::SeekForward(int pos) {
Scan();
}
template <bool capture_raw, bool in_template_literal>
template <bool capture_raw>
bool Scanner::ScanEscape() {
uc32 c = c0_;
Advance<capture_raw>();
// Skip escaped newlines.
DCHECK(!unibrow::IsLineTerminator(kEndOfInput));
if (!in_template_literal && unibrow::IsLineTerminator(c)) {
if (!capture_raw && unibrow::IsLineTerminator(c)) {
// Allow escaped CR+LF newlines in multiline string literals.
if (IsCarriageReturn(c) && IsLineFeed(c0_)) Advance<capture_raw>();
if (IsCarriageReturn(c) && IsLineFeed(c0_)) Advance();
return true;
}
......@@ -948,7 +947,7 @@ bool Scanner::ScanEscape() {
case '5': // fall through
case '6': // fall through
case '7':
c = ScanOctalEscape<capture_raw>(c, 2, in_template_literal);
c = ScanOctalEscape<capture_raw>(c, 2);
break;
}
......@@ -958,7 +957,7 @@ bool Scanner::ScanEscape() {
}
template <bool capture_raw>
uc32 Scanner::ScanOctalEscape(uc32 c, int length, bool in_template_literal) {
uc32 Scanner::ScanOctalEscape(uc32 c, int length) {
uc32 x = c - '0';
int i = 0;
for (; i < length; i++) {
......@@ -976,8 +975,7 @@ uc32 Scanner::ScanOctalEscape(uc32 c, int length, bool in_template_literal) {
// occur before the "use strict" directive.
if (c != '0' || i > 0 || c0_ == '8' || c0_ == '9') {
octal_pos_ = Location(source_pos() - i - 1, source_pos() - 1);
octal_message_ = in_template_literal
? MessageTemplate::kTemplateOctalLiteral
octal_message_ = capture_raw ? MessageTemplate::kTemplateOctalLiteral
: MessageTemplate::kStrictOctalEscape;
}
return x;
......@@ -1001,7 +999,7 @@ Token::Value Scanner::ScanString() {
if (c0_ == '\\') {
Advance();
// TODO(verwaest): Check whether we can remove the additional check.
if (c0_ == kEndOfInput || !ScanEscape<false, false>()) {
if (c0_ == kEndOfInput || !ScanEscape<false>()) {
return Token::ILLEGAL;
}
continue;
......@@ -1056,7 +1054,6 @@ Token::Value Scanner::ScanTemplateSpan() {
LiteralScope literal(this);
StartRawLiteral();
const bool capture_raw = true;
const bool in_template_literal = true;
while (true) {
uc32 c = c0_;
Advance();
......@@ -1081,7 +1078,7 @@ Token::Value Scanner::ScanTemplateSpan() {
}
if (capture_raw) AddRawLiteralChar(lastChar);
} else {
bool success = ScanEscape<capture_raw, in_template_literal>();
bool success = ScanEscape<capture_raw>();
USE(success);
DCHECK_EQ(!success, has_error());
// For templates, invalid escape sequence checking is handled in the
......
......@@ -377,7 +377,7 @@ class Scanner {
// Scans octal escape sequence. Also accepts "\0" decimal escape sequence.
template <bool capture_raw>
uc32 ScanOctalEscape(uc32 c, int length, bool in_template_literal);
uc32 ScanOctalEscape(uc32 c, int length);
// Call this after setting source_ to the input.
void Init() {
......@@ -628,7 +628,7 @@ class Scanner {
// Scans an escape-sequence which is part of a string and adds the
// decoded character to the current literal. Returns true if a pattern
// is scanned.
template <bool capture_raw, bool in_template_literal>
template <bool capture_raw>
bool ScanEscape();
// Decodes a Unicode escape-sequence which is part of an identifier.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment