| 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 #ifndef V8_AST_SCOPES_H_ | 5 #ifndef V8_AST_SCOPES_H_ |
| 6 #define V8_AST_SCOPES_H_ | 6 #define V8_AST_SCOPES_H_ |
| 7 | 7 |
| 8 #include "src/base/compiler-specific.h" | 8 #include "src/base/compiler-specific.h" |
| 9 #include "src/base/hashmap.h" | 9 #include "src/base/hashmap.h" |
| 10 #include "src/globals.h" | 10 #include "src/globals.h" |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 | 416 |
| 417 // Check that all Scopes in the scope tree use the same Zone. | 417 // Check that all Scopes in the scope tree use the same Zone. |
| 418 void CheckZones(); | 418 void CheckZones(); |
| 419 #endif | 419 #endif |
| 420 | 420 |
| 421 // Retrieve `IsSimpleParameterList` of current or outer function. | 421 // Retrieve `IsSimpleParameterList` of current or outer function. |
| 422 bool HasSimpleParameters(); | 422 bool HasSimpleParameters(); |
| 423 void set_is_debug_evaluate_scope() { is_debug_evaluate_scope_ = true; } | 423 void set_is_debug_evaluate_scope() { is_debug_evaluate_scope_ = true; } |
| 424 bool is_debug_evaluate_scope() const { return is_debug_evaluate_scope_; } | 424 bool is_debug_evaluate_scope() const { return is_debug_evaluate_scope_; } |
| 425 | 425 |
| 426 bool RemoveInnerScope(Scope* inner_scope) { |
| 427 DCHECK_NOT_NULL(inner_scope); |
| 428 if (inner_scope == inner_scope_) { |
| 429 inner_scope_ = inner_scope_->sibling_; |
| 430 return true; |
| 431 } |
| 432 for (Scope* scope = inner_scope_; scope != nullptr; |
| 433 scope = scope->sibling_) { |
| 434 if (scope->sibling_ == inner_scope) { |
| 435 scope->sibling_ = scope->sibling_->sibling_; |
| 436 return true; |
| 437 } |
| 438 } |
| 439 return false; |
| 440 } |
| 441 |
| 426 protected: | 442 protected: |
| 427 explicit Scope(Zone* zone); | 443 explicit Scope(Zone* zone); |
| 428 | 444 |
| 429 void set_language_mode(LanguageMode language_mode) { | 445 void set_language_mode(LanguageMode language_mode) { |
| 430 is_strict_ = is_strict(language_mode); | 446 is_strict_ = is_strict(language_mode); |
| 431 } | 447 } |
| 432 | 448 |
| 433 private: | 449 private: |
| 434 Variable* Declare(Zone* zone, const AstRawString* name, VariableMode mode, | 450 Variable* Declare(Zone* zone, const AstRawString* name, VariableMode mode, |
| 435 VariableKind kind, InitializationFlag initialization_flag, | 451 VariableKind kind, InitializationFlag initialization_flag, |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 // Construct a catch scope with a binding for the name. | 569 // Construct a catch scope with a binding for the name. |
| 554 Scope(Zone* zone, const AstRawString* catch_variable_name, | 570 Scope(Zone* zone, const AstRawString* catch_variable_name, |
| 555 Handle<ScopeInfo> scope_info); | 571 Handle<ScopeInfo> scope_info); |
| 556 | 572 |
| 557 void AddInnerScope(Scope* inner_scope) { | 573 void AddInnerScope(Scope* inner_scope) { |
| 558 inner_scope->sibling_ = inner_scope_; | 574 inner_scope->sibling_ = inner_scope_; |
| 559 inner_scope_ = inner_scope; | 575 inner_scope_ = inner_scope; |
| 560 inner_scope->outer_scope_ = this; | 576 inner_scope->outer_scope_ = this; |
| 561 } | 577 } |
| 562 | 578 |
| 563 void RemoveInnerScope(Scope* inner_scope) { | |
| 564 DCHECK_NOT_NULL(inner_scope); | |
| 565 if (inner_scope == inner_scope_) { | |
| 566 inner_scope_ = inner_scope_->sibling_; | |
| 567 return; | |
| 568 } | |
| 569 for (Scope* scope = inner_scope_; scope != nullptr; | |
| 570 scope = scope->sibling_) { | |
| 571 if (scope->sibling_ == inner_scope) { | |
| 572 scope->sibling_ = scope->sibling_->sibling_; | |
| 573 return; | |
| 574 } | |
| 575 } | |
| 576 } | |
| 577 | |
| 578 void SetDefaults(); | 579 void SetDefaults(); |
| 579 | 580 |
| 580 friend class DeclarationScope; | 581 friend class DeclarationScope; |
| 581 }; | 582 }; |
| 582 | 583 |
| 583 class DeclarationScope : public Scope { | 584 class DeclarationScope : public Scope { |
| 584 public: | 585 public: |
| 585 DeclarationScope(Zone* zone, Scope* outer_scope, ScopeType scope_type, | 586 DeclarationScope(Zone* zone, Scope* outer_scope, ScopeType scope_type, |
| 586 FunctionKind function_kind = kNormalFunction); | 587 FunctionKind function_kind = kNormalFunction); |
| 587 DeclarationScope(Zone* zone, ScopeType scope_type, | 588 DeclarationScope(Zone* zone, ScopeType scope_type, |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 void AllocateModuleVariables(); | 858 void AllocateModuleVariables(); |
| 858 | 859 |
| 859 private: | 860 private: |
| 860 ModuleDescriptor* module_descriptor_; | 861 ModuleDescriptor* module_descriptor_; |
| 861 }; | 862 }; |
| 862 | 863 |
| 863 } // namespace internal | 864 } // namespace internal |
| 864 } // namespace v8 | 865 } // namespace v8 |
| 865 | 866 |
| 866 #endif // V8_AST_SCOPES_H_ | 867 #endif // V8_AST_SCOPES_H_ |
| OLD | NEW |