Changeset 65104 in webkit for trunk/JavaScriptCore/runtime/Identifier.h
- Timestamp:
- Aug 10, 2010, 5:16:38 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/Identifier.h
r60762 r65104 35 35 Identifier() { } 36 36 37 Identifier(ExecState* exec, const char* s) : _ustring(add(exec, s)) { } // Only to be used with string literals.38 Identifier(ExecState* exec, const UChar* s, int length) : _ustring(add(exec, s, length)) { }39 Identifier(ExecState* exec, UString::Rep* rep) : _ustring(add(exec, rep)) { }40 Identifier(ExecState* exec, const UString& s) : _ustring(add(exec, s.rep())) { }37 Identifier(ExecState* exec, const char* s) : m_string(add(exec, s)) { } // Only to be used with string literals. 38 Identifier(ExecState* exec, const UChar* s, int length) : m_string(add(exec, s, length)) { } 39 Identifier(ExecState* exec, StringImpl* rep) : m_string(add(exec, rep)) { } 40 Identifier(ExecState* exec, const UString& s) : m_string(add(exec, s.impl())) { } 41 41 42 Identifier(JSGlobalData* globalData, const char* s) : _ustring(add(globalData, s)) { } // Only to be used with string literals.43 Identifier(JSGlobalData* globalData, const UChar* s, int length) : _ustring(add(globalData, s, length)) { }44 Identifier(JSGlobalData* globalData, UString::Rep* rep) : _ustring(add(globalData, rep)) { }45 Identifier(JSGlobalData* globalData, const UString& s) : _ustring(add(globalData, s.rep())) { }42 Identifier(JSGlobalData* globalData, const char* s) : m_string(add(globalData, s)) { } // Only to be used with string literals. 43 Identifier(JSGlobalData* globalData, const UChar* s, int length) : m_string(add(globalData, s, length)) { } 44 Identifier(JSGlobalData* globalData, StringImpl* rep) : m_string(add(globalData, rep)) { } 45 Identifier(JSGlobalData* globalData, const UString& s) : m_string(add(globalData, s.impl())) { } 46 46 47 47 // Special constructor for cases where we overwrite an object in place. 48 Identifier(PlacementNewAdoptType) : _ustring(PlacementNewAdopt) { }48 Identifier(PlacementNewAdoptType) : m_string(PlacementNewAdopt) { } 49 49 50 const UString& ustring() const { return _ustring; } 50 const UString& ustring() const { return m_string; } 51 StringImpl* impl() const { return m_string.impl(); } 51 52 52 const UChar* data() const { return _ustring.data(); }53 int size() const { return _ustring.size(); }53 const UChar* data() const { return m_string.data(); } 54 int size() const { return m_string.size(); } 54 55 55 const char* ascii() const { return _ustring.ascii(); }56 const char* ascii() const { return m_string.ascii(); } 56 57 57 58 static Identifier from(ExecState* exec, unsigned y); … … 62 63 static Identifier from(JSGlobalData*, double y); 63 64 64 bool isNull() const { return _ustring.isNull(); }65 bool isEmpty() const { return _ustring.isEmpty(); }65 bool isNull() const { return m_string.isNull(); } 66 bool isEmpty() const { return m_string.isEmpty(); } 66 67 67 uint32_t toUInt32(bool* ok) const { return _ustring.toUInt32(ok); }68 uint32_t toUInt32(bool* ok, bool tolerateEmptyString) const { return _ustring.toUInt32(ok, tolerateEmptyString); };69 uint32_t toStrictUInt32(bool* ok) const { return _ustring.toStrictUInt32(ok); }70 unsigned toArrayIndex(bool* ok) const { return _ustring.toArrayIndex(ok); }71 double toDouble() const { return _ustring.toDouble(); }68 uint32_t toUInt32(bool* ok) const { return m_string.toUInt32(ok); } 69 uint32_t toUInt32(bool* ok, bool tolerateEmptyString) const { return m_string.toUInt32(ok, tolerateEmptyString); }; 70 uint32_t toStrictUInt32(bool* ok) const { return m_string.toStrictUInt32(ok); } 71 unsigned toArrayIndex(bool* ok) const { return m_string.toArrayIndex(ok); } 72 double toDouble() const { return m_string.toDouble(); } 72 73 73 74 friend bool operator==(const Identifier&, const Identifier&); … … 77 78 friend bool operator!=(const Identifier&, const char*); 78 79 79 static bool equal(const UString::Rep*, const char*);80 static bool equal(const UString::Rep*, const UChar*, unsigned length);81 static bool equal(const UString::Rep* a, const UString::Rep* b) { return ::equal(a, b); }80 static bool equal(const StringImpl*, const char*); 81 static bool equal(const StringImpl*, const UChar*, unsigned length); 82 static bool equal(const StringImpl* a, const StringImpl* b) { return ::equal(a, b); } 82 83 83 static PassRefPtr< UString::Rep> add(ExecState*, const char*); // Only to be used with string literals.84 static PassRefPtr< UString::Rep> add(JSGlobalData*, const char*); // Only to be used with string literals.84 static PassRefPtr<StringImpl> add(ExecState*, const char*); // Only to be used with string literals. 85 static PassRefPtr<StringImpl> add(JSGlobalData*, const char*); // Only to be used with string literals. 85 86 86 87 private: 87 UString _ustring;88 UString m_string; 88 89 89 static bool equal(const Identifier& a, const Identifier& b) { return a. _ustring.rep() == b._ustring.rep(); }90 static bool equal(const Identifier& a, const char* b) { return equal(a. _ustring.rep(), b); }90 static bool equal(const Identifier& a, const Identifier& b) { return a.m_string.impl() == b.m_string.impl(); } 91 static bool equal(const Identifier& a, const char* b) { return equal(a.m_string.impl(), b); } 91 92 92 static PassRefPtr< UString::Rep> add(ExecState*, const UChar*, int length);93 static PassRefPtr< UString::Rep> add(JSGlobalData*, const UChar*, int length);93 static PassRefPtr<StringImpl> add(ExecState*, const UChar*, int length); 94 static PassRefPtr<StringImpl> add(JSGlobalData*, const UChar*, int length); 94 95 95 static PassRefPtr< UString::Rep> add(ExecState* exec, UString::Rep* r)96 static PassRefPtr<StringImpl> add(ExecState* exec, StringImpl* r) 96 97 { 97 98 #ifndef NDEBUG … … 102 103 return addSlowCase(exec, r); 103 104 } 104 static PassRefPtr< UString::Rep> add(JSGlobalData* globalData, UString::Rep* r)105 static PassRefPtr<StringImpl> add(JSGlobalData* globalData, StringImpl* r) 105 106 { 106 107 #ifndef NDEBUG … … 112 113 } 113 114 114 static PassRefPtr< UString::Rep> addSlowCase(ExecState*, UString::Rep* r);115 static PassRefPtr< UString::Rep> addSlowCase(JSGlobalData*, UString::Rep* r);115 static PassRefPtr<StringImpl> addSlowCase(ExecState*, StringImpl* r); 116 static PassRefPtr<StringImpl> addSlowCase(JSGlobalData*, StringImpl* r); 116 117 117 118 static void checkCurrentIdentifierTable(ExecState*);
Note:
See TracChangeset
for help on using the changeset viewer.