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) { ...@@ -904,17 +904,16 @@ void Scanner::SeekForward(int pos) {
Scan(); Scan();
} }
template <bool capture_raw>
template <bool capture_raw, bool in_template_literal>
bool Scanner::ScanEscape() { bool Scanner::ScanEscape() {
uc32 c = c0_; uc32 c = c0_;
Advance<capture_raw>(); Advance<capture_raw>();
// Skip escaped newlines. // Skip escaped newlines.
DCHECK(!unibrow::IsLineTerminator(kEndOfInput)); 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. // 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; return true;
} }
...@@ -948,7 +947,7 @@ bool Scanner::ScanEscape() { ...@@ -948,7 +947,7 @@ bool Scanner::ScanEscape() {
case '5': // fall through case '5': // fall through
case '6': // fall through case '6': // fall through
case '7': case '7':
c = ScanOctalEscape<capture_raw>(c, 2, in_template_literal); c = ScanOctalEscape<capture_raw>(c, 2);
break; break;
} }
...@@ -958,7 +957,7 @@ bool Scanner::ScanEscape() { ...@@ -958,7 +957,7 @@ bool Scanner::ScanEscape() {
} }
template <bool capture_raw> 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'; uc32 x = c - '0';
int i = 0; int i = 0;
for (; i < length; i++) { for (; i < length; i++) {
...@@ -976,8 +975,7 @@ uc32 Scanner::ScanOctalEscape(uc32 c, int length, bool in_template_literal) { ...@@ -976,8 +975,7 @@ uc32 Scanner::ScanOctalEscape(uc32 c, int length, bool in_template_literal) {
// occur before the "use strict" directive. // occur before the "use strict" directive.
if (c != '0' || i > 0 || c0_ == '8' || c0_ == '9') { if (c != '0' || i > 0 || c0_ == '8' || c0_ == '9') {
octal_pos_ = Location(source_pos() - i - 1, source_pos() - 1); octal_pos_ = Location(source_pos() - i - 1, source_pos() - 1);
octal_message_ = in_template_literal octal_message_ = capture_raw ? MessageTemplate::kTemplateOctalLiteral
? MessageTemplate::kTemplateOctalLiteral
: MessageTemplate::kStrictOctalEscape; : MessageTemplate::kStrictOctalEscape;
} }
return x; return x;
...@@ -1001,7 +999,7 @@ Token::Value Scanner::ScanString() { ...@@ -1001,7 +999,7 @@ Token::Value Scanner::ScanString() {
if (c0_ == '\\') { if (c0_ == '\\') {
Advance(); Advance();
// TODO(verwaest): Check whether we can remove the additional check. // TODO(verwaest): Check whether we can remove the additional check.
if (c0_ == kEndOfInput || !ScanEscape<false, false>()) { if (c0_ == kEndOfInput || !ScanEscape<false>()) {
return Token::ILLEGAL; return Token::ILLEGAL;
} }
continue; continue;
...@@ -1056,7 +1054,6 @@ Token::Value Scanner::ScanTemplateSpan() { ...@@ -1056,7 +1054,6 @@ Token::Value Scanner::ScanTemplateSpan() {
LiteralScope literal(this); LiteralScope literal(this);
StartRawLiteral(); StartRawLiteral();
const bool capture_raw = true; const bool capture_raw = true;
const bool in_template_literal = true;
while (true) { while (true) {
uc32 c = c0_; uc32 c = c0_;
Advance(); Advance();
...@@ -1081,7 +1078,7 @@ Token::Value Scanner::ScanTemplateSpan() { ...@@ -1081,7 +1078,7 @@ Token::Value Scanner::ScanTemplateSpan() {
} }
if (capture_raw) AddRawLiteralChar(lastChar); if (capture_raw) AddRawLiteralChar(lastChar);
} else { } else {
bool success = ScanEscape<capture_raw, in_template_literal>(); bool success = ScanEscape<capture_raw>();
USE(success); USE(success);
DCHECK_EQ(!success, has_error()); DCHECK_EQ(!success, has_error());
// For templates, invalid escape sequence checking is handled in the // For templates, invalid escape sequence checking is handled in the
......
...@@ -377,7 +377,7 @@ class Scanner { ...@@ -377,7 +377,7 @@ class Scanner {
// Scans octal escape sequence. Also accepts "\0" decimal escape sequence. // Scans octal escape sequence. Also accepts "\0" decimal escape sequence.
template <bool capture_raw> 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. // Call this after setting source_ to the input.
void Init() { void Init() {
...@@ -628,7 +628,7 @@ class Scanner { ...@@ -628,7 +628,7 @@ class Scanner {
// Scans an escape-sequence which is part of a string and adds the // Scans an escape-sequence which is part of a string and adds the
// decoded character to the current literal. Returns true if a pattern // decoded character to the current literal. Returns true if a pattern
// is scanned. // is scanned.
template <bool capture_raw, bool in_template_literal> template <bool capture_raw>
bool ScanEscape(); bool ScanEscape();
// Decodes a Unicode escape-sequence which is part of an identifier. // 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