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_GLOBALS_H_ | 5 #ifndef V8_GLOBALS_H_ |
6 #define V8_GLOBALS_H_ | 6 #define V8_GLOBALS_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 (static_cast<uint64_t>(kHoleNanUpper32) << 32) | kHoleNanLower32; | 705 (static_cast<uint64_t>(kHoleNanUpper32) << 32) | kHoleNanLower32; |
706 | 706 |
707 | 707 |
708 // The order of this enum has to be kept in sync with the predicates below. | 708 // The order of this enum has to be kept in sync with the predicates below. |
709 enum VariableMode { | 709 enum VariableMode { |
710 // User declared variables: | 710 // User declared variables: |
711 VAR, // declared via 'var', and 'function' declarations | 711 VAR, // declared via 'var', and 'function' declarations |
712 | 712 |
713 CONST_LEGACY, // declared via legacy 'const' declarations | 713 CONST_LEGACY, // declared via legacy 'const' declarations |
714 | 714 |
715 LET, // declared via 'let' declarations (first lexical) | 715 LET, // declared via 'let' declarations |
716 | 716 |
717 CONST, // declared via 'const' declarations | 717 CONST, // declared via 'const' declarations |
718 | 718 |
719 MODULE, // declared via 'module' declaration (last lexical) | |
720 | |
721 // Variables introduced by the compiler: | 719 // Variables introduced by the compiler: |
722 INTERNAL, // like VAR, but not user-visible (may or may not | 720 INTERNAL, // like VAR, but not user-visible (may or may not |
723 // be in a context) | 721 // be in a context) |
724 | 722 |
725 TEMPORARY, // temporary variables (not user-visible), stack-allocated | 723 TEMPORARY, // temporary variables (not user-visible), stack-allocated |
726 // unless the scope as a whole has forced context allocation | 724 // unless the scope as a whole has forced context allocation |
727 | 725 |
728 DYNAMIC, // always require dynamic lookup (we don't know | 726 DYNAMIC, // always require dynamic lookup (we don't know |
729 // the declaration) | 727 // the declaration) |
730 | 728 |
731 DYNAMIC_GLOBAL, // requires dynamic lookup, but we know that the | 729 DYNAMIC_GLOBAL, // requires dynamic lookup, but we know that the |
732 // variable is global unless it has been shadowed | 730 // variable is global unless it has been shadowed |
733 // by an eval-introduced variable | 731 // by an eval-introduced variable |
734 | 732 |
735 DYNAMIC_LOCAL // requires dynamic lookup, but we know that the | 733 DYNAMIC_LOCAL // requires dynamic lookup, but we know that the |
736 // variable is local and where it is unless it | 734 // variable is local and where it is unless it |
737 // has been shadowed by an eval-introduced | 735 // has been shadowed by an eval-introduced |
738 // variable | 736 // variable |
739 }; | 737 }; |
740 | 738 |
741 | 739 |
742 inline bool IsDynamicVariableMode(VariableMode mode) { | 740 inline bool IsDynamicVariableMode(VariableMode mode) { |
743 return mode >= DYNAMIC && mode <= DYNAMIC_LOCAL; | 741 return mode >= DYNAMIC && mode <= DYNAMIC_LOCAL; |
744 } | 742 } |
745 | 743 |
746 | 744 |
747 inline bool IsDeclaredVariableMode(VariableMode mode) { | 745 inline bool IsDeclaredVariableMode(VariableMode mode) { |
748 return mode >= VAR && mode <= MODULE; | 746 return mode >= VAR && mode <= CONST; |
749 } | 747 } |
750 | 748 |
751 | 749 |
752 inline bool IsLexicalVariableMode(VariableMode mode) { | 750 inline bool IsLexicalVariableMode(VariableMode mode) { |
753 return mode >= LET && mode <= MODULE; | 751 return mode == LET || mode == CONST; |
754 } | 752 } |
755 | 753 |
756 | 754 |
757 inline bool IsImmutableVariableMode(VariableMode mode) { | 755 inline bool IsImmutableVariableMode(VariableMode mode) { |
758 return (mode >= CONST && mode <= MODULE) || mode == CONST_LEGACY; | 756 return mode == CONST || mode == CONST_LEGACY; |
759 } | 757 } |
760 | 758 |
761 | 759 |
762 // ES6 Draft Rev3 10.2 specifies declarative environment records with mutable | 760 // ES6 Draft Rev3 10.2 specifies declarative environment records with mutable |
763 // and immutable bindings that can be in two states: initialized and | 761 // and immutable bindings that can be in two states: initialized and |
764 // uninitialized. In ES5 only immutable bindings have these two states. When | 762 // uninitialized. In ES5 only immutable bindings have these two states. When |
765 // accessing a binding, it needs to be checked for initialization. However in | 763 // accessing a binding, it needs to be checked for initialization. However in |
766 // the following cases the binding is initialized immediately after creation | 764 // the following cases the binding is initialized immediately after creation |
767 // so the initialization check can always be skipped: | 765 // so the initialization check can always be skipped: |
768 // 1. Var declared local variables. | 766 // 1. Var declared local variables. |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 DCHECK(IsValidFunctionKind(kind)); | 887 DCHECK(IsValidFunctionKind(kind)); |
890 return kind & | 888 return kind & |
891 (FunctionKind::kBaseConstructor | FunctionKind::kSubclassConstructor | | 889 (FunctionKind::kBaseConstructor | FunctionKind::kSubclassConstructor | |
892 FunctionKind::kDefaultConstructor); | 890 FunctionKind::kDefaultConstructor); |
893 } | 891 } |
894 } } // namespace v8::internal | 892 } } // namespace v8::internal |
895 | 893 |
896 namespace i = v8::internal; | 894 namespace i = v8::internal; |
897 | 895 |
898 #endif // V8_GLOBALS_H_ | 896 #endif // V8_GLOBALS_H_ |
OLD | NEW |