Changeset 233860 in webkit for trunk/Source/JavaScriptCore/parser/ParserModes.h
- Timestamp:
- Jul 16, 2018, 12:49:11 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/parser/ParserModes.h
r233855 r233860 43 43 enum class FunctionMode { FunctionExpression, FunctionDeclaration, MethodDefinition }; 44 44 45 enum class SourceParseMode : uint32_t { 46 NormalFunctionMode = 0b00000000000000000000000000000001, 47 GeneratorBodyMode = 0b00000000000000000000000000000010, 48 GeneratorWrapperFunctionMode = 0b00000000000000000000000000000100, 49 GetterMode = 0b00000000000000000000000000001000, 50 SetterMode = 0b00000000000000000000000000010000, 51 MethodMode = 0b00000000000000000000000000100000, 52 ArrowFunctionMode = 0b00000000000000000000000001000000, 53 AsyncFunctionBodyMode = 0b00000000000000000000000010000000, 54 AsyncArrowFunctionBodyMode = 0b00000000000000000000000100000000, 55 AsyncFunctionMode = 0b00000000000000000000001000000000, 56 AsyncMethodMode = 0b00000000000000000000010000000000, 57 AsyncArrowFunctionMode = 0b00000000000000000000100000000000, 58 ProgramMode = 0b00000000000000000001000000000000, 59 ModuleAnalyzeMode = 0b00000000000000000010000000000000, 60 ModuleEvaluateMode = 0b00000000000000000100000000000000, 61 AsyncGeneratorBodyMode = 0b00000000000000001000000000000000, 62 AsyncGeneratorWrapperFunctionMode = 0b00000000000000010000000000000000, 63 AsyncGeneratorWrapperMethodMode = 0b00000000000000100000000000000000, 64 GeneratorWrapperMethodMode = 0b00000000000001000000000000000000, 45 // Keep it less than 32, it means this should be within 5 bits. 46 enum class SourceParseMode : uint8_t { 47 NormalFunctionMode = 0, 48 GeneratorBodyMode = 1, 49 GeneratorWrapperFunctionMode = 2, 50 GetterMode = 3, 51 SetterMode = 4, 52 MethodMode = 5, 53 ArrowFunctionMode = 6, 54 AsyncFunctionBodyMode = 7, 55 AsyncArrowFunctionBodyMode = 8, 56 AsyncFunctionMode = 9, 57 AsyncMethodMode = 10, 58 AsyncArrowFunctionMode = 11, 59 ProgramMode = 12, 60 ModuleAnalyzeMode = 13, 61 ModuleEvaluateMode = 14, 62 AsyncGeneratorBodyMode = 15, 63 AsyncGeneratorWrapperFunctionMode = 16, 64 AsyncGeneratorWrapperMethodMode = 17, 65 GeneratorWrapperMethodMode = 18, 65 66 }; 66 67 … … 68 69 public: 69 70 template<typename... Modes> 70 SourceParseModeSet(Modes... args)71 constexpr SourceParseModeSet(Modes... args) 71 72 : m_mask(mergeSourceParseModes(args...)) 72 73 { 73 74 } 74 75 75 ALWAYS_INLINE bool contains(SourceParseMode mode)76 ALWAYS_INLINE constexpr bool contains(SourceParseMode mode) 76 77 { 77 return static_cast<unsigned>(mode) & m_mask;78 return (1U << static_cast<unsigned>(mode)) & m_mask; 78 79 } 79 80 80 81 private: 81 ALWAYS_INLINE static unsigned mergeSourceParseModes(SourceParseMode mode)82 ALWAYS_INLINE static constexpr unsigned mergeSourceParseModes(SourceParseMode mode) 82 83 { 83 return static_cast<unsigned>(mode);84 return (1U << static_cast<unsigned>(mode)); 84 85 } 85 86 86 87 template<typename... Rest> 87 ALWAYS_INLINE static unsigned mergeSourceParseModes(SourceParseMode mode, Rest... rest)88 ALWAYS_INLINE static constexpr unsigned mergeSourceParseModes(SourceParseMode mode, Rest... rest) 88 89 { 89 return static_cast<unsigned>(mode) | mergeSourceParseModes(rest...);90 return (1U << static_cast<unsigned>(mode)) | mergeSourceParseModes(rest...); 90 91 } 91 92
Note:
See TracChangeset
for help on using the changeset viewer.