| OLD | NEW | 
|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "src/ast/scopes.h" | 5 #include "src/ast/scopes.h" | 
| 6 | 6 | 
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" | 
| 8 #include "src/ast/scopeinfo.h" | 8 #include "src/ast/scopeinfo.h" | 
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" | 
| 10 #include "src/messages.h" | 10 #include "src/messages.h" | 
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 360     } | 360     } | 
| 361     outer_scope()->unresolved_ = unresolved_; | 361     outer_scope()->unresolved_ = unresolved_; | 
| 362     unresolved_ = nullptr; | 362     unresolved_ = nullptr; | 
| 363   } | 363   } | 
| 364 | 364 | 
| 365   PropagateUsageFlagsToScope(outer_scope_); | 365   PropagateUsageFlagsToScope(outer_scope_); | 
| 366 | 366 | 
| 367   return NULL; | 367   return NULL; | 
| 368 } | 368 } | 
| 369 | 369 | 
|  | 370 void Scope::Snapshot::Reparent(Scope* new_parent) const { | 
|  | 371   DCHECK_EQ(new_parent, outer_scope_->inner_scope_); | 
|  | 372   DCHECK_EQ(new_parent->outer_scope_, outer_scope_); | 
|  | 373   DCHECK_EQ(new_parent, new_parent->ClosureScope()); | 
|  | 374   DCHECK_NULL(new_parent->inner_scope_); | 
|  | 375   DCHECK_NULL(new_parent->unresolved_); | 
|  | 376   DCHECK_EQ(0, new_parent->temps_.length()); | 
|  | 377   Scope* inner_scope = new_parent->sibling_; | 
|  | 378   if (inner_scope != top_inner_scope_) { | 
|  | 379     for (; inner_scope->sibling() != top_inner_scope_; | 
|  | 380          inner_scope = inner_scope->sibling()) { | 
|  | 381       inner_scope->outer_scope_ = new_parent; | 
|  | 382       DCHECK_NE(inner_scope, new_parent); | 
|  | 383     } | 
|  | 384     inner_scope->outer_scope_ = new_parent; | 
|  | 385 | 
|  | 386     new_parent->inner_scope_ = new_parent->sibling_; | 
|  | 387     inner_scope->sibling_ = nullptr; | 
|  | 388     // Reset the sibling rather than the inner_scope_ since we | 
|  | 389     // want to keep new_parent there. | 
|  | 390     new_parent->sibling_ = top_inner_scope_; | 
|  | 391   } | 
|  | 392 | 
|  | 393   if (outer_scope_->unresolved_ != top_unresolved_) { | 
|  | 394     VariableProxy* last = outer_scope_->unresolved_; | 
|  | 395     while (last->next_unresolved() != top_unresolved_) { | 
|  | 396       last = last->next_unresolved(); | 
|  | 397     } | 
|  | 398     last->set_next_unresolved(nullptr); | 
|  | 399     new_parent->unresolved_ = outer_scope_->unresolved_; | 
|  | 400     outer_scope_->unresolved_ = top_unresolved_; | 
|  | 401   } | 
|  | 402 | 
|  | 403   if (outer_scope_->ClosureScope()->temps_.length() != top_temp_) { | 
|  | 404     ZoneList<Variable*>* temps = &outer_scope_->ClosureScope()->temps_; | 
|  | 405     for (int i = top_temp_; i < temps->length(); i++) { | 
|  | 406       Variable* temp = temps->at(i); | 
|  | 407       DCHECK_EQ(temp->scope(), temp->scope()->ClosureScope()); | 
|  | 408       DCHECK_NE(temp->scope(), new_parent); | 
|  | 409       temp->set_scope(new_parent); | 
|  | 410       new_parent->AddTemporary(temp); | 
|  | 411     } | 
|  | 412     temps->Rewind(top_temp_); | 
|  | 413   } | 
|  | 414 } | 
| 370 | 415 | 
| 371 void Scope::ReplaceOuterScope(Scope* outer) { | 416 void Scope::ReplaceOuterScope(Scope* outer) { | 
| 372   DCHECK_NOT_NULL(outer); | 417   DCHECK_NOT_NULL(outer); | 
| 373   DCHECK_NOT_NULL(outer_scope_); | 418   DCHECK_NOT_NULL(outer_scope_); | 
| 374   DCHECK(!already_resolved()); | 419   DCHECK(!already_resolved()); | 
| 375   DCHECK(!outer->already_resolved()); | 420   DCHECK(!outer->already_resolved()); | 
| 376   DCHECK(!outer_scope_->already_resolved()); | 421   DCHECK(!outer_scope_->already_resolved()); | 
| 377   outer_scope_->RemoveInnerScope(this); | 422   outer_scope_->RemoveInnerScope(this); | 
| 378   outer->AddInnerScope(this); | 423   outer->AddInnerScope(this); | 
| 379   outer_scope_ = outer; | 424   outer_scope_ = outer; | 
| (...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1535       function_ != NULL && function_->proxy()->var()->IsContextSlot(); | 1580       function_ != NULL && function_->proxy()->var()->IsContextSlot(); | 
| 1536   return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - | 1581   return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - | 
| 1537          (is_function_var_in_context ? 1 : 0); | 1582          (is_function_var_in_context ? 1 : 0); | 
| 1538 } | 1583 } | 
| 1539 | 1584 | 
| 1540 | 1585 | 
| 1541 int Scope::ContextGlobalCount() const { return num_global_slots(); } | 1586 int Scope::ContextGlobalCount() const { return num_global_slots(); } | 
| 1542 | 1587 | 
| 1543 }  // namespace internal | 1588 }  // namespace internal | 
| 1544 }  // namespace v8 | 1589 }  // namespace v8 | 
| OLD | NEW | 
|---|