Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Unified Diff: src/parsing/parser.h

Issue 1309813007: [es6] implement destructuring assignment (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase*** oops Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parsing/expression-classifier.h ('k') | src/parsing/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « src/parsing/expression-classifier.h ('k') | src/parsing/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698