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 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 enum Signedness { kSigned, kUnsigned }; | 790 enum Signedness { kSigned, kUnsigned }; |
791 | 791 |
792 | 792 |
793 enum FunctionKind { | 793 enum FunctionKind { |
794 kNormalFunction = 0, | 794 kNormalFunction = 0, |
795 kArrowFunction = 1, | 795 kArrowFunction = 1, |
796 kGeneratorFunction = 2, | 796 kGeneratorFunction = 2, |
797 kConciseMethod = 4, | 797 kConciseMethod = 4, |
798 kConciseGeneratorMethod = kGeneratorFunction | kConciseMethod, | 798 kConciseGeneratorMethod = kGeneratorFunction | kConciseMethod, |
799 kDefaultConstructor = 8, | 799 kDefaultConstructor = 8, |
800 kSubclassConstructor = 16 | 800 kBaseConstructor = 16, |
| 801 kSubclassConstructor = 32, |
801 }; | 802 }; |
802 | 803 |
803 | 804 |
804 inline bool IsValidFunctionKind(FunctionKind kind) { | 805 inline bool IsValidFunctionKind(FunctionKind kind) { |
805 return kind == FunctionKind::kNormalFunction || | 806 return kind == FunctionKind::kNormalFunction || |
806 kind == FunctionKind::kArrowFunction || | 807 kind == FunctionKind::kArrowFunction || |
807 kind == FunctionKind::kGeneratorFunction || | 808 kind == FunctionKind::kGeneratorFunction || |
808 kind == FunctionKind::kConciseMethod || | 809 kind == FunctionKind::kConciseMethod || |
809 kind == FunctionKind::kConciseGeneratorMethod || | 810 kind == FunctionKind::kConciseGeneratorMethod || |
810 kind == FunctionKind::kDefaultConstructor || | 811 kind == FunctionKind::kDefaultConstructor || |
| 812 kind == FunctionKind::kBaseConstructor || |
811 kind == FunctionKind::kSubclassConstructor; | 813 kind == FunctionKind::kSubclassConstructor; |
812 } | 814 } |
813 | 815 |
814 | 816 |
815 inline bool IsArrowFunction(FunctionKind kind) { | 817 inline bool IsArrowFunction(FunctionKind kind) { |
816 DCHECK(IsValidFunctionKind(kind)); | 818 DCHECK(IsValidFunctionKind(kind)); |
817 return kind & FunctionKind::kArrowFunction; | 819 return kind & FunctionKind::kArrowFunction; |
818 } | 820 } |
819 | 821 |
820 | 822 |
821 inline bool IsGeneratorFunction(FunctionKind kind) { | 823 inline bool IsGeneratorFunction(FunctionKind kind) { |
822 DCHECK(IsValidFunctionKind(kind)); | 824 DCHECK(IsValidFunctionKind(kind)); |
823 return kind & FunctionKind::kGeneratorFunction; | 825 return kind & FunctionKind::kGeneratorFunction; |
824 } | 826 } |
825 | 827 |
826 | 828 |
827 inline bool IsConciseMethod(FunctionKind kind) { | 829 inline bool IsConciseMethod(FunctionKind kind) { |
828 DCHECK(IsValidFunctionKind(kind)); | 830 DCHECK(IsValidFunctionKind(kind)); |
829 return kind & FunctionKind::kConciseMethod; | 831 return kind & FunctionKind::kConciseMethod; |
830 } | 832 } |
831 | 833 |
832 | 834 |
833 inline bool IsDefaultConstructor(FunctionKind kind) { | 835 inline bool IsDefaultConstructor(FunctionKind kind) { |
834 DCHECK(IsValidFunctionKind(kind)); | 836 DCHECK(IsValidFunctionKind(kind)); |
835 return kind & FunctionKind::kDefaultConstructor; | 837 return kind & FunctionKind::kDefaultConstructor; |
836 } | 838 } |
837 | 839 |
| 840 |
| 841 inline bool IsBaseConstructor(FunctionKind kind) { |
| 842 DCHECK(IsValidFunctionKind(kind)); |
| 843 return kind & FunctionKind::kBaseConstructor; |
| 844 } |
| 845 |
| 846 |
838 inline bool IsSubclassConstructor(FunctionKind kind) { | 847 inline bool IsSubclassConstructor(FunctionKind kind) { |
839 DCHECK(IsValidFunctionKind(kind)); | 848 DCHECK(IsValidFunctionKind(kind)); |
840 return kind & FunctionKind::kSubclassConstructor; | 849 return kind & FunctionKind::kSubclassConstructor; |
841 } | 850 } |
| 851 |
| 852 |
| 853 inline bool IsConstructor(FunctionKind kind) { |
| 854 DCHECK(IsValidFunctionKind(kind)); |
| 855 return kind & |
| 856 (FunctionKind::kBaseConstructor | FunctionKind::kSubclassConstructor | |
| 857 FunctionKind::kDefaultConstructor); |
| 858 } |
842 } } // namespace v8::internal | 859 } } // namespace v8::internal |
843 | 860 |
844 namespace i = v8::internal; | 861 namespace i = v8::internal; |
845 | 862 |
846 #endif // V8_GLOBALS_H_ | 863 #endif // V8_GLOBALS_H_ |
OLD | NEW |