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

Unified Diff: src/ast/scopes.cc

Issue 2166023002: Rescope arrow-function parameter lists by moving the delta to the parameter scope (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: remove unresolved() again Created 4 years, 5 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/ast/scopes.h ('k') | src/parsing/parser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/scopes.cc
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc
index 583a5af04ff62defa3510a5349940ddaf0fb2bce..3314596c573e6add510a12e850e6981d342da318 100644
--- a/src/ast/scopes.cc
+++ b/src/ast/scopes.cc
@@ -366,6 +366,50 @@ Scope* Scope::FinalizeBlockScope() {
return NULL;
}
+void Scope::Snapshot::Reparent(Scope* new_parent) const {
+ DCHECK_EQ(new_parent, outer_scope_->inner_scope_);
+ DCHECK_EQ(new_parent->outer_scope_, outer_scope_);
+ DCHECK_EQ(new_parent, new_parent->ClosureScope());
+ Scope* inner_scope = new_parent->sibling_;
+ if (inner_scope != top_inner_scope_) {
+ for (; inner_scope->sibling() != top_inner_scope_;
+ inner_scope = inner_scope->sibling()) {
+ inner_scope->outer_scope_ = new_parent;
+ DCHECK_NE(inner_scope, new_parent);
+ }
+ inner_scope->outer_scope_ = new_parent;
+
+ new_parent->inner_scope_ = new_parent->sibling_;
nickie 2016/07/21 15:08:52 As you're blindly assigning here, I'd recommend to
+ inner_scope->sibling_ = nullptr;
+ // Reset the sibling rather than the inner_scope_ since we
+ // want to keep new_parent there.
+ DCHECK_EQ(new_parent, outer_scope_->inner_scope_);
+ new_parent->sibling_ = top_inner_scope_;
+ }
+
+ if (outer_scope_->unresolved_ != top_unresolved_) {
+ VariableProxy* last;
+ for (last = outer_scope_->unresolved_;
+ last->next_unresolved() != top_unresolved_;
+ last = last->next_unresolved()) {
+ }
+ last->set_next_unresolved(nullptr);
+ new_parent->unresolved_ = outer_scope_->unresolved_;
+ outer_scope_->unresolved_ = top_unresolved_;
+ }
+
+ if (outer_scope_->ClosureScope()->temps_.length() != top_temp_) {
+ ZoneList<Variable*>* temps = &outer_scope_->ClosureScope()->temps_;
+ for (int i = top_temp_; i < temps->length(); i++) {
+ Variable* temp = (*temps)[i];
+ DCHECK_EQ(temp->scope(), temp->scope()->ClosureScope());
+ DCHECK_NE(temp->scope(), new_parent);
+ temp->set_scope(new_parent);
+ new_parent->AddTemporary(temp);
+ }
+ temps->Rewind(top_temp_);
+ }
+}
void Scope::ReplaceOuterScope(Scope* outer) {
DCHECK_NOT_NULL(outer);
« no previous file with comments | « src/ast/scopes.h ('k') | src/parsing/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698