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 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 Scope* scope, Expression* params, const Scanner::Location& params_loc, | 766 Scope* scope, Expression* params, const Scanner::Location& params_loc, |
767 FormalParameterErrorLocations* error_locs, bool* is_rest, bool* ok); | 767 FormalParameterErrorLocations* error_locs, bool* is_rest, bool* ok); |
768 | 768 |
769 // Temporary glue; these functions will move to ParserBase. | 769 // Temporary glue; these functions will move to ParserBase. |
770 Expression* ParseV8Intrinsic(bool* ok); | 770 Expression* ParseV8Intrinsic(bool* ok); |
771 FunctionLiteral* ParseFunctionLiteral( | 771 FunctionLiteral* ParseFunctionLiteral( |
772 const AstRawString* name, Scanner::Location function_name_location, | 772 const AstRawString* name, Scanner::Location function_name_location, |
773 bool name_is_strict_reserved, FunctionKind kind, | 773 bool name_is_strict_reserved, FunctionKind kind, |
774 int function_token_position, FunctionLiteral::FunctionType type, | 774 int function_token_position, FunctionLiteral::FunctionType type, |
775 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); | 775 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); |
776 V8_INLINE void SkipLazyFunctionBody(int* materialized_literal_count, | 776 V8_INLINE void SkipLazyFunctionBody( |
777 int* expected_property_count, bool* ok); | 777 int* materialized_literal_count, int* expected_property_count, bool* ok, |
| 778 Scanner::BookmarkScope* bookmark = nullptr); |
778 V8_INLINE ZoneList<Statement*>* ParseEagerFunctionBody( | 779 V8_INLINE ZoneList<Statement*>* ParseEagerFunctionBody( |
779 const AstRawString* name, int pos, Variable* fvar, | 780 const AstRawString* name, int pos, Variable* fvar, |
780 Token::Value fvar_init_op, FunctionKind kind, bool* ok); | 781 Token::Value fvar_init_op, FunctionKind kind, bool* ok); |
781 | 782 |
782 ClassLiteral* ParseClassLiteral(const AstRawString* name, | 783 ClassLiteral* ParseClassLiteral(const AstRawString* name, |
783 Scanner::Location class_name_location, | 784 Scanner::Location class_name_location, |
784 bool name_is_strict_reserved, int pos, | 785 bool name_is_strict_reserved, int pos, |
785 bool* ok); | 786 bool* ok); |
786 | 787 |
787 V8_INLINE void CheckConflictingVarDeclarations(v8::internal::Scope* scope, | 788 V8_INLINE void CheckConflictingVarDeclarations(v8::internal::Scope* scope, |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 IterationStatement* LookupContinueTarget(const AstRawString* label, bool* ok); | 1017 IterationStatement* LookupContinueTarget(const AstRawString* label, bool* ok); |
1017 | 1018 |
1018 void AddAssertIsConstruct(ZoneList<Statement*>* body, int pos); | 1019 void AddAssertIsConstruct(ZoneList<Statement*>* body, int pos); |
1019 | 1020 |
1020 // Factory methods. | 1021 // Factory methods. |
1021 FunctionLiteral* DefaultConstructor(bool call_super, Scope* scope, int pos, | 1022 FunctionLiteral* DefaultConstructor(bool call_super, Scope* scope, int pos, |
1022 int end_pos); | 1023 int end_pos); |
1023 | 1024 |
1024 // Skip over a lazy function, either using cached data if we have it, or | 1025 // Skip over a lazy function, either using cached data if we have it, or |
1025 // by parsing the function with PreParser. Consumes the ending }. | 1026 // by parsing the function with PreParser. Consumes the ending }. |
| 1027 // |
| 1028 // If bookmark is set, the (pre-)parser may decide to abort skipping |
| 1029 // in order to force the function to be eagerly parsed, after all. |
| 1030 // In this case, it'll reset the scanner using the bookmark. |
1026 void SkipLazyFunctionBody(int* materialized_literal_count, | 1031 void SkipLazyFunctionBody(int* materialized_literal_count, |
1027 int* expected_property_count, | 1032 int* expected_property_count, bool* ok, |
1028 bool* ok); | 1033 Scanner::BookmarkScope* bookmark = nullptr); |
1029 | 1034 |
1030 PreParser::PreParseResult ParseLazyFunctionBodyWithPreParser( | 1035 PreParser::PreParseResult ParseLazyFunctionBodyWithPreParser( |
1031 SingletonLogger* logger); | 1036 SingletonLogger* logger, Scanner::BookmarkScope* bookmark = nullptr); |
1032 | 1037 |
1033 // Consumes the ending }. | 1038 // Consumes the ending }. |
1034 ZoneList<Statement*>* ParseEagerFunctionBody( | 1039 ZoneList<Statement*>* ParseEagerFunctionBody( |
1035 const AstRawString* function_name, int pos, Variable* fvar, | 1040 const AstRawString* function_name, int pos, Variable* fvar, |
1036 Token::Value fvar_init_op, FunctionKind kind, bool* ok); | 1041 Token::Value fvar_init_op, FunctionKind kind, bool* ok); |
1037 | 1042 |
1038 void ThrowPendingError(Isolate* isolate, Handle<Script> script); | 1043 void ThrowPendingError(Isolate* isolate, Handle<Script> script); |
1039 | 1044 |
1040 TemplateLiteralState OpenTemplateLiteral(int pos); | 1045 TemplateLiteralState OpenTemplateLiteral(int pos); |
1041 void AddTemplateSpan(TemplateLiteralState* state, bool tail); | 1046 void AddTemplateSpan(TemplateLiteralState* state, bool tail); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1082 return parser_->NewScope(parent_scope, scope_type, kind); | 1087 return parser_->NewScope(parent_scope, scope_type, kind); |
1083 } | 1088 } |
1084 | 1089 |
1085 | 1090 |
1086 const AstRawString* ParserTraits::EmptyIdentifierString() { | 1091 const AstRawString* ParserTraits::EmptyIdentifierString() { |
1087 return parser_->ast_value_factory()->empty_string(); | 1092 return parser_->ast_value_factory()->empty_string(); |
1088 } | 1093 } |
1089 | 1094 |
1090 | 1095 |
1091 void ParserTraits::SkipLazyFunctionBody(int* materialized_literal_count, | 1096 void ParserTraits::SkipLazyFunctionBody(int* materialized_literal_count, |
1092 int* expected_property_count, | 1097 int* expected_property_count, bool* ok, |
1093 bool* ok) { | 1098 Scanner::BookmarkScope* bookmark) { |
1094 return parser_->SkipLazyFunctionBody( | 1099 return parser_->SkipLazyFunctionBody(materialized_literal_count, |
1095 materialized_literal_count, expected_property_count, ok); | 1100 expected_property_count, ok, bookmark); |
1096 } | 1101 } |
1097 | 1102 |
1098 | 1103 |
1099 ZoneList<Statement*>* ParserTraits::ParseEagerFunctionBody( | 1104 ZoneList<Statement*>* ParserTraits::ParseEagerFunctionBody( |
1100 const AstRawString* name, int pos, Variable* fvar, | 1105 const AstRawString* name, int pos, Variable* fvar, |
1101 Token::Value fvar_init_op, FunctionKind kind, bool* ok) { | 1106 Token::Value fvar_init_op, FunctionKind kind, bool* ok) { |
1102 return parser_->ParseEagerFunctionBody(name, pos, fvar, fvar_init_op, kind, | 1107 return parser_->ParseEagerFunctionBody(name, pos, fvar, fvar_init_op, kind, |
1103 ok); | 1108 ok); |
1104 } | 1109 } |
1105 | 1110 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1173 } | 1178 } |
1174 | 1179 |
1175 | 1180 |
1176 Expression* ParserTraits::SpreadCallNew( | 1181 Expression* ParserTraits::SpreadCallNew( |
1177 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { | 1182 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { |
1178 return parser_->SpreadCallNew(function, args, pos); | 1183 return parser_->SpreadCallNew(function, args, pos); |
1179 } | 1184 } |
1180 } } // namespace v8::internal | 1185 } } // namespace v8::internal |
1181 | 1186 |
1182 #endif // V8_PARSER_H_ | 1187 #endif // V8_PARSER_H_ |
OLD | NEW |