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

Unified Diff: src/parser.h

Issue 1411203002: [es6] implement destructuring assignment [clean diff] (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rename `recorded_first()` to `FirstRecorded()` because non-accessor Created 5 years, 2 months 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/messages.h ('k') | src/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.h
diff --git a/src/parser.h b/src/parser.h
index 35a6f3af20bdc7022e7ff5ac065b132533afe4c6..26a56668d8aab6373f11ca77d637606b880c0a12 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -560,6 +560,12 @@ struct ParserFormalParameters : FormalParametersBase {
};
+struct MarkedAssignment {
+ Scope* scope;
+ Assignment* assignment;
+};
+
+
class ParserTraits {
public:
struct Type {
@@ -591,6 +597,8 @@ class ParserTraits {
explicit ParserTraits(Parser* parser) : parser_(parser) {}
+ V8_INLINE void MarkDestructuringAssignment(Assignment* assignment);
+
// Helper functions for recursive descent.
bool IsEval(const AstRawString* identifier) const;
bool IsArguments(const AstRawString* identifier) const;
@@ -876,6 +884,9 @@ class ParserTraits {
ZoneList<v8::internal::Expression*>* args,
int pos);
+ V8_INLINE Expression* RewriteDestructuringAssignmentExpression(
+ Expression* expression);
+
private:
Parser* parser_;
};
@@ -1200,6 +1211,8 @@ class Parser : public ParserBase<ParserTraits> {
Expression* SpreadCallNew(Expression* function,
ZoneList<v8::internal::Expression*>* args, int pos);
+ Expression* RewriteDestructuringAssignmentExpression(Expression* expression);
+
Scanner scanner_;
PreParser* reusable_preparser_;
Scope* original_scope_; // for ES5 function declarations in sloppy eval
@@ -1216,6 +1229,9 @@ class Parser : public ParserBase<ParserTraits> {
HistogramTimer* pre_parse_timer_;
bool parsing_on_main_thread_;
+
+ // Track ambiguous expressions, to be rewritten later.
+ Collector<MarkedAssignment> marked_assignments_collector_;
};
@@ -1388,6 +1404,21 @@ DoExpression* ParserTraits::ParseDoExpression(bool* ok) {
}
+void ParserTraits::MarkDestructuringAssignment(Assignment* assignment) {
+ DCHECK(assignment->IsAssignment());
+ MarkedAssignment mark;
+ mark.assignment = assignment;
+ mark.scope = parser_->scope_;
+ parser_->marked_assignments_collector_.Add(mark);
+}
+
+
+Expression* ParserTraits::RewriteDestructuringAssignmentExpression(
+ Expression* expression) {
+ return parser_->RewriteDestructuringAssignmentExpression(expression);
+}
+
+
} // namespace internal
} // namespace v8
« no previous file with comments | « src/messages.h ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698