OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Features shared by parsing and pre-parsing scanners. | 5 // Features shared by parsing and pre-parsing scanners. |
6 | 6 |
7 #ifndef V8_SCANNER_H_ | 7 #ifndef V8_SCANNER_H_ |
8 #define V8_SCANNER_H_ | 8 #define V8_SCANNER_H_ |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
377 } | 377 } |
378 bool is_next_contextual_keyword(Vector<const char> keyword) { | 378 bool is_next_contextual_keyword(Vector<const char> keyword) { |
379 DCHECK_NOT_NULL(next_.literal_chars); | 379 DCHECK_NOT_NULL(next_.literal_chars); |
380 return next_.literal_chars->is_contextual_keyword(keyword); | 380 return next_.literal_chars->is_contextual_keyword(keyword); |
381 } | 381 } |
382 | 382 |
383 const AstRawString* CurrentSymbol(AstValueFactory* ast_value_factory); | 383 const AstRawString* CurrentSymbol(AstValueFactory* ast_value_factory); |
384 const AstRawString* NextSymbol(AstValueFactory* ast_value_factory); | 384 const AstRawString* NextSymbol(AstValueFactory* ast_value_factory); |
385 | 385 |
386 double DoubleValue(); | 386 double DoubleValue(); |
387 bool UnescapedLiteralMatches(const char* data, int length) { | 387 bool LiteralMatches(const char* data, int length, bool allow_escapes) { |
arv (Not doing code reviews)
2014/10/01 21:47:01
You can use default params here:
bool allow_escap
| |
388 if (is_literal_one_byte() && | 388 if (is_literal_one_byte() && |
389 literal_length() == length && | 389 literal_length() == length && |
390 !literal_contains_escapes()) { | 390 (allow_escapes || !literal_contains_escapes())) { |
391 const char* token = | 391 const char* token = |
392 reinterpret_cast<const char*>(literal_one_byte_string().start()); | 392 reinterpret_cast<const char*>(literal_one_byte_string().start()); |
393 return !strncmp(token, data, length); | 393 return !strncmp(token, data, length); |
394 } | 394 } |
395 return false; | 395 return false; |
396 } | 396 } |
397 inline bool UnescapedLiteralMatches(const char* data, int length) { | |
398 return LiteralMatches(data, length, false); | |
399 } | |
400 | |
401 inline bool LiteralMatches(const char* data, int length) { | |
arv (Not doing code reviews)
2014/10/01 21:47:01
Then this can be removed
| |
402 return LiteralMatches(data, length, true); | |
403 } | |
404 | |
397 void IsGetOrSet(bool* is_get, bool* is_set) { | 405 void IsGetOrSet(bool* is_get, bool* is_set) { |
398 if (is_literal_one_byte() && | 406 if (is_literal_one_byte() && |
399 literal_length() == 3 && | 407 literal_length() == 3 && |
400 !literal_contains_escapes()) { | 408 !literal_contains_escapes()) { |
401 const char* token = | 409 const char* token = |
402 reinterpret_cast<const char*>(literal_one_byte_string().start()); | 410 reinterpret_cast<const char*>(literal_one_byte_string().start()); |
403 *is_get = strncmp(token, "get", 3) == 0; | 411 *is_get = strncmp(token, "get", 3) == 0; |
404 *is_set = !*is_get && strncmp(token, "set", 3) == 0; | 412 *is_set = !*is_get && strncmp(token, "set", 3) == 0; |
405 } | 413 } |
406 } | 414 } |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
653 bool harmony_modules_; | 661 bool harmony_modules_; |
654 // Whether we scan 0o777 and 0b111 as numbers. | 662 // Whether we scan 0o777 and 0b111 as numbers. |
655 bool harmony_numeric_literals_; | 663 bool harmony_numeric_literals_; |
656 // Whether we scan 'class', 'extends', 'static' and 'super' as keywords. | 664 // Whether we scan 'class', 'extends', 'static' and 'super' as keywords. |
657 bool harmony_classes_; | 665 bool harmony_classes_; |
658 }; | 666 }; |
659 | 667 |
660 } } // namespace v8::internal | 668 } } // namespace v8::internal |
661 | 669 |
662 #endif // V8_SCANNER_H_ | 670 #endif // V8_SCANNER_H_ |
OLD | NEW |