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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 Type::ExpressionClassifier* classifier); | 543 Type::ExpressionClassifier* classifier); |
543 void ParseArrowFunctionFormalParameters(ParserFormalParameters* parameters, | 544 void ParseArrowFunctionFormalParameters(ParserFormalParameters* parameters, |
544 Expression* params, | 545 Expression* params, |
545 const Scanner::Location& params_loc, | 546 const Scanner::Location& params_loc, |
546 bool* ok); | 547 bool* ok); |
547 void ParseArrowFunctionFormalParameterList( | 548 void ParseArrowFunctionFormalParameterList( |
548 ParserFormalParameters* parameters, Expression* params, | 549 ParserFormalParameters* parameters, Expression* params, |
549 const Scanner::Location& params_loc, | 550 const Scanner::Location& params_loc, |
550 Scanner::Location* duplicate_loc, bool* ok); | 551 Scanner::Location* duplicate_loc, bool* ok); |
551 | 552 |
| 553 V8_INLINE Expression* ParseAsyncFunctionExpression(bool* ok); |
| 554 |
552 V8_INLINE DoExpression* ParseDoExpression(bool* ok); | 555 V8_INLINE DoExpression* ParseDoExpression(bool* ok); |
553 | 556 |
554 void ReindexLiterals(const ParserFormalParameters& parameters); | 557 void ReindexLiterals(const ParserFormalParameters& parameters); |
555 | 558 |
556 // Temporary glue; these functions will move to ParserBase. | 559 // Temporary glue; these functions will move to ParserBase. |
557 Expression* ParseV8Intrinsic(bool* ok); | 560 Expression* ParseV8Intrinsic(bool* ok); |
558 FunctionLiteral* ParseFunctionLiteral( | 561 FunctionLiteral* ParseFunctionLiteral( |
559 const AstRawString* name, Scanner::Location function_name_location, | 562 const AstRawString* name, Scanner::Location function_name_location, |
560 FunctionNameValidity function_name_validity, FunctionKind kind, | 563 FunctionNameValidity function_name_validity, FunctionKind kind, |
561 int function_token_position, FunctionLiteral::FunctionType type, | 564 int function_token_position, FunctionLiteral::FunctionType type, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 V8_INLINE ZoneList<v8::internal::Expression*>* PrepareSpreadArguments( | 624 V8_INLINE ZoneList<v8::internal::Expression*>* PrepareSpreadArguments( |
622 ZoneList<v8::internal::Expression*>* list); | 625 ZoneList<v8::internal::Expression*>* list); |
623 V8_INLINE void MaterializeUnspreadArgumentsLiterals(int count) {} | 626 V8_INLINE void MaterializeUnspreadArgumentsLiterals(int count) {} |
624 V8_INLINE Expression* SpreadCall(Expression* function, | 627 V8_INLINE Expression* SpreadCall(Expression* function, |
625 ZoneList<v8::internal::Expression*>* args, | 628 ZoneList<v8::internal::Expression*>* args, |
626 int pos); | 629 int pos); |
627 V8_INLINE Expression* SpreadCallNew(Expression* function, | 630 V8_INLINE Expression* SpreadCallNew(Expression* function, |
628 ZoneList<v8::internal::Expression*>* args, | 631 ZoneList<v8::internal::Expression*>* args, |
629 int pos); | 632 int pos); |
630 | 633 |
| 634 Expression* ExpressionListToExpression(ZoneList<Expression*>* args); |
| 635 |
631 // Rewrite all DestructuringAssignments in the current FunctionState. | 636 // Rewrite all DestructuringAssignments in the current FunctionState. |
632 V8_INLINE void RewriteDestructuringAssignments(); | 637 V8_INLINE void RewriteDestructuringAssignments(); |
633 | 638 |
634 V8_INLINE Expression* RewriteExponentiation(Expression* left, | 639 V8_INLINE Expression* RewriteExponentiation(Expression* left, |
635 Expression* right, int pos); | 640 Expression* right, int pos); |
636 V8_INLINE Expression* RewriteAssignExponentiation(Expression* left, | 641 V8_INLINE Expression* RewriteAssignExponentiation(Expression* left, |
637 Expression* right, int pos); | 642 Expression* right, int pos); |
638 | 643 |
| 644 V8_INLINE Expression* RewriteAwaitExpression(Expression* value, int pos); |
| 645 |
639 V8_INLINE void QueueDestructuringAssignmentForRewriting( | 646 V8_INLINE void QueueDestructuringAssignmentForRewriting( |
640 Expression* assignment); | 647 Expression* assignment); |
641 V8_INLINE void QueueNonPatternForRewriting(Expression* expr); | 648 V8_INLINE void QueueNonPatternForRewriting(Expression* expr); |
642 | 649 |
643 void SetFunctionNameFromPropertyName(ObjectLiteralProperty* property, | 650 void SetFunctionNameFromPropertyName(ObjectLiteralProperty* property, |
644 const AstRawString* name); | 651 const AstRawString* name); |
645 | 652 |
646 void SetFunctionNameFromIdentifierRef(Expression* value, | 653 void SetFunctionNameFromIdentifierRef(Expression* value, |
647 Expression* identifier); | 654 Expression* identifier); |
648 | 655 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 Statement* ParseStatement(ZoneList<const AstRawString*>* labels, | 762 Statement* ParseStatement(ZoneList<const AstRawString*>* labels, |
756 AllowLabelledFunctionStatement allow_function, | 763 AllowLabelledFunctionStatement allow_function, |
757 bool* ok); | 764 bool* ok); |
758 Statement* ParseSubStatement(ZoneList<const AstRawString*>* labels, | 765 Statement* ParseSubStatement(ZoneList<const AstRawString*>* labels, |
759 AllowLabelledFunctionStatement allow_function, | 766 AllowLabelledFunctionStatement allow_function, |
760 bool* ok); | 767 bool* ok); |
761 Statement* ParseStatementAsUnlabelled(ZoneList<const AstRawString*>* labels, | 768 Statement* ParseStatementAsUnlabelled(ZoneList<const AstRawString*>* labels, |
762 bool* ok); | 769 bool* ok); |
763 Statement* ParseFunctionDeclaration(ZoneList<const AstRawString*>* names, | 770 Statement* ParseFunctionDeclaration(ZoneList<const AstRawString*>* names, |
764 bool* ok); | 771 bool* ok); |
| 772 Statement* ParseAsyncFunctionDeclaration(ZoneList<const AstRawString*>* names, |
| 773 bool* ok); |
| 774 Expression* ParseAsyncFunctionExpression(bool* ok); |
| 775 Statement* ParseFunctionDeclarationInternal( |
| 776 int pos, ParseFunctionFlags flags, ZoneList<const AstRawString*>* names, |
| 777 bool* ok); |
765 Statement* ParseFunctionDeclaration(int pos, bool is_generator, | 778 Statement* ParseFunctionDeclaration(int pos, bool is_generator, |
766 ZoneList<const AstRawString*>* names, | 779 ZoneList<const AstRawString*>* names, |
767 bool* ok); | 780 bool* ok); |
768 Statement* ParseClassDeclaration(ZoneList<const AstRawString*>* names, | 781 Statement* ParseClassDeclaration(ZoneList<const AstRawString*>* names, |
769 bool* ok); | 782 bool* ok); |
770 Statement* ParseNativeDeclaration(bool* ok); | 783 Statement* ParseNativeDeclaration(bool* ok); |
771 Block* ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok); | 784 Block* ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok); |
772 Block* ParseBlock(ZoneList<const AstRawString*>* labels, | 785 Block* ParseBlock(ZoneList<const AstRawString*>* labels, |
773 bool finalize_block_scope, bool* ok); | 786 bool finalize_block_scope, bool* ok); |
774 Block* ParseVariableStatement(VariableDeclarationContext var_context, | 787 Block* ParseVariableStatement(VariableDeclarationContext var_context, |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 if (!parameters.is_simple) { | 1250 if (!parameters.is_simple) { |
1238 auto* init_block = | 1251 auto* init_block = |
1239 parser_->BuildParameterInitializationBlock(parameters, ok); | 1252 parser_->BuildParameterInitializationBlock(parameters, ok); |
1240 if (!*ok) return; | 1253 if (!*ok) return; |
1241 if (init_block != nullptr) { | 1254 if (init_block != nullptr) { |
1242 body->Add(init_block, parser_->zone()); | 1255 body->Add(init_block, parser_->zone()); |
1243 } | 1256 } |
1244 } | 1257 } |
1245 } | 1258 } |
1246 | 1259 |
| 1260 Expression* ParserTraits::ParseAsyncFunctionExpression(bool* ok) { |
| 1261 return parser_->ParseAsyncFunctionExpression(ok); |
| 1262 } |
1247 | 1263 |
1248 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { | 1264 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { |
1249 return parser_->ParseDoExpression(ok); | 1265 return parser_->ParseDoExpression(ok); |
1250 } | 1266 } |
1251 | 1267 |
1252 | 1268 |
1253 } // namespace internal | 1269 } // namespace internal |
1254 } // namespace v8 | 1270 } // namespace v8 |
1255 | 1271 |
1256 #endif // V8_PARSING_PARSER_H_ | 1272 #endif // V8_PARSING_PARSER_H_ |
OLD | NEW |