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 DCHECK(is_valid_language_mode(backing_[kLanguageModeIndex])); |
49 backing_[kStrictModeIndex] == STRICT); | 49 return static_cast<LanguageMode>(backing_[kLanguageModeIndex]); |
50 return static_cast<StrictMode>(backing_[kStrictModeIndex]); | |
51 } | 50 } |
52 | 51 |
53 bool is_valid() { return !backing_.is_empty(); } | 52 bool is_valid() { return !backing_.is_empty(); } |
54 | 53 |
55 private: | 54 private: |
56 Vector<unsigned> backing_; | 55 Vector<unsigned> backing_; |
57 }; | 56 }; |
58 | 57 |
59 | 58 |
60 // Wrapper around ScriptData to provide parser-specific functionality. | 59 // Wrapper around ScriptData to provide parser-specific functionality. |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 // function literal. Returns false (and deallocates any allocated AST | 663 // function literal. Returns false (and deallocates any allocated AST |
665 // nodes) if parsing failed. | 664 // nodes) if parsing failed. |
666 static bool Parse(CompilationInfo* info, | 665 static bool Parse(CompilationInfo* info, |
667 bool allow_lazy = false) { | 666 bool allow_lazy = false) { |
668 ParseInfo parse_info = {info->isolate()->stack_guard()->real_climit(), | 667 ParseInfo parse_info = {info->isolate()->stack_guard()->real_climit(), |
669 info->isolate()->heap()->HashSeed(), | 668 info->isolate()->heap()->HashSeed(), |
670 info->isolate()->unicode_cache()}; | 669 info->isolate()->unicode_cache()}; |
671 Parser parser(info, &parse_info); | 670 Parser parser(info, &parse_info); |
672 parser.set_allow_lazy(allow_lazy); | 671 parser.set_allow_lazy(allow_lazy); |
673 if (parser.Parse()) { | 672 if (parser.Parse()) { |
674 info->SetStrictMode(info->function()->strict_mode()); | 673 info->SetLanguageMode(info->function()->language_mode()); |
675 return true; | 674 return true; |
676 } | 675 } |
677 return false; | 676 return false; |
678 } | 677 } |
679 bool Parse(); | 678 bool Parse(); |
680 void ParseOnBackground(); | 679 void ParseOnBackground(); |
681 | 680 |
682 // Handle errors detected during parsing, move statistics to Isolate, | 681 // Handle errors detected during parsing, move statistics to Isolate, |
683 // internalize strings (move them to the heap). | 682 // internalize strings (move them to the heap). |
684 void Internalize(); | 683 void Internalize(); |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 } | 997 } |
999 | 998 |
1000 | 999 |
1001 Expression* ParserTraits::CloseTemplateLiteral(TemplateLiteralState* state, | 1000 Expression* ParserTraits::CloseTemplateLiteral(TemplateLiteralState* state, |
1002 int start, Expression* tag) { | 1001 int start, Expression* tag) { |
1003 return parser_->CloseTemplateLiteral(state, start, tag); | 1002 return parser_->CloseTemplateLiteral(state, start, tag); |
1004 } | 1003 } |
1005 } } // namespace v8::internal | 1004 } } // namespace v8::internal |
1006 | 1005 |
1007 #endif // V8_PARSER_H_ | 1006 #endif // V8_PARSER_H_ |
OLD | NEW |