| Index: src/parsing/parser.h
|
| diff --git a/src/parsing/parser.h b/src/parsing/parser.h
|
| index 07a52eab2b248b7437f79305a5241d73434c6c47..44ef14a8b70fa161e33f4b7c59047df173c64016 100644
|
| --- a/src/parsing/parser.h
|
| +++ b/src/parsing/parser.h
|
| @@ -899,6 +899,12 @@ class ParserTraits {
|
| ZoneList<v8::internal::Expression*>* args,
|
| int pos);
|
|
|
| + // Rewrite all DestructuringAssignments in the current FunctionState.
|
| + V8_INLINE void RewriteDestructuringAssignments();
|
| +
|
| + V8_INLINE void QueueDestructuringAssignmentForRewriting(
|
| + Expression* assignment);
|
| +
|
| private:
|
| Parser* parser_;
|
| };
|
| @@ -1039,6 +1045,10 @@ class Parser : public ParserBase<ParserTraits> {
|
| const DeclarationParsingResult::Declaration* declaration,
|
| ZoneList<const AstRawString*>* names, bool* ok);
|
|
|
| + static void RewriteDestructuringAssignment(
|
| + Parser* parser, RewritableAssignmentExpression* expr, Scope* Scope,
|
| + bool* ok);
|
| +
|
| void set_initializer_position(int pos) { initializer_position_ = pos; }
|
|
|
| private:
|
| @@ -1050,6 +1060,16 @@ class Parser : public ParserBase<ParserTraits> {
|
| #undef DECLARE_VISIT
|
| void Visit(AstNode* node) override;
|
|
|
| + enum PatternContext {
|
| + BINDING,
|
| + INITIALIZER,
|
| + ASSIGNMENT,
|
| + ASSIGNMENT_INITIALIZER
|
| + };
|
| +
|
| + PatternContext context() const { return context_; }
|
| + void set_context(PatternContext context) { context_ = context; }
|
| +
|
| void RecurseIntoSubpattern(AstNode* pattern, Expression* value) {
|
| Expression* old_value = current_value_;
|
| current_value_ = value;
|
| @@ -1057,14 +1077,29 @@ class Parser : public ParserBase<ParserTraits> {
|
| current_value_ = old_value;
|
| }
|
|
|
| + void VisitObjectLiteral(ObjectLiteral* node, Variable** temp_var);
|
| + void VisitArrayLiteral(ArrayLiteral* node, Variable** temp_var);
|
| +
|
| + bool IsBindingContext() const { return IsBindingContext(context_); }
|
| + bool IsInitializerContext() const { return context_ != ASSIGNMENT; }
|
| + bool IsAssignmentContext() const { return IsAssignmentContext(context_); }
|
| + bool IsAssignmentContext(PatternContext c) const;
|
| + bool IsBindingContext(PatternContext c) const;
|
| + PatternContext SetAssignmentContextIfNeeded(Expression* node);
|
| + PatternContext SetInitializerContextIfNeeded(Expression* node);
|
| +
|
| Variable* CreateTempVar(Expression* value = nullptr);
|
|
|
| - AstNodeFactory* factory() const { return descriptor_->parser->factory(); }
|
| + AstNodeFactory* factory() const { return parser_->factory(); }
|
| AstValueFactory* ast_value_factory() const {
|
| - return descriptor_->parser->ast_value_factory();
|
| + return parser_->ast_value_factory();
|
| }
|
| - Zone* zone() const { return descriptor_->parser->zone(); }
|
| + Zone* zone() const { return parser_->zone(); }
|
| + Scope* scope() const { return scope_; }
|
|
|
| + Scope* scope_;
|
| + Parser* parser_;
|
| + PatternContext context_;
|
| Expression* pattern_;
|
| int initializer_position_;
|
| Block* block_;
|
| @@ -1214,6 +1249,11 @@ class Parser : public ParserBase<ParserTraits> {
|
| void SetLanguageMode(Scope* scope, LanguageMode mode);
|
| void RaiseLanguageMode(LanguageMode mode);
|
|
|
| + V8_INLINE void RewriteDestructuringAssignments();
|
| +
|
| + friend class InitializerRewriter;
|
| + void RewriteParameterInitializer(Expression* expr, Scope* scope);
|
| +
|
| Scanner scanner_;
|
| PreParser* reusable_preparser_;
|
| Scope* original_scope_; // for ES5 function declarations in sloppy eval
|
|
|