OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #ifndef V8_PARSER_H_ | 5 #ifndef V8_PARSER_H_ |
6 #define V8_PARSER_H_ | 6 #define V8_PARSER_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/ast.h" | 9 #include "src/ast.h" |
10 #include "src/compiler.h" // For CachedDataMode | 10 #include "src/compiler.h" // For CachedDataMode |
(...skipping 13 matching lines...) Expand all Loading... | |
24 class Target; | 24 class Target; |
25 | 25 |
26 | 26 |
27 class FunctionEntry BASE_EMBEDDED { | 27 class FunctionEntry BASE_EMBEDDED { |
28 public: | 28 public: |
29 enum { | 29 enum { |
30 kStartPositionIndex, | 30 kStartPositionIndex, |
31 kEndPositionIndex, | 31 kEndPositionIndex, |
32 kLiteralCountIndex, | 32 kLiteralCountIndex, |
33 kPropertyCountIndex, | 33 kPropertyCountIndex, |
34 kStrictModeIndex, | 34 kLanguageModeIndex, |
35 kSize | 35 kSize |
36 }; | 36 }; |
37 | 37 |
38 explicit FunctionEntry(Vector<unsigned> backing) | 38 explicit FunctionEntry(Vector<unsigned> backing) |
39 : backing_(backing) { } | 39 : backing_(backing) { } |
40 | 40 |
41 FunctionEntry() : backing_() { } | 41 FunctionEntry() : backing_() { } |
42 | 42 |
43 int start_pos() { return backing_[kStartPositionIndex]; } | 43 int start_pos() { return backing_[kStartPositionIndex]; } |
44 int end_pos() { return backing_[kEndPositionIndex]; } | 44 int end_pos() { return backing_[kEndPositionIndex]; } |
45 int literal_count() { return backing_[kLiteralCountIndex]; } | 45 int literal_count() { return backing_[kLiteralCountIndex]; } |
46 int property_count() { return backing_[kPropertyCountIndex]; } | 46 int property_count() { return backing_[kPropertyCountIndex]; } |
47 StrictMode strict_mode() { | 47 LanguageMode language_mode() { |
48 DCHECK(backing_[kStrictModeIndex] == SLOPPY || | 48 STATIC_ASSERT(LANGUAGE_END == 2); |
49 backing_[kStrictModeIndex] == STRICT); | 49 DCHECK(backing_[kLanguageModeIndex] == SLOPPY || |
rossberg
2015/02/03 12:26:20
Same here, could use is_valid_l_m
marja
2015/02/03 14:45:02
Done.
| |
50 return static_cast<StrictMode>(backing_[kStrictModeIndex]); | 50 backing_[kLanguageModeIndex] == STRICT); |
51 return static_cast<LanguageMode>(backing_[kLanguageModeIndex]); | |
51 } | 52 } |
52 | 53 |
53 bool is_valid() { return !backing_.is_empty(); } | 54 bool is_valid() { return !backing_.is_empty(); } |
54 | 55 |
55 private: | 56 private: |
56 Vector<unsigned> backing_; | 57 Vector<unsigned> backing_; |
57 }; | 58 }; |
58 | 59 |
59 | 60 |
60 // Wrapper around ScriptData to provide parser-specific functionality. | 61 // Wrapper around ScriptData to provide parser-specific functionality. |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
663 // function literal. Returns false (and deallocates any allocated AST | 664 // function literal. Returns false (and deallocates any allocated AST |
664 // nodes) if parsing failed. | 665 // nodes) if parsing failed. |
665 static bool Parse(CompilationInfo* info, | 666 static bool Parse(CompilationInfo* info, |
666 bool allow_lazy = false) { | 667 bool allow_lazy = false) { |
667 ParseInfo parse_info = {info->isolate()->stack_guard()->real_climit(), | 668 ParseInfo parse_info = {info->isolate()->stack_guard()->real_climit(), |
668 info->isolate()->heap()->HashSeed(), | 669 info->isolate()->heap()->HashSeed(), |
669 info->isolate()->unicode_cache()}; | 670 info->isolate()->unicode_cache()}; |
670 Parser parser(info, &parse_info); | 671 Parser parser(info, &parse_info); |
671 parser.set_allow_lazy(allow_lazy); | 672 parser.set_allow_lazy(allow_lazy); |
672 if (parser.Parse()) { | 673 if (parser.Parse()) { |
673 info->SetStrictMode(info->function()->strict_mode()); | 674 info->SetLanguageMode(info->function()->language_mode()); |
674 return true; | 675 return true; |
675 } | 676 } |
676 return false; | 677 return false; |
677 } | 678 } |
678 bool Parse(); | 679 bool Parse(); |
679 void ParseOnBackground(); | 680 void ParseOnBackground(); |
680 | 681 |
681 // Handle errors detected during parsing, move statistics to Isolate, | 682 // Handle errors detected during parsing, move statistics to Isolate, |
682 // internalize strings (move them to the heap). | 683 // internalize strings (move them to the heap). |
683 void Internalize(); | 684 void Internalize(); |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
995 } | 996 } |
996 | 997 |
997 | 998 |
998 Expression* ParserTraits::CloseTemplateLiteral(TemplateLiteralState* state, | 999 Expression* ParserTraits::CloseTemplateLiteral(TemplateLiteralState* state, |
999 int start, Expression* tag) { | 1000 int start, Expression* tag) { |
1000 return parser_->CloseTemplateLiteral(state, start, tag); | 1001 return parser_->CloseTemplateLiteral(state, start, tag); |
1001 } | 1002 } |
1002 } } // namespace v8::internal | 1003 } } // namespace v8::internal |
1003 | 1004 |
1004 #endif // V8_PARSER_H_ | 1005 #endif // V8_PARSER_H_ |
OLD | NEW |