Skip to content
This repository has been archived by the owner on Mar 25, 2018. It is now read-only.

Commit

Permalink
Revert of [ast] Simplify FetchFreeVariables. (patchset #1 id:1 of htt…
Browse files Browse the repository at this point in the history
…ps://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.
>
> [email protected]
> BUG=

[email protected]
# 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}
  • Loading branch information
GeorgNeis authored and Commit bot committed Nov 14, 2016
1 parent 79aee39 commit 8538143
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/ast/scopes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ Scope* Scope::GetOuterScopeWithContext() {

Handle<StringSet> DeclarationScope::CollectNonLocals(
ParseInfo* info, Handle<StringSet> 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());
Expand Down Expand Up @@ -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) {
Expand All @@ -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();
}
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/ast/scopes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 8538143

Please sign in to comment.