Index: src/scanner.h |
diff --git a/src/scanner.h b/src/scanner.h |
index 387d3319c167c014177499e90698047e2b4364ae..c431cf110f36810c54807a4e8177127af26c759e 100644 |
--- a/src/scanner.h |
+++ b/src/scanner.h |
@@ -391,7 +391,9 @@ class Scanner { |
} |
const AstRawString* CurrentSymbol(AstValueFactory* ast_value_factory); |
+ const AstRawString* CurrentRawSymbol(AstValueFactory* ast_value_factory); |
const AstRawString* NextSymbol(AstValueFactory* ast_value_factory); |
+ const AstRawString* NextRawSymbol(AstValueFactory* ast_value_factory); |
double DoubleValue(); |
bool LiteralMatches(const char* data, int length, bool allow_escapes = true) { |
@@ -458,6 +460,8 @@ class Scanner { |
void SetHarmonyClasses(bool classes) { |
harmony_classes_ = classes; |
} |
+ bool HarmonyTemplates() const { return harmony_templates_; } |
+ void SetHarmonyTemplates(bool templates) { harmony_templates_ = templates; } |
// Returns true if there was a line terminator before the peek'ed token, |
// possibly inside a multi-line comment. |
@@ -473,6 +477,9 @@ class Scanner { |
// be empty). |
bool ScanRegExpFlags(); |
+ // Scans the input as a template literal |
+ Token::Value ScanTemplateSpan(); |
+ |
const LiteralBuffer* source_url() const { return &source_url_; } |
const LiteralBuffer* source_mapping_url() const { |
return &source_mapping_url_; |
@@ -486,12 +493,13 @@ class Scanner { |
Token::Value token; |
Location location; |
LiteralBuffer* literal_chars; |
+ LiteralBuffer* raw_literal_chars; |
}; |
static const int kCharacterLookaheadBufferSize = 1; |
// Scans octal escape sequence. Also accepts "\0" decimal escape sequence. |
- uc32 ScanOctalEscape(uc32 c, int length); |
+ uc32 ScanOctalEscape(uc32 c, int length, bool recordRaw = false); |
// Call this after setting source_ to the input. |
void Init() { |
@@ -500,14 +508,19 @@ class Scanner { |
Advance(); |
// Initialize current_ to not refer to a literal. |
current_.literal_chars = NULL; |
+ current_.raw_literal_chars = NULL; |
} |
// Literal buffer support |
inline void StartLiteral() { |
LiteralBuffer* free_buffer = (current_.literal_chars == &literal_buffer1_) ? |
&literal_buffer2_ : &literal_buffer1_; |
+ LiteralBuffer* raw_buffer = (current_.raw_literal_chars == &raw_buffer1_) |
+ ? &raw_buffer2_ |
+ : &raw_buffer1_; |
free_buffer->Reset(); |
next_.literal_chars = free_buffer; |
+ next_.raw_literal_chars = raw_buffer; |
} |
INLINE(void AddLiteralChar(uc32 c)) { |
@@ -515,6 +528,11 @@ class Scanner { |
next_.literal_chars->AddChar(c); |
} |
+ INLINE(void AddRawLiteralChar(uc32 c)) { |
+ DCHECK_NOT_NULL(next_.raw_literal_chars); |
+ next_.raw_literal_chars->AddChar(c); |
+ } |
+ |
// Complete scanning of a literal. |
inline void TerminateLiteral() { |
// Does nothing in the current implementation. |
@@ -583,10 +601,22 @@ class Scanner { |
DCHECK_NOT_NULL(current_.literal_chars); |
return current_.literal_chars->two_byte_literal(); |
} |
+ Vector<const uint8_t> raw_one_byte_string() { |
+ DCHECK_NOT_NULL(current_.raw_literal_chars); |
+ return current_.raw_literal_chars->one_byte_literal(); |
+ } |
+ Vector<const uint16_t> raw_two_byte_string() { |
+ DCHECK_NOT_NULL(current_.raw_literal_chars); |
+ return current_.raw_literal_chars->two_byte_literal(); |
+ } |
bool is_literal_one_byte() { |
DCHECK_NOT_NULL(current_.literal_chars); |
return current_.literal_chars->is_one_byte(); |
} |
+ bool is_raw_one_byte() { |
+ DCHECK_NOT_NULL(current_.raw_literal_chars); |
+ return current_.raw_literal_chars->is_one_byte(); |
+ } |
int literal_length() const { |
DCHECK_NOT_NULL(current_.literal_chars); |
return current_.literal_chars->length(); |
@@ -601,16 +631,28 @@ class Scanner { |
DCHECK_NOT_NULL(next_.literal_chars); |
return next_.literal_chars->two_byte_literal(); |
} |
+ Vector<const uint8_t> next_raw_one_byte_string() { |
+ DCHECK_NOT_NULL(next_.raw_literal_chars); |
+ return next_.raw_literal_chars->one_byte_literal(); |
+ } |
+ Vector<const uint16_t> next_raw_two_byte_string() { |
+ DCHECK_NOT_NULL(next_.raw_literal_chars); |
+ return next_.raw_literal_chars->two_byte_literal(); |
+ } |
bool is_next_literal_one_byte() { |
DCHECK_NOT_NULL(next_.literal_chars); |
return next_.literal_chars->is_one_byte(); |
} |
+ bool is_next_raw_one_byte() { |
+ DCHECK_NOT_NULL(next_.raw_literal_chars); |
+ return next_.raw_literal_chars->is_one_byte(); |
+ } |
int next_literal_length() const { |
DCHECK_NOT_NULL(next_.literal_chars); |
return next_.literal_chars->length(); |
} |
- uc32 ScanHexNumber(int expected_length); |
+ uc32 ScanHexNumber(int expected_length, bool recordRaw = false); |
// Scans a single JavaScript token. |
void Scan(); |
@@ -633,7 +675,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. |
- bool ScanEscape(); |
+ bool ScanEscape(bool recordRaw = false); |
// Decodes a Unicode escape-sequence which is part of an identifier. |
// If the escape sequence cannot be decoded the result is kBadChar. |
uc32 ScanIdentifierUnicodeEscape(); |
@@ -653,6 +695,10 @@ class Scanner { |
LiteralBuffer literal_buffer1_; |
LiteralBuffer literal_buffer2_; |
+ // Buffer to store raw string values |
+ LiteralBuffer raw_buffer1_; |
+ LiteralBuffer raw_buffer2_; |
+ |
// Values parsed from magic comments. |
LiteralBuffer source_url_; |
LiteralBuffer source_mapping_url_; |
@@ -685,6 +731,8 @@ class Scanner { |
bool harmony_numeric_literals_; |
// Whether we scan 'class', 'extends', 'static' and 'super' as keywords. |
bool harmony_classes_; |
+ // Whether we scan TEMPLATE_SPAN and TEMPLATE_TAIL |
+ bool harmony_templates_; |
}; |
} } // namespace v8::internal |