Index: src/ast/scopes.cc |
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc |
index f61e43073cfcf25a988e51ad3183e5bf1d91f6ca..bce3c030eb772ca6947d0384feb8c0651938d047 100644 |
--- a/src/ast/scopes.cc |
+++ b/src/ast/scopes.cc |
@@ -533,6 +533,13 @@ void DeclarationScope::Analyze(ParseInfo* info, AnalyzeMode mode) { |
scope->AllocateVariables(info, mode); |
+ // Ensuring that the outer script scope has a scope info avoids having |
+ // special case for native contexts vs other contexts. |
+ if (info->script_scope()->scope_info_.is_null()) { |
+ info->script_scope()->scope_info_ = |
+ handle(ScopeInfo::Empty(info->isolate())); |
+ } |
+ |
#ifdef DEBUG |
if (info->script_is_native() ? FLAG_print_builtin_scopes |
: FLAG_print_scopes) { |
@@ -1140,6 +1147,14 @@ DeclarationScope* Scope::GetReceiverScope() { |
return scope->AsDeclarationScope(); |
} |
+Scope* Scope::GetOuterScopeWithContext() { |
+ Scope* scope = outer_scope_; |
+ while (scope && !scope->NeedsContext()) { |
+ scope = scope->outer_scope(); |
+ } |
+ return scope; |
+} |
+ |
Handle<StringSet> DeclarationScope::CollectNonLocals( |
ParseInfo* info, Handle<StringSet> non_locals) { |
VariableProxy* free_variables = FetchFreeVariables(this, info); |