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_SCOPES_H_ | 5 #ifndef V8_SCOPES_H_ |
6 #define V8_SCOPES_H_ | 6 #define V8_SCOPES_H_ |
7 | 7 |
8 #include "src/ast.h" | 8 #include "src/ast.h" |
9 #include "src/pending-compilation-error-handler.h" | 9 #include "src/pending-compilation-error-handler.h" |
10 #include "src/zone.h" | 10 #include "src/zone.h" |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 if (rest_index_ >= 0) return false; | 402 if (rest_index_ >= 0) return false; |
403 return true; | 403 return true; |
404 } | 404 } |
405 | 405 |
406 // The local variable 'arguments' if we need to allocate it; NULL otherwise. | 406 // The local variable 'arguments' if we need to allocate it; NULL otherwise. |
407 Variable* arguments() const { | 407 Variable* arguments() const { |
408 DCHECK(!is_arrow_scope() || arguments_ == nullptr); | 408 DCHECK(!is_arrow_scope() || arguments_ == nullptr); |
409 return arguments_; | 409 return arguments_; |
410 } | 410 } |
411 | 411 |
| 412 // A local variable to the [[HomeObject]] used by methods if we need to |
| 413 // allocate it; NULL otherwise. |
| 414 Variable* home_object_var() const { |
| 415 DCHECK(home_object_ == nullptr || |
| 416 (is_function_scope() && (IsConciseMethod(function_kind()) || |
| 417 IsAccessorFunction(function_kind()) || |
| 418 IsConstructor(function_kind())))); |
| 419 return home_object_; |
| 420 } |
| 421 |
412 // Declarations list. | 422 // Declarations list. |
413 ZoneList<Declaration*>* declarations() { return &decls_; } | 423 ZoneList<Declaration*>* declarations() { return &decls_; } |
414 | 424 |
415 // Inner scope list. | 425 // Inner scope list. |
416 ZoneList<Scope*>* inner_scopes() { return &inner_scopes_; } | 426 ZoneList<Scope*>* inner_scopes() { return &inner_scopes_; } |
417 | 427 |
418 // The scope immediately surrounding this scope, or NULL. | 428 // The scope immediately surrounding this scope, or NULL. |
419 Scope* outer_scope() const { return outer_scope_; } | 429 Scope* outer_scope() const { return outer_scope_; } |
420 | 430 |
421 // The ModuleDescriptor for this scope; only for module scopes. | 431 // The ModuleDescriptor for this scope; only for module scopes. |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 // Declarations. | 569 // Declarations. |
560 ZoneList<Declaration*> decls_; | 570 ZoneList<Declaration*> decls_; |
561 // Convenience variable. | 571 // Convenience variable. |
562 Variable* receiver_; | 572 Variable* receiver_; |
563 // Function variable, if any; function scopes only. | 573 // Function variable, if any; function scopes only. |
564 VariableDeclaration* function_; | 574 VariableDeclaration* function_; |
565 // new.target variable, function scopes only. | 575 // new.target variable, function scopes only. |
566 Variable* new_target_; | 576 Variable* new_target_; |
567 // Convenience variable; function scopes only. | 577 // Convenience variable; function scopes only. |
568 Variable* arguments_; | 578 Variable* arguments_; |
| 579 // Convenience variable; method scopes only. |
| 580 Variable* home_object_; |
569 // Module descriptor; module scopes only. | 581 // Module descriptor; module scopes only. |
570 ModuleDescriptor* module_descriptor_; | 582 ModuleDescriptor* module_descriptor_; |
571 | 583 |
572 // Illegal redeclaration. | 584 // Illegal redeclaration. |
573 Expression* illegal_redecl_; | 585 Expression* illegal_redecl_; |
574 | 586 |
575 // Scope-specific information computed during parsing. | 587 // Scope-specific information computed during parsing. |
576 // | 588 // |
577 // This scope is inside a 'with' of some outer scope. | 589 // This scope is inside a 'with' of some outer scope. |
578 bool scope_inside_with_; | 590 bool scope_inside_with_; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 PendingCompilationErrorHandler pending_error_handler_; | 764 PendingCompilationErrorHandler pending_error_handler_; |
753 | 765 |
754 // For tracking which classes are declared consecutively. Needed for strong | 766 // For tracking which classes are declared consecutively. Needed for strong |
755 // mode. | 767 // mode. |
756 int class_declaration_group_start_; | 768 int class_declaration_group_start_; |
757 }; | 769 }; |
758 | 770 |
759 } } // namespace v8::internal | 771 } } // namespace v8::internal |
760 | 772 |
761 #endif // V8_SCOPES_H_ | 773 #endif // V8_SCOPES_H_ |
OLD | NEW |