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/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/base/hashmap.h" | 9 #include "src/base/hashmap.h" |
10 #include "src/globals.h" | 10 #include "src/globals.h" |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 | 439 |
440 // Check that all Scopes in the scope tree use the same Zone. | 440 // Check that all Scopes in the scope tree use the same Zone. |
441 void CheckZones(); | 441 void CheckZones(); |
442 #endif | 442 #endif |
443 | 443 |
444 // Retrieve `IsSimpleParameterList` of current or outer function. | 444 // Retrieve `IsSimpleParameterList` of current or outer function. |
445 bool HasSimpleParameters(); | 445 bool HasSimpleParameters(); |
446 void set_is_debug_evaluate_scope() { is_debug_evaluate_scope_ = true; } | 446 void set_is_debug_evaluate_scope() { is_debug_evaluate_scope_ = true; } |
447 | 447 |
448 protected: | 448 protected: |
| 449 // Creates a script scope. |
| 450 explicit Scope(Zone* zone); |
| 451 |
449 void set_language_mode(LanguageMode language_mode) { | 452 void set_language_mode(LanguageMode language_mode) { |
450 is_strict_ = is_strict(language_mode); | 453 is_strict_ = is_strict(language_mode); |
451 } | 454 } |
452 | 455 |
453 private: | 456 private: |
454 Variable* Declare(Zone* zone, Scope* scope, const AstRawString* name, | 457 Variable* Declare(Zone* zone, Scope* scope, const AstRawString* name, |
455 VariableMode mode, Variable::Kind kind, | 458 VariableMode mode, Variable::Kind kind, |
456 InitializationFlag initialization_flag, | 459 InitializationFlag initialization_flag, |
457 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned) { | 460 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned) { |
458 bool added; | 461 bool added; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 | 658 |
656 friend class DeclarationScope; | 659 friend class DeclarationScope; |
657 }; | 660 }; |
658 | 661 |
659 class DeclarationScope : public Scope { | 662 class DeclarationScope : public Scope { |
660 public: | 663 public: |
661 DeclarationScope(Zone* zone, Scope* outer_scope, ScopeType scope_type, | 664 DeclarationScope(Zone* zone, Scope* outer_scope, ScopeType scope_type, |
662 FunctionKind function_kind = kNormalFunction); | 665 FunctionKind function_kind = kNormalFunction); |
663 DeclarationScope(Zone* zone, Scope* inner_scope, ScopeType scope_type, | 666 DeclarationScope(Zone* zone, Scope* inner_scope, ScopeType scope_type, |
664 Handle<ScopeInfo> scope_info); | 667 Handle<ScopeInfo> scope_info); |
| 668 // Creates a script scope. |
| 669 explicit DeclarationScope(Zone* zone); |
665 | 670 |
666 bool IsDeclaredParameter(const AstRawString* name) { | 671 bool IsDeclaredParameter(const AstRawString* name) { |
667 // If IsSimpleParameterList is false, duplicate parameters are not allowed, | 672 // If IsSimpleParameterList is false, duplicate parameters are not allowed, |
668 // however `arguments` may be allowed if function is not strict code. Thus, | 673 // however `arguments` may be allowed if function is not strict code. Thus, |
669 // the assumptions explained above do not hold. | 674 // the assumptions explained above do not hold. |
670 return params_.Contains(variables_.Lookup(name)); | 675 return params_.Contains(variables_.Lookup(name)); |
671 } | 676 } |
672 | 677 |
673 FunctionKind function_kind() const { return function_kind_; } | 678 FunctionKind function_kind() const { return function_kind_; } |
674 | 679 |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 void AllocateModuleVariables(); | 914 void AllocateModuleVariables(); |
910 | 915 |
911 private: | 916 private: |
912 ModuleDescriptor* module_descriptor_; | 917 ModuleDescriptor* module_descriptor_; |
913 }; | 918 }; |
914 | 919 |
915 } // namespace internal | 920 } // namespace internal |
916 } // namespace v8 | 921 } // namespace v8 |
917 | 922 |
918 #endif // V8_AST_SCOPES_H_ | 923 #endif // V8_AST_SCOPES_H_ |
OLD | NEW |