Changeset 201328 in webkit for trunk/Source/JavaScriptCore/parser/SourceCodeKey.h
- Timestamp:
- May 24, 2016, 5:04:35 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/parser/SourceCodeKey.h
r194017 r201328 34 34 namespace JSC { 35 35 36 enum class SourceCodeType { EvalType, ProgramType, FunctionType, ModuleType }; 37 38 class SourceCodeFlags { 39 public: 40 SourceCodeFlags() = default; 41 42 SourceCodeFlags(SourceCodeType codeType, JSParserBuiltinMode builtinMode, JSParserStrictMode strictMode, DerivedContextType derivedContextType, EvalContextType evalContextType, bool isArrowFunctionContext) 43 : m_flags( 44 (static_cast<unsigned>(isArrowFunctionContext) << 7) | 45 (static_cast<unsigned>(evalContextType) << 6) | 46 (static_cast<unsigned>(derivedContextType) << 4) | 47 (static_cast<unsigned>(codeType) << 2) | 48 (static_cast<unsigned>(builtinMode) << 1) | 49 (static_cast<unsigned>(strictMode)) 50 ) 51 { 52 } 53 54 inline bool operator==(const SourceCodeFlags& rhs) const 55 { 56 return m_flags == rhs.m_flags; 57 } 58 59 private: 60 unsigned m_flags { 0 }; 61 }; 62 36 63 class SourceCodeKey { 37 64 public: 38 enum CodeType { EvalType, ProgramType, FunctionType, ModuleType };39 40 65 SourceCodeKey() 41 66 { 42 67 } 43 68 44 SourceCodeKey(const SourceCode& sourceCode, const String& name, CodeType codeType, JSParserBuiltinMode builtinMode, JSParserStrictMode strictMode, ThisTDZMode thisTDZMode = ThisTDZMode::CheckIfNeeded)69 SourceCodeKey(const SourceCode& sourceCode, const String& name, SourceCodeType codeType, JSParserBuiltinMode builtinMode, JSParserStrictMode strictMode, DerivedContextType derivedContextType, EvalContextType evalContextType, bool isArrowFunctionContext) 45 70 : m_sourceCode(sourceCode) 46 71 , m_name(name) 47 , m_flags( (static_cast<unsigned>(codeType) << 3) | (static_cast<unsigned>(builtinMode) << 2) | (static_cast<unsigned>(strictMode) << 1) | static_cast<unsigned>(thisTDZMode))72 , m_flags(codeType, builtinMode, strictMode, derivedContextType, evalContextType, isArrowFunctionContext) 48 73 , m_hash(sourceCode.hash()) 49 74 { … … 76 101 } 77 102 103 struct Hash { 104 static unsigned hash(const SourceCodeKey& key) { return key.hash(); } 105 static bool equal(const SourceCodeKey& a, const SourceCodeKey& b) { return a == b; } 106 static const bool safeToCompareToEmptyOrDeleted = false; 107 }; 108 109 struct HashTraits : SimpleClassHashTraits<SourceCodeKey> { 110 static const bool hasIsEmptyValueFunction = true; 111 static bool isEmptyValue(const SourceCodeKey& key) { return key.isNull(); } 112 }; 113 78 114 private: 79 115 SourceCode m_sourceCode; 80 116 String m_name; 81 unsignedm_flags;117 SourceCodeFlags m_flags; 82 118 unsigned m_hash; 83 };84 85 struct SourceCodeKeyHash {86 static unsigned hash(const SourceCodeKey& key) { return key.hash(); }87 static bool equal(const SourceCodeKey& a, const SourceCodeKey& b) { return a == b; }88 static const bool safeToCompareToEmptyOrDeleted = false;89 };90 91 struct SourceCodeKeyHashTraits : SimpleClassHashTraits<SourceCodeKey> {92 static const bool hasIsEmptyValueFunction = true;93 static bool isEmptyValue(const SourceCodeKey& sourceCodeKey) { return sourceCodeKey.isNull(); }94 119 }; 95 120
Note:
See TracChangeset
for help on using the changeset viewer.