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_PARSER_H_ | 5 #ifndef V8_PARSER_H_ |
6 #define V8_PARSER_H_ | 6 #define V8_PARSER_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/ast.h" | 9 #include "src/ast.h" |
10 #include "src/compiler.h" // TODO(titzer): remove this include dependency | 10 #include "src/compiler.h" // TODO(titzer): remove this include dependency |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 Scanner::Location* dupe_loc, | 749 Scanner::Location* dupe_loc, |
750 bool* ok); | 750 bool* ok); |
751 | 751 |
752 // Temporary glue; these functions will move to ParserBase. | 752 // Temporary glue; these functions will move to ParserBase. |
753 Expression* ParseV8Intrinsic(bool* ok); | 753 Expression* ParseV8Intrinsic(bool* ok); |
754 FunctionLiteral* ParseFunctionLiteral( | 754 FunctionLiteral* ParseFunctionLiteral( |
755 const AstRawString* name, Scanner::Location function_name_location, | 755 const AstRawString* name, Scanner::Location function_name_location, |
756 bool name_is_strict_reserved, FunctionKind kind, | 756 bool name_is_strict_reserved, FunctionKind kind, |
757 int function_token_position, FunctionLiteral::FunctionType type, | 757 int function_token_position, FunctionLiteral::FunctionType type, |
758 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); | 758 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); |
759 V8_INLINE void SkipLazyFunctionBody(const AstRawString* name, | 759 V8_INLINE void SkipLazyFunctionBody( |
760 int* materialized_literal_count, | 760 const AstRawString* name, int* materialized_literal_count, |
761 int* expected_property_count, bool* ok); | 761 int* expected_property_count, bool* ok, |
| 762 Scanner::BookmarkScope* bookmark = nullptr); |
762 V8_INLINE ZoneList<Statement*>* ParseEagerFunctionBody( | 763 V8_INLINE ZoneList<Statement*>* ParseEagerFunctionBody( |
763 const AstRawString* name, int pos, Variable* fvar, | 764 const AstRawString* name, int pos, Variable* fvar, |
764 Token::Value fvar_init_op, FunctionKind kind, bool* ok); | 765 Token::Value fvar_init_op, FunctionKind kind, bool* ok); |
765 | 766 |
766 ClassLiteral* ParseClassLiteral(const AstRawString* name, | 767 ClassLiteral* ParseClassLiteral(const AstRawString* name, |
767 Scanner::Location class_name_location, | 768 Scanner::Location class_name_location, |
768 bool name_is_strict_reserved, int pos, | 769 bool name_is_strict_reserved, int pos, |
769 bool* ok); | 770 bool* ok); |
770 | 771 |
771 V8_INLINE void CheckConflictingVarDeclarations(v8::internal::Scope* scope, | 772 V8_INLINE void CheckConflictingVarDeclarations(v8::internal::Scope* scope, |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1001 IterationStatement* LookupContinueTarget(const AstRawString* label, bool* ok); | 1002 IterationStatement* LookupContinueTarget(const AstRawString* label, bool* ok); |
1002 | 1003 |
1003 void AddAssertIsConstruct(ZoneList<Statement*>* body, int pos); | 1004 void AddAssertIsConstruct(ZoneList<Statement*>* body, int pos); |
1004 | 1005 |
1005 // Factory methods. | 1006 // Factory methods. |
1006 FunctionLiteral* DefaultConstructor(bool call_super, Scope* scope, int pos, | 1007 FunctionLiteral* DefaultConstructor(bool call_super, Scope* scope, int pos, |
1007 int end_pos); | 1008 int end_pos); |
1008 | 1009 |
1009 // Skip over a lazy function, either using cached data if we have it, or | 1010 // Skip over a lazy function, either using cached data if we have it, or |
1010 // by parsing the function with PreParser. Consumes the ending }. | 1011 // by parsing the function with PreParser. Consumes the ending }. |
| 1012 // |
| 1013 // If bookmark is set, the (pre-)parser may decide to abort skipping |
| 1014 // in order to force the function to be eagerly parsed, after all. |
| 1015 // In this case, it'll reset the scanner using the bookmark. |
1011 void SkipLazyFunctionBody(const AstRawString* function_name, | 1016 void SkipLazyFunctionBody(const AstRawString* function_name, |
1012 int* materialized_literal_count, | 1017 int* materialized_literal_count, |
1013 int* expected_property_count, | 1018 int* expected_property_count, bool* ok, |
1014 bool* ok); | 1019 Scanner::BookmarkScope* bookmark = nullptr); |
1015 | 1020 |
1016 PreParser::PreParseResult ParseLazyFunctionBodyWithPreParser( | 1021 PreParser::PreParseResult ParseLazyFunctionBodyWithPreParser( |
1017 SingletonLogger* logger); | 1022 SingletonLogger* logger, Scanner::BookmarkScope* bookmark = nullptr); |
1018 | 1023 |
1019 // Consumes the ending }. | 1024 // Consumes the ending }. |
1020 ZoneList<Statement*>* ParseEagerFunctionBody( | 1025 ZoneList<Statement*>* ParseEagerFunctionBody( |
1021 const AstRawString* function_name, int pos, Variable* fvar, | 1026 const AstRawString* function_name, int pos, Variable* fvar, |
1022 Token::Value fvar_init_op, FunctionKind kind, bool* ok); | 1027 Token::Value fvar_init_op, FunctionKind kind, bool* ok); |
1023 | 1028 |
1024 void ThrowPendingError(Isolate* isolate, Handle<Script> script); | 1029 void ThrowPendingError(Isolate* isolate, Handle<Script> script); |
1025 | 1030 |
1026 TemplateLiteralState OpenTemplateLiteral(int pos); | 1031 TemplateLiteralState OpenTemplateLiteral(int pos); |
1027 void AddTemplateSpan(TemplateLiteralState* state, bool tail); | 1032 void AddTemplateSpan(TemplateLiteralState* state, bool tail); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1071 } | 1076 } |
1072 | 1077 |
1073 | 1078 |
1074 const AstRawString* ParserTraits::EmptyIdentifierString() { | 1079 const AstRawString* ParserTraits::EmptyIdentifierString() { |
1075 return parser_->ast_value_factory()->empty_string(); | 1080 return parser_->ast_value_factory()->empty_string(); |
1076 } | 1081 } |
1077 | 1082 |
1078 | 1083 |
1079 void ParserTraits::SkipLazyFunctionBody(const AstRawString* function_name, | 1084 void ParserTraits::SkipLazyFunctionBody(const AstRawString* function_name, |
1080 int* materialized_literal_count, | 1085 int* materialized_literal_count, |
1081 int* expected_property_count, | 1086 int* expected_property_count, bool* ok, |
1082 bool* ok) { | 1087 Scanner::BookmarkScope* bookmark) { |
1083 return parser_->SkipLazyFunctionBody( | 1088 return parser_->SkipLazyFunctionBody(function_name, |
1084 function_name, materialized_literal_count, expected_property_count, ok); | 1089 materialized_literal_count, |
| 1090 expected_property_count, ok, bookmark); |
1085 } | 1091 } |
1086 | 1092 |
1087 | 1093 |
1088 ZoneList<Statement*>* ParserTraits::ParseEagerFunctionBody( | 1094 ZoneList<Statement*>* ParserTraits::ParseEagerFunctionBody( |
1089 const AstRawString* name, int pos, Variable* fvar, | 1095 const AstRawString* name, int pos, Variable* fvar, |
1090 Token::Value fvar_init_op, FunctionKind kind, bool* ok) { | 1096 Token::Value fvar_init_op, FunctionKind kind, bool* ok) { |
1091 return parser_->ParseEagerFunctionBody(name, pos, fvar, fvar_init_op, kind, | 1097 return parser_->ParseEagerFunctionBody(name, pos, fvar, fvar_init_op, kind, |
1092 ok); | 1098 ok); |
1093 } | 1099 } |
1094 | 1100 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1162 } | 1168 } |
1163 | 1169 |
1164 | 1170 |
1165 Expression* ParserTraits::SpreadCallNew( | 1171 Expression* ParserTraits::SpreadCallNew( |
1166 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { | 1172 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { |
1167 return parser_->SpreadCallNew(function, args, pos); | 1173 return parser_->SpreadCallNew(function, args, pos); |
1168 } | 1174 } |
1169 } } // namespace v8::internal | 1175 } } // namespace v8::internal |
1170 | 1176 |
1171 #endif // V8_PARSER_H_ | 1177 #endif // V8_PARSER_H_ |
OLD | NEW |