Chromium Code Reviews| Index: src/ast/scopes.cc |
| diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc |
| index a0b23234166506e9ca328677d6056071d55dce64..51bff40d39a15f6eaa3b1c901fda1eeae2ebb8d7 100644 |
| --- a/src/ast/scopes.cc |
| +++ b/src/ast/scopes.cc |
| @@ -824,6 +824,23 @@ Declaration* Scope::CheckLexDeclarationsConflictingWith( |
| return nullptr; |
| } |
| +Scope* Scope::GetOuterScopeWithContext() const { |
| + Scope* scope = outer_scope(); |
| + while (scope) { |
|
marja
2016/08/29 07:53:00
Style nit: while (scope != nullptr) seems to be th
|
| + // If we hit a SCRIPT_SCOPE that isn't backed by a scope_info, it's the |
| + // SCRIPT_SCOPE corresponding to the native context. This also means, |
| + // that the variables in that scope never get resolved (they should be all |
| + // dynamic lookups), and so NeedsContext() incorrectly returns true. To |
| + // avoid this, we bail out here. |
| + if (scope->scope_type() == SCRIPT_SCOPE && scope->scope_info_.is_null()) { |
|
Toon Verwaest
2016/08/26 12:07:01
How does this work for let variables in top-level
jochen (gone - plz use gerrit)
2016/08/26 13:14:11
For a top-level script, we'll invoke GetScopeInfo(
marja
2016/08/29 07:53:00
I don't get this answer at all..
|
| + return nullptr; |
| + } |
| + if (scope->NeedsContext()) return scope; |
|
Toon Verwaest
2016/08/26 12:04:37
I guess this happens for outer function scopes fro
jochen (gone - plz use gerrit)
2016/08/26 13:14:10
I guess in practice, this should be always true.
|
| + scope = scope->outer_scope(); |
| + } |
| + return nullptr; |
| +} |
| + |
| void Scope::CollectVariables(ZoneList<Variable*>* stack_locals, |
| ZoneList<Variable*>* context_locals, |
| ZoneList<Variable*>* context_globals) { |