Index: src/parser.h |
diff --git a/src/parser.h b/src/parser.h |
index 1b138112f39542f4f38b62aadd608a586b40e143..b3e7d796ca1e0955e6557602bc7a0e30a77f3e4e 100644 |
--- a/src/parser.h |
+++ b/src/parser.h |
@@ -539,8 +539,7 @@ class Parser; |
class SingletonLogger; |
-struct ParserFormalParameterParsingState |
- : public PreParserFormalParameterParsingState { |
+struct ParserFormalParameters : public PreParserFormalParameters { |
struct Parameter { |
Parameter(Variable* var, Expression* pattern) |
: var(var), pattern(pattern) {} |
@@ -548,8 +547,8 @@ struct ParserFormalParameterParsingState |
Expression* pattern; |
}; |
- explicit ParserFormalParameterParsingState(Scope* scope) |
- : PreParserFormalParameterParsingState(scope), params(4, scope->zone()) {} |
+ explicit ParserFormalParameters(Scope* scope) |
+ : PreParserFormalParameters(scope), params(4, scope->zone()) {} |
ZoneList<Parameter> params; |
@@ -581,7 +580,7 @@ class ParserTraits { |
typedef ZoneList<v8::internal::Expression*>* ExpressionList; |
typedef ZoneList<ObjectLiteral::Property*>* PropertyList; |
typedef const v8::internal::AstRawString* FormalParameter; |
- typedef ParserFormalParameterParsingState FormalParameterParsingState; |
+ typedef ParserFormalParameters FormalParameters; |
typedef ZoneList<v8::internal::Statement*>* StatementList; |
// For constructing objects returned by the traversing functions. |
@@ -774,21 +773,21 @@ class ParserTraits { |
} |
V8_INLINE void AddParameterInitializationBlock( |
- const ParserFormalParameterParsingState& formal_parameters, |
+ const ParserFormalParameters& 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); |
+ ParserFormalParameters* parameters, Expression* pattern, bool is_rest, |
+ ExpressionClassifier* classifier); |
void ParseArrowFunctionFormalParameters( |
- ParserFormalParameterParsingState* scope, Expression* params, |
- const Scanner::Location& params_loc, Scanner::Location* duplicate_loc, |
- bool* ok); |
+ ParserFormalParameters* parameters, Expression* params, |
+ const Scanner::Location& params_loc, |
+ Scanner::Location* duplicate_loc, bool* ok); |
- void ReindexLiterals(const ParserFormalParameterParsingState& parsing_state); |
+ void ReindexLiterals(const ParserFormalParameters& parameters); |
// Temporary glue; these functions will move to ParserBase. |
Expression* ParseV8Intrinsic(bool* ok); |
@@ -803,7 +802,7 @@ class ParserTraits { |
Scanner::BookmarkScope* bookmark = nullptr); |
V8_INLINE ZoneList<Statement*>* ParseEagerFunctionBody( |
const AstRawString* name, int pos, |
- const ParserFormalParameterParsingState& formal_parameters, |
+ const ParserFormalParameters& parameters, |
Variable* fvar, Token::Value fvar_init_op, FunctionKind kind, bool* ok); |
ClassLiteral* ParseClassLiteral(const AstRawString* name, |
@@ -1155,15 +1154,14 @@ class Parser : public ParserBase<ParserTraits> { |
PreParser::PreParseResult ParseLazyFunctionBodyWithPreParser( |
SingletonLogger* logger, Scanner::BookmarkScope* bookmark = nullptr); |
- bool IsSimpleParameterList( |
- const ParserFormalParameterParsingState& formal_parameters); |
+ bool IsSimpleParameterList(const ParserFormalParameters& parameters); |
Block* BuildParameterInitializationBlock( |
- const ParserFormalParameterParsingState& formal_parameters, bool* ok); |
+ const ParserFormalParameters& parameters, bool* ok); |
// Consumes the ending }. |
ZoneList<Statement*>* ParseEagerFunctionBody( |
const AstRawString* function_name, int pos, |
- const ParserFormalParameterParsingState& formal_parameters, |
+ const ParserFormalParameters& parameters, |
Variable* fvar, Token::Value fvar_init_op, FunctionKind kind, bool* ok); |
void ThrowPendingError(Isolate* isolate, Handle<Script> script); |
@@ -1229,9 +1227,9 @@ void ParserTraits::SkipLazyFunctionBody(int* materialized_literal_count, |
ZoneList<Statement*>* ParserTraits::ParseEagerFunctionBody( |
const AstRawString* name, int pos, |
- const ParserFormalParameterParsingState& formal_parameters, Variable* fvar, |
+ const ParserFormalParameters& parameters, Variable* fvar, |
Token::Value fvar_init_op, FunctionKind kind, bool* ok) { |
- return parser_->ParseEagerFunctionBody(name, pos, formal_parameters, fvar, |
+ return parser_->ParseEagerFunctionBody(name, pos, parameters, fvar, |
fvar_init_op, kind, ok); |
} |
@@ -1312,40 +1310,41 @@ Expression* ParserTraits::SpreadCallNew( |
void ParserTraits::DeclareFormalParameter( |
- ParserFormalParameterParsingState* parsing_state, Expression* pattern, |
- ExpressionClassifier* classifier, bool is_rest) { |
+ ParserFormalParameters* parameters, Expression* pattern, bool is_rest, |
+ ExpressionClassifier* classifier) { |
bool is_duplicate = false; |
- bool is_simple_name = pattern->IsVariableProxy(); |
- DCHECK(parser_->allow_harmony_destructuring() || is_simple_name); |
+ bool is_simple = pattern->IsVariableProxy(); |
+ DCHECK(parser_->allow_harmony_destructuring() || is_simple); |
- const AstRawString* name = is_simple_name |
+ const AstRawString* name = is_simple |
? 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())) { |
+ parameters->scope->DeclareParameter(name, VAR, is_rest, &is_duplicate); |
+ parameters->AddParameter(var, is_simple ? nullptr : pattern); |
+ if (is_duplicate) { |
+ classifier->RecordDuplicateFormalParameterError( |
+ parser_->scanner()->location()); |
+ } |
+ if (is_sloppy(parameters->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. |
var->set_maybe_assigned(); |
} |
- if (is_duplicate) { |
- classifier->RecordDuplicateFormalParameterError( |
- parser_->scanner()->location()); |
- } |
} |
void ParserTraits::AddParameterInitializationBlock( |
- const ParserFormalParameterParsingState& formal_parameters, |
+ const ParserFormalParameters& parameters, |
ZoneList<v8::internal::Statement*>* body, bool* ok) { |
- if (parser_->IsSimpleParameterList(formal_parameters)) return; |
- auto* init_block = |
- parser_->BuildParameterInitializationBlock(formal_parameters, ok); |
- if (!*ok) return; |
- if (init_block != nullptr) { |
- body->Add(init_block, parser_->zone()); |
+ if (!parser_->IsSimpleParameterList(parameters)) { |
+ auto* init_block = |
+ parser_->BuildParameterInitializationBlock(parameters, ok); |
+ if (!*ok) return; |
+ if (init_block != nullptr) { |
+ body->Add(init_block, parser_->zone()); |
+ } |
} |
} |
} } // namespace v8::internal |