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/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
10 #include "src/ast/scopes.h" | 10 #include "src/ast/scopes.h" |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 typedef AstNodeFactory Factory; | 348 typedef AstNodeFactory Factory; |
349 }; | 349 }; |
350 | 350 |
351 explicit ParserTraits(Parser* parser) : parser_(parser) {} | 351 explicit ParserTraits(Parser* parser) : parser_(parser) {} |
352 | 352 |
353 // Helper functions for recursive descent. | 353 // Helper functions for recursive descent. |
354 bool IsEval(const AstRawString* identifier) const; | 354 bool IsEval(const AstRawString* identifier) const; |
355 bool IsArguments(const AstRawString* identifier) const; | 355 bool IsArguments(const AstRawString* identifier) const; |
356 bool IsEvalOrArguments(const AstRawString* identifier) const; | 356 bool IsEvalOrArguments(const AstRawString* identifier) const; |
357 bool IsUndefined(const AstRawString* identifier) const; | 357 bool IsUndefined(const AstRawString* identifier) const; |
| 358 bool IsAwait(const AstRawString* identifier) const; |
358 V8_INLINE bool IsFutureStrictReserved(const AstRawString* identifier) const; | 359 V8_INLINE bool IsFutureStrictReserved(const AstRawString* identifier) const; |
359 | 360 |
360 // Returns true if the expression is of type "this.foo". | 361 // Returns true if the expression is of type "this.foo". |
361 static bool IsThisProperty(Expression* expression); | 362 static bool IsThisProperty(Expression* expression); |
362 | 363 |
363 static bool IsIdentifier(Expression* expression); | 364 static bool IsIdentifier(Expression* expression); |
364 | 365 |
365 bool IsPrototype(const AstRawString* identifier) const; | 366 bool IsPrototype(const AstRawString* identifier) const; |
366 | 367 |
367 bool IsConstructor(const AstRawString* identifier) const; | 368 bool IsConstructor(const AstRawString* identifier) const; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 Scope* scope, const ParserFormalParameters::Parameter& parameter, | 542 Scope* scope, const ParserFormalParameters::Parameter& parameter, |
542 Type::ExpressionClassifier* classifier); | 543 Type::ExpressionClassifier* classifier); |
543 void ParseArrowFunctionFormalParameters(ParserFormalParameters* parameters, | 544 void ParseArrowFunctionFormalParameters(ParserFormalParameters* parameters, |
544 Expression* params, int end_pos, | 545 Expression* params, int end_pos, |
545 bool* ok); | 546 bool* ok); |
546 void ParseArrowFunctionFormalParameterList( | 547 void ParseArrowFunctionFormalParameterList( |
547 ParserFormalParameters* parameters, Expression* params, | 548 ParserFormalParameters* parameters, Expression* params, |
548 const Scanner::Location& params_loc, | 549 const Scanner::Location& params_loc, |
549 Scanner::Location* duplicate_loc, bool* ok); | 550 Scanner::Location* duplicate_loc, bool* ok); |
550 | 551 |
| 552 V8_INLINE Expression* ParseAsyncFunctionExpression(bool* ok); |
| 553 |
551 V8_INLINE DoExpression* ParseDoExpression(bool* ok); | 554 V8_INLINE DoExpression* ParseDoExpression(bool* ok); |
552 | 555 |
553 void ReindexLiterals(const ParserFormalParameters& parameters); | 556 void ReindexLiterals(const ParserFormalParameters& parameters); |
554 | 557 |
555 // Temporary glue; these functions will move to ParserBase. | 558 // Temporary glue; these functions will move to ParserBase. |
556 Expression* ParseV8Intrinsic(bool* ok); | 559 Expression* ParseV8Intrinsic(bool* ok); |
557 FunctionLiteral* ParseFunctionLiteral( | 560 FunctionLiteral* ParseFunctionLiteral( |
558 const AstRawString* name, Scanner::Location function_name_location, | 561 const AstRawString* name, Scanner::Location function_name_location, |
559 FunctionNameValidity function_name_validity, FunctionKind kind, | 562 FunctionNameValidity function_name_validity, FunctionKind kind, |
560 int function_token_position, FunctionLiteral::FunctionType type, | 563 int function_token_position, FunctionLiteral::FunctionType type, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 V8_INLINE ZoneList<v8::internal::Expression*>* PrepareSpreadArguments( | 627 V8_INLINE ZoneList<v8::internal::Expression*>* PrepareSpreadArguments( |
625 ZoneList<v8::internal::Expression*>* list); | 628 ZoneList<v8::internal::Expression*>* list); |
626 V8_INLINE void MaterializeUnspreadArgumentsLiterals(int count) {} | 629 V8_INLINE void MaterializeUnspreadArgumentsLiterals(int count) {} |
627 V8_INLINE Expression* SpreadCall(Expression* function, | 630 V8_INLINE Expression* SpreadCall(Expression* function, |
628 ZoneList<v8::internal::Expression*>* args, | 631 ZoneList<v8::internal::Expression*>* args, |
629 int pos); | 632 int pos); |
630 V8_INLINE Expression* SpreadCallNew(Expression* function, | 633 V8_INLINE Expression* SpreadCallNew(Expression* function, |
631 ZoneList<v8::internal::Expression*>* args, | 634 ZoneList<v8::internal::Expression*>* args, |
632 int pos); | 635 int pos); |
633 | 636 |
| 637 Expression* ExpressionListToExpression(ZoneList<Expression*>* args); |
| 638 |
634 // Rewrite all DestructuringAssignments in the current FunctionState. | 639 // Rewrite all DestructuringAssignments in the current FunctionState. |
635 V8_INLINE void RewriteDestructuringAssignments(); | 640 V8_INLINE void RewriteDestructuringAssignments(); |
636 | 641 |
637 V8_INLINE Expression* RewriteExponentiation(Expression* left, | 642 V8_INLINE Expression* RewriteExponentiation(Expression* left, |
638 Expression* right, int pos); | 643 Expression* right, int pos); |
639 V8_INLINE Expression* RewriteAssignExponentiation(Expression* left, | 644 V8_INLINE Expression* RewriteAssignExponentiation(Expression* left, |
640 Expression* right, int pos); | 645 Expression* right, int pos); |
641 | 646 |
| 647 V8_INLINE Expression* RewriteAwaitExpression(Expression* value, int pos); |
| 648 |
642 V8_INLINE void QueueDestructuringAssignmentForRewriting( | 649 V8_INLINE void QueueDestructuringAssignmentForRewriting( |
643 Expression* assignment); | 650 Expression* assignment); |
644 V8_INLINE void QueueNonPatternForRewriting(Expression* expr); | 651 V8_INLINE void QueueNonPatternForRewriting(Expression* expr); |
645 | 652 |
646 void SetFunctionNameFromPropertyName(ObjectLiteralProperty* property, | 653 void SetFunctionNameFromPropertyName(ObjectLiteralProperty* property, |
647 const AstRawString* name); | 654 const AstRawString* name); |
648 | 655 |
649 void SetFunctionNameFromIdentifierRef(Expression* value, | 656 void SetFunctionNameFromIdentifierRef(Expression* value, |
650 Expression* identifier); | 657 Expression* identifier); |
651 | 658 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 AllowLabelledFunctionStatement allow_function, | 766 AllowLabelledFunctionStatement allow_function, |
760 bool* ok); | 767 bool* ok); |
761 Statement* ParseSubStatement(ZoneList<const AstRawString*>* labels, | 768 Statement* ParseSubStatement(ZoneList<const AstRawString*>* labels, |
762 AllowLabelledFunctionStatement allow_function, | 769 AllowLabelledFunctionStatement allow_function, |
763 bool* ok); | 770 bool* ok); |
764 Statement* ParseStatementAsUnlabelled(ZoneList<const AstRawString*>* labels, | 771 Statement* ParseStatementAsUnlabelled(ZoneList<const AstRawString*>* labels, |
765 bool* ok); | 772 bool* ok); |
766 Statement* ParseFunctionDeclaration(bool* ok); | 773 Statement* ParseFunctionDeclaration(bool* ok); |
767 Statement* ParseHoistableDeclaration(ZoneList<const AstRawString*>* names, | 774 Statement* ParseHoistableDeclaration(ZoneList<const AstRawString*>* names, |
768 bool* ok); | 775 bool* ok); |
769 Statement* ParseHoistableDeclaration(int pos, bool is_generator, | 776 Statement* ParseHoistableDeclaration(int pos, ParseFunctionFlags flags, |
| 777 ZoneList<const AstRawString*>* names, |
| 778 bool* ok); |
| 779 Statement* ParseAsyncFunctionDeclaration(ZoneList<const AstRawString*>* names, |
| 780 bool* ok); |
| 781 Expression* ParseAsyncFunctionExpression(bool* ok); |
| 782 Statement* ParseFunctionDeclaration(int pos, bool is_generator, |
770 ZoneList<const AstRawString*>* names, | 783 ZoneList<const AstRawString*>* names, |
771 bool* ok); | 784 bool* ok); |
772 Statement* ParseClassDeclaration(ZoneList<const AstRawString*>* names, | 785 Statement* ParseClassDeclaration(ZoneList<const AstRawString*>* names, |
773 bool* ok); | 786 bool* ok); |
774 Statement* ParseNativeDeclaration(bool* ok); | 787 Statement* ParseNativeDeclaration(bool* ok); |
775 Block* ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok); | 788 Block* ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok); |
776 Block* ParseBlock(ZoneList<const AstRawString*>* labels, | 789 Block* ParseBlock(ZoneList<const AstRawString*>* labels, |
777 bool finalize_block_scope, bool* ok); | 790 bool finalize_block_scope, bool* ok); |
778 Block* ParseVariableStatement(VariableDeclarationContext var_context, | 791 Block* ParseVariableStatement(VariableDeclarationContext var_context, |
779 ZoneList<const AstRawString*>* names, | 792 ZoneList<const AstRawString*>* names, |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1242 if (!parameters.is_simple) { | 1255 if (!parameters.is_simple) { |
1243 auto* init_block = | 1256 auto* init_block = |
1244 parser_->BuildParameterInitializationBlock(parameters, ok); | 1257 parser_->BuildParameterInitializationBlock(parameters, ok); |
1245 if (!*ok) return; | 1258 if (!*ok) return; |
1246 if (init_block != nullptr) { | 1259 if (init_block != nullptr) { |
1247 body->Add(init_block, parser_->zone()); | 1260 body->Add(init_block, parser_->zone()); |
1248 } | 1261 } |
1249 } | 1262 } |
1250 } | 1263 } |
1251 | 1264 |
| 1265 Expression* ParserTraits::ParseAsyncFunctionExpression(bool* ok) { |
| 1266 return parser_->ParseAsyncFunctionExpression(ok); |
| 1267 } |
1252 | 1268 |
1253 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { | 1269 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { |
1254 return parser_->ParseDoExpression(ok); | 1270 return parser_->ParseDoExpression(ok); |
1255 } | 1271 } |
1256 | 1272 |
1257 | 1273 |
1258 } // namespace internal | 1274 } // namespace internal |
1259 } // namespace v8 | 1275 } // namespace v8 |
1260 | 1276 |
1261 #endif // V8_PARSING_PARSER_H_ | 1277 #endif // V8_PARSING_PARSER_H_ |
OLD | NEW |