Chromium Code Reviews| 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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 387 bool UnescapedLiteralMatches(const char* data, int length) { | 387 bool UnescapedLiteralMatches(const char* data, int length) { |
| 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 !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 | |
| 398 bool LiteralMatches(const char* data, int length) { | |
| 399 if (current_token() == Token::STRING && | |
|
caitp (gmail)
2014/10/01 20:52:18
The check for Token::STRING is simply because I do
| |
| 400 is_literal_one_byte() && | |
| 401 literal_length() == length) { | |
| 402 const char* token = | |
| 403 reinterpret_cast<const char*>(literal_one_byte_string().start()); | |
| 404 return !strncmp(token, data, length); | |
| 405 } | |
| 406 return UnescapedLiteralMatches(data, length); | |
|
caitp (gmail)
2014/10/01 20:52:18
But if it does turn out to be necessary, I want to
arv (Not doing code reviews)
2014/10/01 21:00:35
Is the only difference here is the literal_contain
| |
| 407 } | |
| 408 | |
| 397 void IsGetOrSet(bool* is_get, bool* is_set) { | 409 void IsGetOrSet(bool* is_get, bool* is_set) { |
| 398 if (is_literal_one_byte() && | 410 if (is_literal_one_byte() && |
| 399 literal_length() == 3 && | 411 literal_length() == 3 && |
| 400 !literal_contains_escapes()) { | 412 !literal_contains_escapes()) { |
| 401 const char* token = | 413 const char* token = |
| 402 reinterpret_cast<const char*>(literal_one_byte_string().start()); | 414 reinterpret_cast<const char*>(literal_one_byte_string().start()); |
| 403 *is_get = strncmp(token, "get", 3) == 0; | 415 *is_get = strncmp(token, "get", 3) == 0; |
| 404 *is_set = !*is_get && strncmp(token, "set", 3) == 0; | 416 *is_set = !*is_get && strncmp(token, "set", 3) == 0; |
| 405 } | 417 } |
| 406 } | 418 } |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 653 bool harmony_modules_; | 665 bool harmony_modules_; |
| 654 // Whether we scan 0o777 and 0b111 as numbers. | 666 // Whether we scan 0o777 and 0b111 as numbers. |
| 655 bool harmony_numeric_literals_; | 667 bool harmony_numeric_literals_; |
| 656 // Whether we scan 'class', 'extends', 'static' and 'super' as keywords. | 668 // Whether we scan 'class', 'extends', 'static' and 'super' as keywords. |
| 657 bool harmony_classes_; | 669 bool harmony_classes_; |
| 658 }; | 670 }; |
| 659 | 671 |
| 660 } } // namespace v8::internal | 672 } } // namespace v8::internal |
| 661 | 673 |
| 662 #endif // V8_SCANNER_H_ | 674 #endif // V8_SCANNER_H_ |
| OLD | NEW |