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

Unified Diff: src/scopes.cc

Issue 1414283002: [es6] Fix scoping for default parameters in arrow functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased 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/scopes.h ('k') | test/mjsunit/harmony/regress/regress-4395.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scopes.cc
diff --git a/src/scopes.cc b/src/scopes.cc
index 4e6acca5fc64ba5f6be60a0e70d6f739aa87dea4..cc3250704cd65cc6622d3d73dadaaf8aaac5f907 100644
--- a/src/scopes.cc
+++ b/src/scopes.cc
@@ -377,12 +377,7 @@ Scope* Scope::FinalizeBlockScope() {
}
// Remove this scope from outer scope.
- for (int i = 0; i < outer_scope_->inner_scopes_.length(); i++) {
- if (outer_scope_->inner_scopes_[i] == this) {
- outer_scope_->inner_scopes_.Remove(i);
- break;
- }
- }
+ outer_scope()->RemoveInnerScope(this);
// Reparent inner scopes.
for (int i = 0; i < inner_scopes_.length(); i++) {
@@ -395,6 +390,7 @@ Scope* Scope::FinalizeBlockScope() {
}
// Propagate usage flags to outer scope.
+ // TODO(adamk): Why doesn't this call PropagateScopeInfo()?
if (uses_arguments()) outer_scope_->RecordArgumentsUsage();
if (uses_super_property()) outer_scope_->RecordSuperPropertyUsage();
if (scope_calls_eval_) outer_scope_->RecordEvalCall();
@@ -403,6 +399,15 @@ Scope* Scope::FinalizeBlockScope() {
}
+void Scope::ReplaceOuterScope(Scope* outer_scope) {
+ DCHECK_NOT_NULL(outer_scope_);
+ outer_scope_->RemoveInnerScope(this);
+ outer_scope_ = outer_scope;
+ outer_scope_->AddInnerScope(this);
+ // TODO(adamk): Do we need to propagate usage flags here?
+}
+
+
Variable* Scope::LookupLocal(const AstRawString* name) {
Variable* result = variables_.Lookup(name);
if (result != NULL || scope_info_.is_null()) {
@@ -548,15 +553,16 @@ Variable* Scope::DeclareDynamicGlobal(const AstRawString* name) {
}
-void Scope::RemoveUnresolved(VariableProxy* var) {
+bool Scope::RemoveUnresolved(VariableProxy* var) {
// Most likely (always?) any variable we want to remove
// was just added before, so we search backwards.
for (int i = unresolved_.length(); i-- > 0;) {
if (unresolved_[i] == var) {
unresolved_.Remove(i);
- return;
+ return true;
}
}
+ return false;
}
« no previous file with comments | « src/scopes.h ('k') | test/mjsunit/harmony/regress/regress-4395.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698