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_PARSING_PARSER_H_ | 5 #ifndef V8_PARSING_PARSER_H_ |
6 #define V8_PARSING_PARSER_H_ | 6 #define V8_PARSING_PARSER_H_ |
7 | 7 |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/base/compiler-specific.h" | 10 #include "src/base/compiler-specific.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 namespace internal { | 22 namespace internal { |
23 | 23 |
24 class ParseInfo; | 24 class ParseInfo; |
25 class ScriptData; | 25 class ScriptData; |
26 class ParserTarget; | 26 class ParserTarget; |
27 class ParserTargetScope; | 27 class ParserTargetScope; |
28 | 28 |
29 class FunctionEntry BASE_EMBEDDED { | 29 class FunctionEntry BASE_EMBEDDED { |
30 public: | 30 public: |
31 enum { | 31 enum { |
| 32 kKeyPositionIndex, |
32 kStartPositionIndex, | 33 kStartPositionIndex, |
33 kEndPositionIndex, | 34 kEndPositionIndex, |
| 35 kNumParametersIndex, |
| 36 kFunctionLengthIndex, |
| 37 kHasDuplicateParametersIndex, |
34 kLiteralCountIndex, | 38 kLiteralCountIndex, |
35 kPropertyCountIndex, | 39 kPropertyCountIndex, |
36 kLanguageModeIndex, | 40 kLanguageModeIndex, |
37 kUsesSuperPropertyIndex, | 41 kUsesSuperPropertyIndex, |
38 kCallsEvalIndex, | 42 kCallsEvalIndex, |
39 kSize | 43 kSize |
40 }; | 44 }; |
41 | 45 |
42 explicit FunctionEntry(Vector<unsigned> backing) | 46 explicit FunctionEntry(Vector<unsigned> backing) |
43 : backing_(backing) { } | 47 : backing_(backing) { } |
44 | 48 |
45 FunctionEntry() : backing_() { } | 49 FunctionEntry() : backing_() { } |
46 | 50 |
47 int start_pos() { return backing_[kStartPositionIndex]; } | 51 int start_pos() const { return backing_[kStartPositionIndex]; } |
48 int end_pos() { return backing_[kEndPositionIndex]; } | 52 int end_pos() const { return backing_[kEndPositionIndex]; } |
49 int literal_count() { return backing_[kLiteralCountIndex]; } | 53 int num_parameters() const { return backing_[kNumParametersIndex]; } |
50 int property_count() { return backing_[kPropertyCountIndex]; } | 54 int function_length() const { return backing_[kFunctionLengthIndex]; } |
51 LanguageMode language_mode() { | 55 bool has_duplicate_parameters() const { |
| 56 return backing_[kHasDuplicateParametersIndex]; |
| 57 } |
| 58 int literal_count() const { return backing_[kLiteralCountIndex]; } |
| 59 int property_count() const { return backing_[kPropertyCountIndex]; } |
| 60 LanguageMode language_mode() const { |
52 DCHECK(is_valid_language_mode(backing_[kLanguageModeIndex])); | 61 DCHECK(is_valid_language_mode(backing_[kLanguageModeIndex])); |
53 return static_cast<LanguageMode>(backing_[kLanguageModeIndex]); | 62 return static_cast<LanguageMode>(backing_[kLanguageModeIndex]); |
54 } | 63 } |
55 bool uses_super_property() { return backing_[kUsesSuperPropertyIndex]; } | 64 bool uses_super_property() const { return backing_[kUsesSuperPropertyIndex]; } |
56 bool calls_eval() { return backing_[kCallsEvalIndex]; } | 65 bool calls_eval() const { return backing_[kCallsEvalIndex]; } |
57 | 66 |
58 bool is_valid() { return !backing_.is_empty(); } | 67 bool is_valid() const { return !backing_.is_empty(); } |
59 | 68 |
60 private: | 69 private: |
61 Vector<unsigned> backing_; | 70 Vector<unsigned> backing_; |
62 }; | 71 }; |
63 | 72 |
64 | 73 |
65 // Wrapper around ScriptData to provide parser-specific functionality. | 74 // Wrapper around ScriptData to provide parser-specific functionality. |
66 class ParseData { | 75 class ParseData { |
67 public: | 76 public: |
68 static ParseData* FromCachedData(ScriptData* cached_data) { | 77 static ParseData* FromCachedData(ScriptData* cached_data) { |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 | 492 |
484 // Factory methods. | 493 // Factory methods. |
485 FunctionLiteral* DefaultConstructor(const AstRawString* name, bool call_super, | 494 FunctionLiteral* DefaultConstructor(const AstRawString* name, bool call_super, |
486 bool requires_class_field_init, int pos, | 495 bool requires_class_field_init, int pos, |
487 int end_pos, LanguageMode language_mode); | 496 int end_pos, LanguageMode language_mode); |
488 | 497 |
489 // Skip over a lazy function, either using cached data if we have it, or | 498 // Skip over a lazy function, either using cached data if we have it, or |
490 // by parsing the function with PreParser. Consumes the ending }. | 499 // by parsing the function with PreParser. Consumes the ending }. |
491 // If may_abort == true, the (pre-)parser may decide to abort skipping | 500 // If may_abort == true, the (pre-)parser may decide to abort skipping |
492 // in order to force the function to be eagerly parsed, after all. | 501 // in order to force the function to be eagerly parsed, after all. |
493 LazyParsingResult SkipLazyFunctionBody(int* materialized_literal_count, | 502 LazyParsingResult SkipLazyFunction( |
494 int* expected_property_count, | 503 FunctionKind kind, DeclarationScope* function_scope, int* num_parameters, |
495 bool is_inner_function, bool may_abort, | 504 int* function_length, bool* has_duplicate_parameters, |
496 bool* ok); | 505 int* materialized_literal_count, int* expected_property_count, |
| 506 bool is_inner_function, bool may_abort, bool* ok); |
497 | 507 |
498 PreParser::PreParseResult ParseFunctionBodyWithPreParser( | 508 PreParser::PreParseResult ParseFunctionWithPreParser(FunctionKind kind, |
499 SingletonLogger* logger, bool is_inner_function, bool may_abort); | 509 DeclarationScope* scope, |
| 510 SingletonLogger* logger, |
| 511 bool is_inner_function, |
| 512 bool may_abort); |
500 | 513 |
501 Block* BuildParameterInitializationBlock( | 514 Block* BuildParameterInitializationBlock( |
502 const ParserFormalParameters& parameters, bool* ok); | 515 const ParserFormalParameters& parameters, bool* ok); |
503 Block* BuildRejectPromiseOnException(Block* block, bool* ok); | 516 Block* BuildRejectPromiseOnException(Block* block, bool* ok); |
504 | 517 |
505 // Consumes the ending }. | 518 // Consumes the ending }. |
506 ZoneList<Statement*>* ParseEagerFunctionBody( | 519 ZoneList<Statement*>* ParseEagerFunctionBody( |
507 const AstRawString* function_name, int pos, | 520 const AstRawString* function_name, int pos, |
508 const ParserFormalParameters& parameters, FunctionKind kind, | 521 const ParserFormalParameters& parameters, FunctionKind kind, |
509 FunctionLiteral::FunctionType function_type, bool* ok); | 522 FunctionLiteral::FunctionType function_type, bool* ok); |
510 | 523 |
| 524 ZoneList<Statement*>* ParseFunctionParametersAndBodyEagerly( |
| 525 const AstRawString* function_name, int pos, FunctionKind kind, |
| 526 FunctionLiteral::FunctionType function_type, |
| 527 DeclarationScope* function_scope, int* num_parameters, |
| 528 int* function_length, bool* has_duplicate_parameters, |
| 529 int* materialized_literal_count, int* expected_property_count, bool* ok); |
| 530 |
511 void ThrowPendingError(Isolate* isolate, Handle<Script> script); | 531 void ThrowPendingError(Isolate* isolate, Handle<Script> script); |
512 | 532 |
513 class TemplateLiteral : public ZoneObject { | 533 class TemplateLiteral : public ZoneObject { |
514 public: | 534 public: |
515 TemplateLiteral(Zone* zone, int pos) | 535 TemplateLiteral(Zone* zone, int pos) |
516 : cooked_(8, zone), raw_(8, zone), expressions_(8, zone), pos_(pos) {} | 536 : cooked_(8, zone), raw_(8, zone), expressions_(8, zone), pos_(pos) {} |
517 | 537 |
518 const ZoneList<Expression*>* cooked() const { return &cooked_; } | 538 const ZoneList<Expression*>* cooked() const { return &cooked_; } |
519 const ZoneList<Expression*>* raw() const { return &raw_; } | 539 const ZoneList<Expression*>* raw() const { return &raw_; } |
520 const ZoneList<Expression*>* expressions() const { return &expressions_; } | 540 const ZoneList<Expression*>* expressions() const { return &expressions_; } |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 | 1162 |
1143 private: | 1163 private: |
1144 ParserTarget** variable_; | 1164 ParserTarget** variable_; |
1145 ParserTarget* previous_; | 1165 ParserTarget* previous_; |
1146 }; | 1166 }; |
1147 | 1167 |
1148 } // namespace internal | 1168 } // namespace internal |
1149 } // namespace v8 | 1169 } // namespace v8 |
1150 | 1170 |
1151 #endif // V8_PARSING_PARSER_H_ | 1171 #endif // V8_PARSING_PARSER_H_ |
OLD | NEW |