Index: src/scopes.cc |
diff --git a/src/scopes.cc b/src/scopes.cc |
index 8d5a4a84e9ec93d8eeaeb54a63c082946f4c1fe3..dac9ed26a8f76bda19845f1dbd7608a4e499818c 100644 |
--- a/src/scopes.cc |
+++ b/src/scopes.cc |
@@ -331,6 +331,36 @@ void Scope::Initialize(bool inside_with) { |
} |
+Scope* Scope::FinalizeBlockScope() { |
+ ASSERT(is_block_scope()); |
+ ASSERT(decls_.is_empty()); |
+ ASSERT(temps_.is_empty()); |
+ ASSERT(params_.is_empty()); |
+ |
+ if (num_var_or_const() > 0) return this; |
+ |
+ // Remove this scope from outer scope. |
+ for (int i = 0; i < outer_scope_->inner_scopes_.length(); i++) { |
+ if (outer_scope_->inner_scopes_[i] == this) { |
+ outer_scope_->inner_scopes_.Remove(i); |
+ break; |
+ } |
+ } |
+ |
+ // Reparent inner scopes. |
+ for (int i = 0; i < inner_scopes_.length(); i++) { |
+ outer_scope()->AddInnerScope(inner_scopes_[i]); |
+ } |
+ |
+ // Move unresolved variables |
+ for (int i = 0; i < unresolved_.length(); i++) { |
+ outer_scope()->unresolved_.Add(unresolved_[i]); |
+ } |
+ |
+ return NULL; |
+} |
+ |
+ |
Variable* Scope::LocalLookup(Handle<String> name) { |
Variable* result = variables_.Lookup(name); |
if (result != NULL || scope_info_.is_null()) { |