| Index: src/parser.h
|
| diff --git a/src/parser.h b/src/parser.h
|
| index 103bafea3341595f4d08ef58d425567ce037da99..39d0d9278b132fd4dfc5a9ebd104661f1f846205 100644
|
| --- a/src/parser.h
|
| +++ b/src/parser.h
|
| @@ -538,27 +538,6 @@
|
| class Parser;
|
| class SingletonLogger;
|
|
|
| -
|
| -struct ParserFormalParameterParsingState
|
| - : public PreParserFormalParameterParsingState {
|
| - struct Parameter {
|
| - Parameter(Variable* var, Expression* pattern)
|
| - : var(var), pattern(pattern) {}
|
| - Variable* var;
|
| - Expression* pattern;
|
| - };
|
| -
|
| - explicit ParserFormalParameterParsingState(Scope* scope)
|
| - : PreParserFormalParameterParsingState(scope), params(4, scope->zone()) {}
|
| -
|
| - ZoneList<Parameter> params;
|
| -
|
| - void AddParameter(Variable* var, Expression* pattern) {
|
| - params.Add(Parameter(var, pattern), scope->zone());
|
| - }
|
| -};
|
| -
|
| -
|
| class ParserTraits {
|
| public:
|
| struct Type {
|
| @@ -581,7 +560,7 @@
|
| typedef ZoneList<v8::internal::Expression*>* ExpressionList;
|
| typedef ZoneList<ObjectLiteral::Property*>* PropertyList;
|
| typedef const v8::internal::AstRawString* FormalParameter;
|
| - typedef ParserFormalParameterParsingState FormalParameterParsingState;
|
| + typedef Scope FormalParameterScope;
|
| typedef ZoneList<v8::internal::Statement*>* StatementList;
|
|
|
| // For constructing objects returned by the traversing functions.
|
| @@ -772,21 +751,17 @@
|
| ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) {
|
| return new(zone) ZoneList<v8::internal::Statement*>(size, zone);
|
| }
|
| -
|
| - V8_INLINE void AddParameterInitializationBlock(
|
| - const ParserFormalParameterParsingState& formal_parameters,
|
| - ZoneList<v8::internal::Statement*>* body, bool* ok);
|
| -
|
| V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type,
|
| FunctionKind kind = kNormalFunction);
|
|
|
| - V8_INLINE void DeclareFormalParameter(
|
| - ParserFormalParameterParsingState* parsing_state, Expression* name,
|
| - ExpressionClassifier* classifier, bool is_rest);
|
| - void ParseArrowFunctionFormalParameters(
|
| - ParserFormalParameterParsingState* scope, Expression* params,
|
| - const Scanner::Location& params_loc, Scanner::Location* duplicate_loc,
|
| - bool* ok);
|
| + V8_INLINE void DeclareFormalParameter(Scope* scope, Expression* name,
|
| + ExpressionClassifier* classifier,
|
| + bool is_rest);
|
| + void ParseArrowFunctionFormalParameters(Scope* scope, Expression* params,
|
| + const Scanner::Location& params_loc,
|
| + bool* has_rest,
|
| + Scanner::Location* duplicate_loc,
|
| + bool* ok);
|
|
|
| // Temporary glue; these functions will move to ParserBase.
|
| Expression* ParseV8Intrinsic(bool* ok);
|
| @@ -799,9 +774,8 @@
|
| int* materialized_literal_count, int* expected_property_count, bool* ok,
|
| Scanner::BookmarkScope* bookmark = nullptr);
|
| V8_INLINE ZoneList<Statement*>* ParseEagerFunctionBody(
|
| - const AstRawString* name, int pos,
|
| - const ParserFormalParameterParsingState& formal_parameters,
|
| - Variable* fvar, Token::Value fvar_init_op, FunctionKind kind, bool* ok);
|
| + const AstRawString* name, int pos, Variable* fvar,
|
| + Token::Value fvar_init_op, FunctionKind kind, bool* ok);
|
|
|
| ClassLiteral* ParseClassLiteral(const AstRawString* name,
|
| Scanner::Location class_name_location,
|
| @@ -962,7 +936,6 @@
|
| bool* ok);
|
|
|
| struct DeclarationDescriptor {
|
| - enum Kind { NORMAL, PARAMETER };
|
| Parser* parser;
|
| Scope* declaration_scope;
|
| Scope* scope;
|
| @@ -972,7 +945,6 @@
|
| int declaration_pos;
|
| int initialization_pos;
|
| Token::Value init_op;
|
| - Kind declaration_kind;
|
| };
|
|
|
| struct DeclarationParsingResult {
|
| @@ -1123,9 +1095,7 @@
|
|
|
| // Parser support
|
| VariableProxy* NewUnresolved(const AstRawString* name, VariableMode mode);
|
| - Variable* Declare(Declaration* declaration,
|
| - DeclarationDescriptor::Kind declaration_kind, bool resolve,
|
| - bool* ok);
|
| + Variable* Declare(Declaration* declaration, bool resolve, bool* ok);
|
|
|
| bool TargetStackContainsLabel(const AstRawString* label);
|
| BreakableStatement* LookupBreakTarget(const AstRawString* label, bool* ok);
|
| @@ -1151,14 +1121,10 @@
|
| PreParser::PreParseResult ParseLazyFunctionBodyWithPreParser(
|
| SingletonLogger* logger, Scanner::BookmarkScope* bookmark = nullptr);
|
|
|
| - Block* BuildParameterInitializationBlock(
|
| - const ParserFormalParameterParsingState& formal_parameters, bool* ok);
|
| -
|
| // Consumes the ending }.
|
| ZoneList<Statement*>* ParseEagerFunctionBody(
|
| - const AstRawString* function_name, int pos,
|
| - const ParserFormalParameterParsingState& formal_parameters,
|
| - Variable* fvar, Token::Value fvar_init_op, FunctionKind kind, bool* ok);
|
| + const AstRawString* function_name, int pos, Variable* fvar,
|
| + Token::Value fvar_init_op, FunctionKind kind, bool* ok);
|
|
|
| void ThrowPendingError(Isolate* isolate, Handle<Script> script);
|
|
|
| @@ -1222,11 +1188,10 @@
|
|
|
|
|
| ZoneList<Statement*>* ParserTraits::ParseEagerFunctionBody(
|
| - const AstRawString* name, int pos,
|
| - const ParserFormalParameterParsingState& formal_parameters, Variable* fvar,
|
| + const AstRawString* name, int pos, Variable* fvar,
|
| Token::Value fvar_init_op, FunctionKind kind, bool* ok) {
|
| - return parser_->ParseEagerFunctionBody(name, pos, formal_parameters, fvar,
|
| - fvar_init_op, kind, ok);
|
| + return parser_->ParseEagerFunctionBody(name, pos, fvar, fvar_init_op, kind,
|
| + ok);
|
| }
|
|
|
| void ParserTraits::CheckConflictingVarDeclarations(v8::internal::Scope* scope,
|
| @@ -1305,20 +1270,18 @@
|
| }
|
|
|
|
|
| -void ParserTraits::DeclareFormalParameter(
|
| - ParserFormalParameterParsingState* parsing_state, Expression* pattern,
|
| - ExpressionClassifier* classifier, bool is_rest) {
|
| +void ParserTraits::DeclareFormalParameter(Scope* scope, Expression* pattern,
|
| + ExpressionClassifier* classifier,
|
| + bool is_rest) {
|
| bool is_duplicate = false;
|
| - bool is_simple_name = pattern->IsVariableProxy();
|
| - DCHECK(parser_->allow_harmony_destructuring() || is_simple_name);
|
| -
|
| - const AstRawString* name = is_simple_name
|
| - ? pattern->AsVariableProxy()->raw_name()
|
| - : parser_->ast_value_factory()->empty_string();
|
| - Variable* var =
|
| - parsing_state->scope->DeclareParameter(name, VAR, is_rest, &is_duplicate);
|
| - parsing_state->AddParameter(var, is_simple_name ? nullptr : pattern);
|
| - if (is_sloppy(parsing_state->scope->language_mode())) {
|
| + if (!pattern->IsVariableProxy()) {
|
| + // TODO(dslomov): implement.
|
| + DCHECK(parser_->allow_harmony_destructuring());
|
| + return;
|
| + }
|
| + auto name = pattern->AsVariableProxy()->raw_name();
|
| + Variable* var = scope->DeclareParameter(name, VAR, is_rest, &is_duplicate);
|
| + if (is_sloppy(scope->language_mode())) {
|
| // TODO(sigurds) Mark every parameter as maybe assigned. This is a
|
| // conservative approximation necessary to account for parameters
|
| // that are assigned via the arguments array.
|
| @@ -1329,18 +1292,6 @@
|
| parser_->scanner()->location());
|
| }
|
| }
|
| -
|
| -
|
| -void ParserTraits::AddParameterInitializationBlock(
|
| - const ParserFormalParameterParsingState& formal_parameters,
|
| - ZoneList<v8::internal::Statement*>* body, bool* ok) {
|
| - auto* init_block =
|
| - parser_->BuildParameterInitializationBlock(formal_parameters, ok);
|
| - if (!*ok) return;
|
| - if (init_block != nullptr) {
|
| - body->Add(init_block, parser_->zone());
|
| - }
|
| -}
|
| } } // namespace v8::internal
|
|
|
| #endif // V8_PARSER_H_
|
|
|