Changeset 57055 in webkit for trunk/JavaScriptCore/runtime
- Timestamp:
- Apr 3, 2010, 11:53:46 PM (15 years ago)
- Location:
- trunk/JavaScriptCore/runtime
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/InternalFunction.cpp
r51801 r57055 41 41 : JSObject(structure) 42 42 { 43 putDirect(globalData->propertyNames->name, jsString(globalData, name. ustring()), DontDelete | ReadOnly | DontEnum);43 putDirect(globalData->propertyNames->name, jsString(globalData, name.isNull() ? "" : name.ustring()), DontDelete | ReadOnly | DontEnum); 44 44 } 45 45 -
trunk/JavaScriptCore/runtime/JSString.h
r57019 r57055 117 117 , m_fiberCount(0) 118 118 { 119 ASSERT(!m_value.isNull()); 119 120 Heap::heap(this)->reportExtraMemoryCost(value.cost()); 120 121 } … … 127 128 , m_fiberCount(0) 128 129 { 130 ASSERT(!m_value.isNull()); 129 131 } 130 132 JSString(JSGlobalData* globalData, PassRefPtr<UString::Rep> value, HasOtherOwnerType) … … 134 136 , m_fiberCount(0) 135 137 { 138 ASSERT(!m_value.isNull()); 136 139 } 137 140 JSString(JSGlobalData* globalData, PassRefPtr<Rope> rope) … … 203 206 , m_fiberCount(0) 204 207 { 208 ASSERT(!m_value.isNull()); 205 209 // nasty hack because we can't union non-POD types 206 210 m_other.m_finalizerCallback = finalizer; -
trunk/JavaScriptCore/runtime/UString.cpp
r56864 r57055 59 59 60 60 // The null string is immutable, except for refCount. 61 UString::Rep* UString::s_nullRep;62 61 UString* UString::s_nullUString; 63 62 … … 68 67 UStringImpl::empty(); 69 68 70 UString::s_nullRep = new UStringImpl(0, 0, UStringImpl::ConstructStaticString);71 69 UString::s_nullUString = new UString; 72 70 } -
trunk/JavaScriptCore/runtime/UString.h
r56864 r57055 49 49 50 50 public: 51 UString() ;51 UString() {} 52 52 UString(const char*); // Constructor for null-terminated string. 53 53 UString(const char*, unsigned length); … … 63 63 UString(PlacementNewAdoptType) 64 64 : m_rep(PlacementNewAdopt) 65 {66 }67 68 ~UString()69 65 { 70 66 } … … 96 92 CString UTF8String(bool strict = false) const; 97 93 98 const UChar* data() const { return m_rep->characters(); } 99 100 bool isNull() const { return m_rep == s_nullRep; } 101 bool isEmpty() const { return !m_rep->length(); } 94 const UChar* data() const 95 { 96 if (!m_rep) 97 return 0; 98 return m_rep->characters(); 99 } 100 101 unsigned size() const 102 { 103 if (!m_rep) 104 return 0; 105 return m_rep->length(); 106 } 107 108 bool isNull() const { return !m_rep; } 109 bool isEmpty() const { return !m_rep || !m_rep->length(); } 102 110 103 111 bool is8Bit() const; 104 105 unsigned size() const { return m_rep->length(); }106 112 107 113 UChar operator[](unsigned pos) const; … … 132 138 : m_rep(r) 133 139 { 134 ASSERT(m_rep); 135 } 136 137 size_t cost() const { return m_rep->cost(); } 140 } 141 142 size_t cost() const 143 { 144 if (!m_rep) 145 return 0; 146 return m_rep->cost(); 147 } 138 148 139 149 private: 140 150 RefPtr<Rep> m_rep; 141 151 142 JS_EXPORTDATA static Rep* s_nullRep;143 152 static UString* s_nullUString; 144 153 … … 194 203 195 204 int compare(const UString&, const UString&); 196 197 inline UString::UString()198 : m_rep(s_nullRep)199 {200 }201 205 202 206 // Rule from ECMA 15.2 about what an array index is.
Note:
See TracChangeset
for help on using the changeset viewer.