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