From 8538143c61664a6859e5f24374936b9e9edc92ce Mon Sep 17 00:00:00 2001 From: neis Date: Mon, 14 Nov 2016 05:22:38 -0800 Subject: [PATCH] Revert of [ast] Simplify FetchFreeVariables. (patchset #1 id:1 of https://codereview.chromium.org/2491373004/ ) Reason for revert: It's probably needed after all but we're lacking tests. Original issue's description: > [ast] Simplify FetchFreeVariables. > > This CL removes the ParseInfo argument from FetchFreeVariables, since it seems > to have become unnecessary. > > R=verwaest@chromium.org > BUG= TBR=verwaest@chromium.org # Not skipping CQ checks because original CL landed more than 1 days ago. BUG= Review-Url: https://codereview.chromium.org/2495293002 Cr-Commit-Position: refs/heads/master@{#40964} --- src/ast/scopes.cc | 9 ++++++--- src/ast/scopes.h | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc index ad9330538ab9..c3cab48d6e3a 100644 --- a/src/ast/scopes.cc +++ b/src/ast/scopes.cc @@ -1247,7 +1247,7 @@ Scope* Scope::GetOuterScopeWithContext() { Handle DeclarationScope::CollectNonLocals( ParseInfo* info, Handle non_locals) { - VariableProxy* free_variables = FetchFreeVariables(this, true); + VariableProxy* free_variables = FetchFreeVariables(this, true, info); for (VariableProxy* proxy = free_variables; proxy != nullptr; proxy = proxy->next_unresolved()) { non_locals = StringSet::Add(non_locals, proxy->name()); @@ -1734,7 +1734,7 @@ void Scope::ResolveVariablesRecursively(ParseInfo* info) { } VariableProxy* Scope::FetchFreeVariables(DeclarationScope* max_outer_scope, - bool try_to_resolve, + bool try_to_resolve, ParseInfo* info, VariableProxy* stack) { for (VariableProxy *proxy = unresolved_, *next = nullptr; proxy != nullptr; proxy = next) { @@ -1747,6 +1747,8 @@ VariableProxy* Scope::FetchFreeVariables(DeclarationScope* max_outer_scope, if (var == nullptr) { proxy->set_next_unresolved(stack); stack = proxy; + } else if (info != nullptr) { + ResolveTo(info, proxy, var); } else { var->set_is_used(); } @@ -1756,7 +1758,8 @@ VariableProxy* Scope::FetchFreeVariables(DeclarationScope* max_outer_scope, unresolved_ = nullptr; for (Scope* scope = inner_scope_; scope != nullptr; scope = scope->sibling_) { - stack = scope->FetchFreeVariables(max_outer_scope, try_to_resolve, stack); + stack = + scope->FetchFreeVariables(max_outer_scope, try_to_resolve, info, stack); } return stack; diff --git a/src/ast/scopes.h b/src/ast/scopes.h index 37c296ce0733..865198e58e58 100644 --- a/src/ast/scopes.h +++ b/src/ast/scopes.h @@ -520,8 +520,10 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) { // Finds free variables of this scope. This mutates the unresolved variables // list along the way, so full resolution cannot be done afterwards. + // If a ParseInfo* is passed, non-free variables will be resolved. VariableProxy* FetchFreeVariables(DeclarationScope* max_outer_scope, bool try_to_resolve = true, + ParseInfo* info = nullptr, VariableProxy* stack = nullptr); // Predicates.