Index: src/scopes.cc |
diff --git a/src/scopes.cc b/src/scopes.cc |
index 4ac9d0e6a463047319ef43317ebd6551b798e110..77e644b25c046e369f3fa4d0133026f594ec008d 100644 |
--- a/src/scopes.cc |
+++ b/src/scopes.cc |
@@ -190,6 +190,7 @@ void Scope::SetDefaults(ScopeType type, |
illegal_redecl_ = NULL; |
scope_inside_with_ = false; |
scope_contains_with_ = false; |
+ scope_inside_generator_ = false; |
scope_calls_eval_ = false; |
// Inherit the strict mode from the parent scope. |
language_mode_ = (outer_scope != NULL) |
@@ -248,6 +249,25 @@ Scope* Scope::DeserializeScopeChain(Context* context, Scope* global_scope, |
FUNCTION_SCOPE, |
Handle<ScopeInfo>(scope_info), |
zone); |
+ if (context->closure()->shared()->is_generator()) { |
+ if (innermost_scope) { |
+ // Find the deepest scope that's still in this function. |
+ Scope *inner_scope = innermost_scope; |
+ for (Scope *s = innermost_scope; |
+ s != current_scope; |
+ s = s->outer_scope()) { |
+ inner_scope = s; |
+ while (!s->is_function_scope()) |
+ s = s->outer_scope(); |
+ } |
+ // Mark intervening scopes (inclusive) as being inside a generator. |
+ while (inner_scope != current_scope) { |
+ inner_scope->scope_inside_generator_ = true; |
+ inner_scope = inner_scope->outer_scope(); |
+ } |
+ } |
+ current_scope->scope_inside_generator_ = true; |
+ } |
} else if (context->IsBlockContext()) { |
ScopeInfo* scope_info = ScopeInfo::cast(context->extension()); |
current_scope = new(zone) Scope(current_scope, |
@@ -320,6 +340,7 @@ void Scope::Initialize() { |
if (outer_scope_ != NULL) { |
outer_scope_->inner_scopes_.Add(this, zone()); |
scope_inside_with_ = outer_scope_->scope_inside_with_ || is_with_scope(); |
+ scope_inside_generator_ = outer_scope_->inside_generator(); |
} else { |
scope_inside_with_ = is_with_scope(); |
} |