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 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 Scope* scope = this->ClosureScope(); | 557 Scope* scope = this->ClosureScope(); |
558 Variable* var = new(zone()) Variable(scope, | 558 Variable* var = new(zone()) Variable(scope, |
559 name, | 559 name, |
560 TEMPORARY, | 560 TEMPORARY, |
561 Variable::NORMAL, | 561 Variable::NORMAL, |
562 kCreatedInitialized); | 562 kCreatedInitialized); |
563 scope->AddTemporary(var); | 563 scope->AddTemporary(var); |
564 return var; | 564 return var; |
565 } | 565 } |
566 | 566 |
567 | 567 int Scope::RemoveTemporary(Variable* var) { |
568 bool Scope::RemoveTemporary(Variable* var) { | |
569 // Most likely (always?) any temporary variable we want to remove | 568 // Most likely (always?) any temporary variable we want to remove |
570 // was just added before, so we search backwards. | 569 // was just added before, so we search backwards. |
571 for (int i = temps_.length(); i-- > 0;) { | 570 for (int i = temps_.length(); i-- > 0;) { |
572 if (temps_[i] == var) { | 571 if (temps_[i] == var) { |
573 temps_.Remove(i); | 572 temps_.Remove(i); |
574 return true; | 573 return i; |
575 } | 574 } |
576 } | 575 } |
577 return false; | 576 return -1; |
578 } | 577 } |
579 | 578 |
580 | 579 |
581 void Scope::AddDeclaration(Declaration* declaration) { | 580 void Scope::AddDeclaration(Declaration* declaration) { |
582 decls_.Add(declaration, zone()); | 581 decls_.Add(declaration, zone()); |
583 } | 582 } |
584 | 583 |
585 | 584 |
586 void Scope::SetIllegalRedeclaration(Expression* expression) { | 585 void Scope::SetIllegalRedeclaration(Expression* expression) { |
587 // Record only the first illegal redeclaration. | 586 // Record only the first illegal redeclaration. |
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1530 function_ != NULL && function_->proxy()->var()->IsContextSlot(); | 1529 function_ != NULL && function_->proxy()->var()->IsContextSlot(); |
1531 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - | 1530 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - |
1532 (is_function_var_in_context ? 1 : 0); | 1531 (is_function_var_in_context ? 1 : 0); |
1533 } | 1532 } |
1534 | 1533 |
1535 | 1534 |
1536 int Scope::ContextGlobalCount() const { return num_global_slots(); } | 1535 int Scope::ContextGlobalCount() const { return num_global_slots(); } |
1537 | 1536 |
1538 } // namespace internal | 1537 } // namespace internal |
1539 } // namespace v8 | 1538 } // namespace v8 |
OLD | NEW |