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 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 | 659 |
660 V8_INLINE void QueueDestructuringAssignmentForRewriting( | 660 V8_INLINE void QueueDestructuringAssignmentForRewriting( |
661 Expression* assignment); | 661 Expression* assignment); |
662 V8_INLINE void QueueNonPatternForRewriting(Expression* expr, bool* ok); | 662 V8_INLINE void QueueNonPatternForRewriting(Expression* expr, bool* ok); |
663 | 663 |
664 void SetFunctionNameFromPropertyName(ObjectLiteralProperty* property, | 664 void SetFunctionNameFromPropertyName(ObjectLiteralProperty* property, |
665 const AstRawString* name); | 665 const AstRawString* name); |
666 | 666 |
667 void SetFunctionNameFromIdentifierRef(Expression* value, | 667 void SetFunctionNameFromIdentifierRef(Expression* value, |
668 Expression* identifier); | 668 Expression* identifier); |
| 669 void SetFunctionName(Expression* value, const AstRawString* name); |
669 | 670 |
670 // Rewrite expressions that are not used as patterns | 671 // Rewrite expressions that are not used as patterns |
671 V8_INLINE void RewriteNonPattern(Type::ExpressionClassifier* classifier, | 672 V8_INLINE void RewriteNonPattern(Type::ExpressionClassifier* classifier, |
672 bool* ok); | 673 bool* ok); |
673 | 674 |
674 V8_INLINE ZoneList<typename Type::ExpressionClassifier::Error>* | 675 V8_INLINE ZoneList<typename Type::ExpressionClassifier::Error>* |
675 GetReportedErrorList() const; | 676 GetReportedErrorList() const; |
676 V8_INLINE Zone* zone() const; | 677 V8_INLINE Zone* zone() const; |
677 | 678 |
678 V8_INLINE ZoneList<Expression*>* GetNonPatternList() const; | 679 V8_INLINE ZoneList<Expression*>* GetNonPatternList() const; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 | 759 |
759 // All ParseXXX functions take as the last argument an *ok parameter | 760 // All ParseXXX functions take as the last argument an *ok parameter |
760 // which is set to false if parsing failed; it is unchanged otherwise. | 761 // which is set to false if parsing failed; it is unchanged otherwise. |
761 // By making the 'exception handling' explicit, we are forced to check | 762 // By making the 'exception handling' explicit, we are forced to check |
762 // for failure at the call sites. | 763 // for failure at the call sites. |
763 void* ParseStatementList(ZoneList<Statement*>* body, int end_token, bool* ok); | 764 void* ParseStatementList(ZoneList<Statement*>* body, int end_token, bool* ok); |
764 Statement* ParseStatementListItem(bool* ok); | 765 Statement* ParseStatementListItem(bool* ok); |
765 void* ParseModuleItemList(ZoneList<Statement*>* body, bool* ok); | 766 void* ParseModuleItemList(ZoneList<Statement*>* body, bool* ok); |
766 Statement* ParseModuleItem(bool* ok); | 767 Statement* ParseModuleItem(bool* ok); |
767 const AstRawString* ParseModuleSpecifier(bool* ok); | 768 const AstRawString* ParseModuleSpecifier(bool* ok); |
768 Statement* ParseImportDeclaration(bool* ok); | 769 void* ParseImportDeclaration(bool* ok); |
769 Statement* ParseExportDeclaration(bool* ok); | 770 Statement* ParseExportDeclaration(bool* ok); |
770 Statement* ParseExportDefault(bool* ok); | 771 Statement* ParseExportDefault(bool* ok); |
771 void* ParseExportClause(ZoneList<const AstRawString*>* export_names, | 772 void* ParseExportClause(ZoneList<const AstRawString*>* export_names, |
772 ZoneList<Scanner::Location>* export_locations, | 773 ZoneList<Scanner::Location>* export_locations, |
773 ZoneList<const AstRawString*>* local_names, | 774 ZoneList<const AstRawString*>* local_names, |
774 Scanner::Location* reserved_loc, bool* ok); | 775 Scanner::Location* reserved_loc, bool* ok); |
775 ZoneList<ImportDeclaration*>* ParseNamedImports(int pos, bool* ok); | 776 struct NamedImport : public ZoneObject { |
| 777 const AstRawString* import_name; |
| 778 const AstRawString* local_name; |
| 779 const Scanner::Location location; |
| 780 NamedImport(const AstRawString* import_name, const AstRawString* local_name, |
| 781 Scanner::Location location) |
| 782 : import_name(import_name), |
| 783 local_name(local_name), |
| 784 location(location) {} |
| 785 }; |
| 786 ZoneList<const NamedImport*>* ParseNamedImports(int pos, bool* ok); |
776 Statement* ParseStatement(ZoneList<const AstRawString*>* labels, | 787 Statement* ParseStatement(ZoneList<const AstRawString*>* labels, |
777 AllowLabelledFunctionStatement allow_function, | 788 AllowLabelledFunctionStatement allow_function, |
778 bool* ok); | 789 bool* ok); |
779 Statement* ParseSubStatement(ZoneList<const AstRawString*>* labels, | 790 Statement* ParseSubStatement(ZoneList<const AstRawString*>* labels, |
780 AllowLabelledFunctionStatement allow_function, | 791 AllowLabelledFunctionStatement allow_function, |
781 bool* ok); | 792 bool* ok); |
782 Statement* ParseStatementAsUnlabelled(ZoneList<const AstRawString*>* labels, | 793 Statement* ParseStatementAsUnlabelled(ZoneList<const AstRawString*>* labels, |
783 bool* ok); | 794 bool* ok); |
784 Statement* ParseFunctionDeclaration(bool* ok); | 795 Statement* ParseFunctionDeclaration(bool* ok); |
785 Statement* ParseHoistableDeclaration(ZoneList<const AstRawString*>* names, | 796 Statement* ParseHoistableDeclaration(ZoneList<const AstRawString*>* names, |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 // Implement sloppy block-scoped functions, ES2015 Annex B 3.3 | 1030 // Implement sloppy block-scoped functions, ES2015 Annex B 3.3 |
1020 void InsertSloppyBlockFunctionVarBindings(Scope* scope, | 1031 void InsertSloppyBlockFunctionVarBindings(Scope* scope, |
1021 Scope* complex_params_scope, | 1032 Scope* complex_params_scope, |
1022 bool* ok); | 1033 bool* ok); |
1023 | 1034 |
1024 // Parser support | 1035 // Parser support |
1025 VariableProxy* NewUnresolved(const AstRawString* name, VariableMode mode); | 1036 VariableProxy* NewUnresolved(const AstRawString* name, VariableMode mode); |
1026 Variable* Declare(Declaration* declaration, | 1037 Variable* Declare(Declaration* declaration, |
1027 DeclarationDescriptor::Kind declaration_kind, bool resolve, | 1038 DeclarationDescriptor::Kind declaration_kind, bool resolve, |
1028 bool* ok, Scope* declaration_scope = nullptr); | 1039 bool* ok, Scope* declaration_scope = nullptr); |
| 1040 void* DeclareImport(const AstRawString* local_name, int pos, bool* ok); |
1029 | 1041 |
1030 bool TargetStackContainsLabel(const AstRawString* label); | 1042 bool TargetStackContainsLabel(const AstRawString* label); |
1031 BreakableStatement* LookupBreakTarget(const AstRawString* label, bool* ok); | 1043 BreakableStatement* LookupBreakTarget(const AstRawString* label, bool* ok); |
1032 IterationStatement* LookupContinueTarget(const AstRawString* label, bool* ok); | 1044 IterationStatement* LookupContinueTarget(const AstRawString* label, bool* ok); |
1033 | 1045 |
1034 Statement* BuildAssertIsCoercible(Variable* var); | 1046 Statement* BuildAssertIsCoercible(Variable* var); |
1035 | 1047 |
1036 // Factory methods. | 1048 // Factory methods. |
1037 FunctionLiteral* DefaultConstructor(const AstRawString* name, bool call_super, | 1049 FunctionLiteral* DefaultConstructor(const AstRawString* name, bool call_super, |
1038 Scope* scope, int pos, int end_pos, | 1050 Scope* scope, int pos, int end_pos, |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1299 | 1311 |
1300 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { | 1312 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { |
1301 return parser_->ParseDoExpression(ok); | 1313 return parser_->ParseDoExpression(ok); |
1302 } | 1314 } |
1303 | 1315 |
1304 | 1316 |
1305 } // namespace internal | 1317 } // namespace internal |
1306 } // namespace v8 | 1318 } // namespace v8 |
1307 | 1319 |
1308 #endif // V8_PARSING_PARSER_H_ | 1320 #endif // V8_PARSING_PARSER_H_ |
OLD | NEW |