Changeset 33979 in webkit for trunk/JavaScriptCore/kjs/SymbolTable.h
- Timestamp:
- May 21, 2008, 6:20:45 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/SymbolTable.h
r32609 r33979 30 30 #define SymbolTable_h 31 31 32 #include "object.h" 32 33 #include "ustring.h" 33 34 #include <wtf/AlwaysInline.h> … … 40 41 }; 41 42 42 static ALWAYS_INLINE size_t missingSymbolMarker() { return std::numeric_limits<size_t>::max(); }43 static ALWAYS_INLINE int missingSymbolMarker() { return std::numeric_limits<int>::max(); } 43 44 44 struct SymbolTableIndexHashTraits : HashTraits<size_t> { 45 static const bool emptyValueIsZero = false; 46 static size_t emptyValue() { return missingSymbolMarker(); } 45 struct SymbolTableEntry { 46 SymbolTableEntry() 47 : rawValue(0) 48 { 49 } 50 51 SymbolTableEntry(int index) 52 { 53 rawValue = index & ~0x80000000 & ~0x40000000; 54 } 55 56 SymbolTableEntry(int index, unsigned attributes) 57 { 58 rawValue = index; 59 60 if (!(attributes & ReadOnly)) 61 rawValue &= ~0x80000000; 62 63 if (!(attributes & DontEnum)) 64 rawValue &= ~0x40000000; 65 } 66 67 bool isEmpty() const 68 { 69 return rawValue == 0; 70 } 71 72 int getIndex() const 73 { 74 // Every register index we store is negative, so this bit twiddling works correctly 75 return rawValue | 0x80000000 | 0x40000000; 76 } 77 78 unsigned getAttributes() const 79 { 80 unsigned attributes = 0; 81 82 if (rawValue & 0x80000000) 83 attributes |= ReadOnly; 84 85 if (rawValue & 0x40000000) 86 attributes |= DontEnum; 87 88 return attributes; 89 } 90 91 void setAttributes(unsigned attributes) 92 { 93 rawValue = getIndex(); 94 95 if (!(attributes & ReadOnly)) 96 rawValue &= ~0x80000000; 97 98 if (!(attributes & DontEnum)) 99 rawValue &= ~0x40000000; 100 } 101 102 bool isReadOnly() const 103 { 104 return rawValue & 0x80000000; 105 } 106 107 int rawValue; 47 108 }; 48 109 49 typedef HashMap<RefPtr<UString::Rep>, size_t, IdentifierRepHash, HashTraits<RefPtr<UString::Rep> >, SymbolTableIndexHashTraits> SymbolTable; 110 struct SymbolTableIndexHashTraits { 111 typedef SymbolTableEntry TraitType; 112 static SymbolTableEntry emptyValue() { return SymbolTableEntry(); } 113 static const bool emptyValueIsZero = false; 114 static const bool needsDestruction = false; 115 }; 116 117 typedef HashMap<RefPtr<UString::Rep>, SymbolTableEntry, IdentifierRepHash, HashTraits<RefPtr<UString::Rep> >, SymbolTableIndexHashTraits> SymbolTable; 50 118 51 119 } // namespace KJS
Note:
See TracChangeset
for help on using the changeset viewer.