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" |
11 #include "src/char-predicates.h" | 11 #include "src/char-predicates.h" |
12 #include "src/checks.h" | 12 #include "src/checks.h" |
13 #include "src/globals.h" | 13 #include "src/globals.h" |
14 #include "src/hashmap.h" | 14 #include "src/hashmap.h" |
15 #include "src/list.h" | 15 #include "src/list.h" |
16 #include "src/token.h" | 16 #include "src/token.h" |
17 #include "src/unicode-inl.h" | 17 #include "src/unicode-inl.h" |
18 #include "src/utils.h" | 18 #include "src/utils.h" |
19 | 19 |
20 namespace v8 { | 20 namespace v8 { |
21 namespace internal { | 21 namespace internal { |
22 | 22 |
23 | 23 |
| 24 class AstRawString; |
| 25 class AstValueFactory; |
24 class ParserRecorder; | 26 class ParserRecorder; |
25 | 27 |
26 | 28 |
27 // Returns the value (0 .. 15) of a hexadecimal character c. | 29 // Returns the value (0 .. 15) of a hexadecimal character c. |
28 // If c is not a legal hexadecimal character, returns a value < 0. | 30 // If c is not a legal hexadecimal character, returns a value < 0. |
29 inline int HexValue(uc32 c) { | 31 inline int HexValue(uc32 c) { |
30 c -= '0'; | 32 c -= '0'; |
31 if (static_cast<unsigned>(c) <= 9) return c; | 33 if (static_cast<unsigned>(c) <= 9) return c; |
32 c = (c | 0x20) - ('a' - '0'); // detect 0x11..0x16 and 0x31..0x36. | 34 c = (c | 0x20) - ('a' - '0'); // detect 0x11..0x16 and 0x31..0x36. |
33 if (static_cast<unsigned>(c) <= 5) return c + 10; | 35 if (static_cast<unsigned>(c) <= 5) return c + 10; |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 } | 371 } |
370 bool is_literal_contextual_keyword(Vector<const char> keyword) { | 372 bool is_literal_contextual_keyword(Vector<const char> keyword) { |
371 ASSERT_NOT_NULL(current_.literal_chars); | 373 ASSERT_NOT_NULL(current_.literal_chars); |
372 return current_.literal_chars->is_contextual_keyword(keyword); | 374 return current_.literal_chars->is_contextual_keyword(keyword); |
373 } | 375 } |
374 bool is_next_contextual_keyword(Vector<const char> keyword) { | 376 bool is_next_contextual_keyword(Vector<const char> keyword) { |
375 ASSERT_NOT_NULL(next_.literal_chars); | 377 ASSERT_NOT_NULL(next_.literal_chars); |
376 return next_.literal_chars->is_contextual_keyword(keyword); | 378 return next_.literal_chars->is_contextual_keyword(keyword); |
377 } | 379 } |
378 | 380 |
379 Handle<String> AllocateNextLiteralString(Isolate* isolate, | 381 const AstRawString* CurrentSymbol(AstValueFactory* ast_value_factory); |
380 PretenureFlag tenured); | 382 const AstRawString* NextSymbol(AstValueFactory* ast_value_factory); |
381 Handle<String> AllocateInternalizedString(Isolate* isolate); | |
382 | 383 |
383 double DoubleValue(); | 384 double DoubleValue(); |
384 bool UnescapedLiteralMatches(const char* data, int length) { | 385 bool UnescapedLiteralMatches(const char* data, int length) { |
385 if (is_literal_one_byte() && | 386 if (is_literal_one_byte() && |
386 literal_length() == length && | 387 literal_length() == length && |
387 !literal_contains_escapes()) { | 388 !literal_contains_escapes()) { |
388 const char* token = | 389 const char* token = |
389 reinterpret_cast<const char*>(literal_one_byte_string().start()); | 390 reinterpret_cast<const char*>(literal_one_byte_string().start()); |
390 return !strncmp(token, data, length); | 391 return !strncmp(token, data, length); |
391 } | 392 } |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 bool harmony_scoping_; | 630 bool harmony_scoping_; |
630 // Whether we scan 'module', 'import', 'export' as keywords. | 631 // Whether we scan 'module', 'import', 'export' as keywords. |
631 bool harmony_modules_; | 632 bool harmony_modules_; |
632 // Whether we scan 0o777 and 0b111 as numbers. | 633 // Whether we scan 0o777 and 0b111 as numbers. |
633 bool harmony_numeric_literals_; | 634 bool harmony_numeric_literals_; |
634 }; | 635 }; |
635 | 636 |
636 } } // namespace v8::internal | 637 } } // namespace v8::internal |
637 | 638 |
638 #endif // V8_SCANNER_H_ | 639 #endif // V8_SCANNER_H_ |
OLD | NEW |