| Index: src/parser.h
|
| diff --git a/src/parser.h b/src/parser.h
|
| index 39d0d9278b132fd4dfc5a9ebd104661f1f846205..78f2176cae9cf01d838e60a8eac824111e1630ee 100644
|
| --- a/src/parser.h
|
| +++ b/src/parser.h
|
| @@ -751,6 +751,10 @@ class ParserTraits {
|
| ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) {
|
| return new(zone) ZoneList<v8::internal::Statement*>(size, zone);
|
| }
|
| +
|
| + V8_INLINE void AddParameterInitializationBlock(
|
| + ZoneList<v8::internal::Statement*>* body, bool* ok);
|
| +
|
| V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type,
|
| FunctionKind kind = kNormalFunction);
|
|
|
| @@ -1121,6 +1125,8 @@ class Parser : public ParserBase<ParserTraits> {
|
| PreParser::PreParseResult ParseLazyFunctionBodyWithPreParser(
|
| SingletonLogger* logger, Scanner::BookmarkScope* bookmark = nullptr);
|
|
|
| + Block* BuildParameterInitializationBlock(bool* ok);
|
| +
|
| // Consumes the ending }.
|
| ZoneList<Statement*>* ParseEagerFunctionBody(
|
| const AstRawString* function_name, int pos, Variable* fvar,
|
| @@ -1274,13 +1280,14 @@ void ParserTraits::DeclareFormalParameter(Scope* scope, Expression* pattern,
|
| ExpressionClassifier* classifier,
|
| bool is_rest) {
|
| bool is_duplicate = false;
|
| - 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);
|
| + 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 = scope->DeclareParameter(
|
| + name, is_simple_name ? nullptr : pattern, 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
|
| @@ -1292,6 +1299,16 @@ void ParserTraits::DeclareFormalParameter(Scope* scope, Expression* pattern,
|
| parser_->scanner()->location());
|
| }
|
| }
|
| +
|
| +
|
| +void ParserTraits::AddParameterInitializationBlock(
|
| + ZoneList<v8::internal::Statement*>* body, bool* ok) {
|
| + auto* init_block = parser_->BuildParameterInitializationBlock(ok);
|
| + if (!*ok) return;
|
| + if (init_block != nullptr) {
|
| + body->Add(init_block, parser_->zone());
|
| + }
|
| +}
|
| } } // namespace v8::internal
|
|
|
| #endif // V8_PARSER_H_
|
|
|