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

Unified Diff: src/scopes.cc

Issue 1250513004: [es6] Make sure temporaries are not allocated in block scope (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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/variables.cc » ('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 6e1c18dc2e11b346c3c3e4914d58160a8027eb5c..4aca42042233652d3ad0b597804793652e8b106d 100644
--- a/src/scopes.cc
+++ b/src/scopes.cc
@@ -527,26 +527,15 @@ void Scope::RemoveUnresolved(VariableProxy* var) {
}
-Variable* Scope::NewInternal(const AstRawString* name) {
- DCHECK(!already_resolved());
- Variable* var = new(zone()) Variable(this,
- name,
- INTERNAL,
- Variable::NORMAL,
- kCreatedInitialized);
- internals_.Add(var, zone());
- return var;
-}
-
-
Variable* Scope::NewTemporary(const AstRawString* name) {
DCHECK(!already_resolved());
- Variable* var = new(zone()) Variable(this,
+ Scope* scope = this->TemporaryScope();
+ Variable* var = new(zone()) Variable(scope,
name,
TEMPORARY,
Variable::NORMAL,
kCreatedInitialized);
- temps_.Add(var, zone());
+ scope->temps_.Add(var, zone());
return var;
}
@@ -772,6 +761,15 @@ Scope* Scope::DeclarationScope() {
}
+Scope* Scope::TemporaryScope() {
+ Scope* scope = this;
+ while (!scope->is_declaration_scope() || scope->is_block_scope()) {
+ scope = scope->outer_scope();
+ }
+ return scope;
+}
+
+
Scope* Scope::ReceiverScope() {
Scope* scope = this;
while (!scope->is_script_scope() &&
@@ -1354,7 +1352,6 @@ bool Scope::MustAllocateInContext(Variable* var) {
// always context-allocated.
if (has_forced_context_allocation()) return true;
if (var->mode() == TEMPORARY) return false;
- if (var->mode() == INTERNAL) return true;
if (is_catch_scope() || is_module_scope()) return true;
if (is_script_scope() && IsLexicalVariableMode(var->mode())) return true;
return var->has_forced_context_allocation() ||
@@ -1609,7 +1606,8 @@ void Scope::AllocateModules() {
DCHECK(!scope->already_resolved());
DCHECK(scope->module_descriptor_->IsFrozen());
DCHECK_NULL(scope->module_var_);
- scope->module_var_ = NewInternal(ast_value_factory_->dot_module_string());
+ scope->module_var_ =
+ NewTemporary(ast_value_factory_->dot_module_string());
++num_modules_;
}
}
« no previous file with comments | « src/scopes.h ('k') | src/variables.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698