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 void RemoveInnerScope(Scope* inner_scope) { | |
marja
2016/11/29 10:20:04
... add a return value here to tell whether inner_
bradn
2016/11/29 10:43:36
Done.
| |
427 DCHECK_NOT_NULL(inner_scope); | |
428 if (inner_scope == inner_scope_) { | |
429 inner_scope_ = inner_scope_->sibling_; | |
430 return; | |
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; | |
437 } | |
438 } | |
439 } | |
440 | |
426 protected: | 441 protected: |
427 explicit Scope(Zone* zone); | 442 explicit Scope(Zone* zone); |
428 | 443 |
429 void set_language_mode(LanguageMode language_mode) { | 444 void set_language_mode(LanguageMode language_mode) { |
430 is_strict_ = is_strict(language_mode); | 445 is_strict_ = is_strict(language_mode); |
431 } | 446 } |
432 | 447 |
433 private: | 448 private: |
434 Variable* Declare(Zone* zone, const AstRawString* name, VariableMode mode, | 449 Variable* Declare(Zone* zone, const AstRawString* name, VariableMode mode, |
435 VariableKind kind, InitializationFlag initialization_flag, | 450 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. | 568 // Construct a catch scope with a binding for the name. |
554 Scope(Zone* zone, const AstRawString* catch_variable_name, | 569 Scope(Zone* zone, const AstRawString* catch_variable_name, |
555 Handle<ScopeInfo> scope_info); | 570 Handle<ScopeInfo> scope_info); |
556 | 571 |
557 void AddInnerScope(Scope* inner_scope) { | 572 void AddInnerScope(Scope* inner_scope) { |
558 inner_scope->sibling_ = inner_scope_; | 573 inner_scope->sibling_ = inner_scope_; |
559 inner_scope_ = inner_scope; | 574 inner_scope_ = inner_scope; |
560 inner_scope->outer_scope_ = this; | 575 inner_scope->outer_scope_ = this; |
561 } | 576 } |
562 | 577 |
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(); | 578 void SetDefaults(); |
579 | 579 |
580 friend class DeclarationScope; | 580 friend class DeclarationScope; |
581 }; | 581 }; |
582 | 582 |
583 class DeclarationScope : public Scope { | 583 class DeclarationScope : public Scope { |
584 public: | 584 public: |
585 DeclarationScope(Zone* zone, Scope* outer_scope, ScopeType scope_type, | 585 DeclarationScope(Zone* zone, Scope* outer_scope, ScopeType scope_type, |
586 FunctionKind function_kind = kNormalFunction); | 586 FunctionKind function_kind = kNormalFunction); |
587 DeclarationScope(Zone* zone, ScopeType scope_type, | 587 DeclarationScope(Zone* zone, ScopeType scope_type, |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
857 void AllocateModuleVariables(); | 857 void AllocateModuleVariables(); |
858 | 858 |
859 private: | 859 private: |
860 ModuleDescriptor* module_descriptor_; | 860 ModuleDescriptor* module_descriptor_; |
861 }; | 861 }; |
862 | 862 |
863 } // namespace internal | 863 } // namespace internal |
864 } // namespace v8 | 864 } // namespace v8 |
865 | 865 |
866 #endif // V8_AST_SCOPES_H_ | 866 #endif // V8_AST_SCOPES_H_ |
OLD | NEW |