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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 | 493 |
485 // Factory methods. | 494 // Factory methods. |
486 FunctionLiteral* DefaultConstructor(const AstRawString* name, bool call_super, | 495 FunctionLiteral* DefaultConstructor(const AstRawString* name, bool call_super, |
487 bool requires_class_field_init, int pos, | 496 bool requires_class_field_init, int pos, |
488 int end_pos, LanguageMode language_mode); | 497 int end_pos, LanguageMode language_mode); |
489 | 498 |
490 // Skip over a lazy function, either using cached data if we have it, or | 499 // Skip over a lazy function, either using cached data if we have it, or |
491 // by parsing the function with PreParser. Consumes the ending }. | 500 // by parsing the function with PreParser. Consumes the ending }. |
492 // If may_abort == true, the (pre-)parser may decide to abort skipping | 501 // If may_abort == true, the (pre-)parser may decide to abort skipping |
493 // in order to force the function to be eagerly parsed, after all. | 502 // in order to force the function to be eagerly parsed, after all. |
494 LazyParsingResult SkipLazyFunctionBody(int* materialized_literal_count, | 503 LazyParsingResult SkipLazyFunction( |
495 int* expected_property_count, | 504 FunctionKind kind, DeclarationScope* function_scope, int* num_parameters, |
496 bool is_inner_function, bool may_abort, | 505 int* function_length, bool* has_duplicate_parameters, |
497 bool* ok); | 506 int* materialized_literal_count, int* expected_property_count, |
| 507 bool is_inner_function, bool may_abort, bool* ok); |
498 | 508 |
499 PreParser::PreParseResult ParseFunctionBodyWithPreParser( | 509 PreParser::PreParseResult ParseFunctionWithPreParser(FunctionKind kind, |
500 SingletonLogger* logger, bool is_inner_function, bool may_abort); | 510 DeclarationScope* scope, |
| 511 SingletonLogger* logger, |
| 512 bool is_inner_function, |
| 513 bool may_abort); |
501 | 514 |
502 Block* BuildParameterInitializationBlock( | 515 Block* BuildParameterInitializationBlock( |
503 const ParserFormalParameters& parameters, bool* ok); | 516 const ParserFormalParameters& parameters, bool* ok); |
504 Block* BuildRejectPromiseOnException(Block* block, bool* ok); | 517 Block* BuildRejectPromiseOnException(Block* block, bool* ok); |
505 | 518 |
506 // Consumes the ending }. | 519 // Consumes the ending }. |
507 ZoneList<Statement*>* ParseEagerFunctionBody( | 520 ZoneList<Statement*>* ParseEagerFunctionBody( |
508 const AstRawString* function_name, int pos, | 521 const AstRawString* function_name, int pos, |
509 const ParserFormalParameters& parameters, FunctionKind kind, | 522 const ParserFormalParameters& parameters, FunctionKind kind, |
510 FunctionLiteral::FunctionType function_type, bool* ok); | 523 FunctionLiteral::FunctionType function_type, bool* ok); |
511 | 524 |
| 525 ZoneList<Statement*>* ParseFunctionParametersAndBodyEagerly( |
| 526 const AstRawString* function_name, int pos, FunctionKind kind, |
| 527 FunctionLiteral::FunctionType function_type, |
| 528 DeclarationScope* function_scope, int* num_parameters, |
| 529 int* function_length, bool* has_duplicate_parameters, |
| 530 int* materialized_literal_count, int* expected_property_count, bool* ok); |
| 531 |
512 void ThrowPendingError(Isolate* isolate, Handle<Script> script); | 532 void ThrowPendingError(Isolate* isolate, Handle<Script> script); |
513 | 533 |
514 class TemplateLiteral : public ZoneObject { | 534 class TemplateLiteral : public ZoneObject { |
515 public: | 535 public: |
516 TemplateLiteral(Zone* zone, int pos) | 536 TemplateLiteral(Zone* zone, int pos) |
517 : cooked_(8, zone), raw_(8, zone), expressions_(8, zone), pos_(pos) {} | 537 : cooked_(8, zone), raw_(8, zone), expressions_(8, zone), pos_(pos) {} |
518 | 538 |
519 const ZoneList<Expression*>* cooked() const { return &cooked_; } | 539 const ZoneList<Expression*>* cooked() const { return &cooked_; } |
520 const ZoneList<Expression*>* raw() const { return &raw_; } | 540 const ZoneList<Expression*>* raw() const { return &raw_; } |
521 const ZoneList<Expression*>* expressions() const { return &expressions_; } | 541 const ZoneList<Expression*>* expressions() const { return &expressions_; } |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 | 1163 |
1144 private: | 1164 private: |
1145 ParserTarget** variable_; | 1165 ParserTarget** variable_; |
1146 ParserTarget* previous_; | 1166 ParserTarget* previous_; |
1147 }; | 1167 }; |
1148 | 1168 |
1149 } // namespace internal | 1169 } // namespace internal |
1150 } // namespace v8 | 1170 } // namespace v8 |
1151 | 1171 |
1152 #endif // V8_PARSING_PARSER_H_ | 1172 #endif // V8_PARSING_PARSER_H_ |
OLD | NEW |