Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(698)

Unified Diff: src/scopes.cc

Issue 13179002: Add parser support for generators. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: added additional syntax tests Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/scopes.h ('k') | src/token.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « src/scopes.h ('k') | src/token.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698