| 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 Scope* scope, const ParserFormalParameters::Parameter& parameter, | 548 Scope* scope, const ParserFormalParameters::Parameter& parameter, |
| 548 Type::ExpressionClassifier* classifier); | 549 Type::ExpressionClassifier* classifier); |
| 549 void ParseArrowFunctionFormalParameters(ParserFormalParameters* parameters, | 550 void ParseArrowFunctionFormalParameters(ParserFormalParameters* parameters, |
| 550 Expression* params, int end_pos, | 551 Expression* params, int end_pos, |
| 551 bool* ok); | 552 bool* ok); |
| 552 void ParseArrowFunctionFormalParameterList( | 553 void ParseArrowFunctionFormalParameterList( |
| 553 ParserFormalParameters* parameters, Expression* params, | 554 ParserFormalParameters* parameters, Expression* params, |
| 554 const Scanner::Location& params_loc, | 555 const Scanner::Location& params_loc, |
| 555 Scanner::Location* duplicate_loc, bool* ok); | 556 Scanner::Location* duplicate_loc, bool* ok); |
| 556 | 557 |
| 558 V8_INLINE Expression* ParseAsyncFunctionExpression(bool* ok); |
| 559 |
| 557 V8_INLINE DoExpression* ParseDoExpression(bool* ok); | 560 V8_INLINE DoExpression* ParseDoExpression(bool* ok); |
| 558 | 561 |
| 559 void ReindexLiterals(const ParserFormalParameters& parameters); | 562 void ReindexLiterals(const ParserFormalParameters& parameters); |
| 560 | 563 |
| 561 // Temporary glue; these functions will move to ParserBase. | 564 // Temporary glue; these functions will move to ParserBase. |
| 562 Expression* ParseV8Intrinsic(bool* ok); | 565 Expression* ParseV8Intrinsic(bool* ok); |
| 563 FunctionLiteral* ParseFunctionLiteral( | 566 FunctionLiteral* ParseFunctionLiteral( |
| 564 const AstRawString* name, Scanner::Location function_name_location, | 567 const AstRawString* name, Scanner::Location function_name_location, |
| 565 FunctionNameValidity function_name_validity, FunctionKind kind, | 568 FunctionNameValidity function_name_validity, FunctionKind kind, |
| 566 int function_token_position, FunctionLiteral::FunctionType type, | 569 int function_token_position, FunctionLiteral::FunctionType type, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 V8_INLINE ZoneList<v8::internal::Expression*>* PrepareSpreadArguments( | 633 V8_INLINE ZoneList<v8::internal::Expression*>* PrepareSpreadArguments( |
| 631 ZoneList<v8::internal::Expression*>* list); | 634 ZoneList<v8::internal::Expression*>* list); |
| 632 V8_INLINE void MaterializeUnspreadArgumentsLiterals(int count) {} | 635 V8_INLINE void MaterializeUnspreadArgumentsLiterals(int count) {} |
| 633 V8_INLINE Expression* SpreadCall(Expression* function, | 636 V8_INLINE Expression* SpreadCall(Expression* function, |
| 634 ZoneList<v8::internal::Expression*>* args, | 637 ZoneList<v8::internal::Expression*>* args, |
| 635 int pos); | 638 int pos); |
| 636 V8_INLINE Expression* SpreadCallNew(Expression* function, | 639 V8_INLINE Expression* SpreadCallNew(Expression* function, |
| 637 ZoneList<v8::internal::Expression*>* args, | 640 ZoneList<v8::internal::Expression*>* args, |
| 638 int pos); | 641 int pos); |
| 639 | 642 |
| 643 Expression* ExpressionListToExpression(ZoneList<Expression*>* args); |
| 644 |
| 640 // Rewrite all DestructuringAssignments in the current FunctionState. | 645 // Rewrite all DestructuringAssignments in the current FunctionState. |
| 641 V8_INLINE void RewriteDestructuringAssignments(); | 646 V8_INLINE void RewriteDestructuringAssignments(); |
| 642 | 647 |
| 643 V8_INLINE Expression* RewriteExponentiation(Expression* left, | 648 V8_INLINE Expression* RewriteExponentiation(Expression* left, |
| 644 Expression* right, int pos); | 649 Expression* right, int pos); |
| 645 V8_INLINE Expression* RewriteAssignExponentiation(Expression* left, | 650 V8_INLINE Expression* RewriteAssignExponentiation(Expression* left, |
| 646 Expression* right, int pos); | 651 Expression* right, int pos); |
| 647 | 652 |
| 653 V8_INLINE Expression* RewriteAwaitExpression(Expression* value, int pos); |
| 654 |
| 648 V8_INLINE void QueueDestructuringAssignmentForRewriting( | 655 V8_INLINE void QueueDestructuringAssignmentForRewriting( |
| 649 Expression* assignment); | 656 Expression* assignment); |
| 650 V8_INLINE void QueueNonPatternForRewriting(Expression* expr); | 657 V8_INLINE void QueueNonPatternForRewriting(Expression* expr); |
| 651 | 658 |
| 652 void SetFunctionNameFromPropertyName(ObjectLiteralProperty* property, | 659 void SetFunctionNameFromPropertyName(ObjectLiteralProperty* property, |
| 653 const AstRawString* name); | 660 const AstRawString* name); |
| 654 | 661 |
| 655 void SetFunctionNameFromIdentifierRef(Expression* value, | 662 void SetFunctionNameFromIdentifierRef(Expression* value, |
| 656 Expression* identifier); | 663 Expression* identifier); |
| 657 | 664 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 AllowLabelledFunctionStatement allow_function, | 772 AllowLabelledFunctionStatement allow_function, |
| 766 bool* ok); | 773 bool* ok); |
| 767 Statement* ParseSubStatement(ZoneList<const AstRawString*>* labels, | 774 Statement* ParseSubStatement(ZoneList<const AstRawString*>* labels, |
| 768 AllowLabelledFunctionStatement allow_function, | 775 AllowLabelledFunctionStatement allow_function, |
| 769 bool* ok); | 776 bool* ok); |
| 770 Statement* ParseStatementAsUnlabelled(ZoneList<const AstRawString*>* labels, | 777 Statement* ParseStatementAsUnlabelled(ZoneList<const AstRawString*>* labels, |
| 771 bool* ok); | 778 bool* ok); |
| 772 Statement* ParseFunctionDeclaration(bool* ok); | 779 Statement* ParseFunctionDeclaration(bool* ok); |
| 773 Statement* ParseHoistableDeclaration(ZoneList<const AstRawString*>* names, | 780 Statement* ParseHoistableDeclaration(ZoneList<const AstRawString*>* names, |
| 774 bool* ok); | 781 bool* ok); |
| 775 Statement* ParseHoistableDeclaration(int pos, bool is_generator, | 782 Statement* ParseHoistableDeclaration(int pos, ParseFunctionFlags flags, |
| 783 ZoneList<const AstRawString*>* names, |
| 784 bool* ok); |
| 785 Statement* ParseAsyncFunctionDeclaration(ZoneList<const AstRawString*>* names, |
| 786 bool* ok); |
| 787 Expression* ParseAsyncFunctionExpression(bool* ok); |
| 788 Statement* ParseFunctionDeclaration(int pos, bool is_generator, |
| 776 ZoneList<const AstRawString*>* names, | 789 ZoneList<const AstRawString*>* names, |
| 777 bool* ok); | 790 bool* ok); |
| 778 Statement* ParseClassDeclaration(ZoneList<const AstRawString*>* names, | 791 Statement* ParseClassDeclaration(ZoneList<const AstRawString*>* names, |
| 779 bool* ok); | 792 bool* ok); |
| 780 Statement* ParseNativeDeclaration(bool* ok); | 793 Statement* ParseNativeDeclaration(bool* ok); |
| 781 Block* ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok); | 794 Block* ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok); |
| 782 Block* ParseBlock(ZoneList<const AstRawString*>* labels, | 795 Block* ParseBlock(ZoneList<const AstRawString*>* labels, |
| 783 bool finalize_block_scope, bool* ok); | 796 bool finalize_block_scope, bool* ok); |
| 784 Block* ParseVariableStatement(VariableDeclarationContext var_context, | 797 Block* ParseVariableStatement(VariableDeclarationContext var_context, |
| 785 ZoneList<const AstRawString*>* names, | 798 ZoneList<const AstRawString*>* names, |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 if (!parameters.is_simple) { | 1261 if (!parameters.is_simple) { |
| 1249 auto* init_block = | 1262 auto* init_block = |
| 1250 parser_->BuildParameterInitializationBlock(parameters, ok); | 1263 parser_->BuildParameterInitializationBlock(parameters, ok); |
| 1251 if (!*ok) return; | 1264 if (!*ok) return; |
| 1252 if (init_block != nullptr) { | 1265 if (init_block != nullptr) { |
| 1253 body->Add(init_block, parser_->zone()); | 1266 body->Add(init_block, parser_->zone()); |
| 1254 } | 1267 } |
| 1255 } | 1268 } |
| 1256 } | 1269 } |
| 1257 | 1270 |
| 1271 Expression* ParserTraits::ParseAsyncFunctionExpression(bool* ok) { |
| 1272 return parser_->ParseAsyncFunctionExpression(ok); |
| 1273 } |
| 1258 | 1274 |
| 1259 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { | 1275 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { |
| 1260 return parser_->ParseDoExpression(ok); | 1276 return parser_->ParseDoExpression(ok); |
| 1261 } | 1277 } |
| 1262 | 1278 |
| 1263 | 1279 |
| 1264 } // namespace internal | 1280 } // namespace internal |
| 1265 } // namespace v8 | 1281 } // namespace v8 |
| 1266 | 1282 |
| 1267 #endif // V8_PARSING_PARSER_H_ | 1283 #endif // V8_PARSING_PARSER_H_ |
| OLD | NEW |