Changeset 39769 in webkit for trunk/JavaScriptCore/runtime/JSCell.h
- Timestamp:
- Jan 9, 2009, 4:14:25 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/JSCell.h
r39670 r39769 24 24 #define JSCell_h 25 25 26 #include <wtf/Noncopyable.h> 26 27 #include "Structure.h" 27 28 #include "JSValue.h" … … 31 32 namespace JSC { 32 33 33 class JSCell : public JSValue {34 class JSCell : Noncopyable { 34 35 friend class JIT; 35 36 friend class GetterSetter; … … 39 40 friend class JSPropertyNameIterator; 40 41 friend class JSString; 41 friend class JSValue ;42 friend class JSValuePtr; 42 43 friend class Interpreter; 43 44 … … 113 114 inline JSCell* asCell(JSValuePtr value) 114 115 { 115 ASSERT(!JSImmediate::isImmediate(value));116 116 return value->asCell(); 117 117 } … … 156 156 } 157 157 158 ALWAYS_INLINE JSCell* JSValue ::asCell() const158 ALWAYS_INLINE JSCell* JSValuePtr::asCell() const 159 159 { 160 160 ASSERT(!JSImmediate::isImmediate(asValue())); 161 return const_cast<JSCell*>(reinterpret_cast<const JSCell*>(this));161 return m_ptr; 162 162 } 163 163 … … 173 173 // --- JSValue inlines ---------------------------- 174 174 175 inline bool JSValue ::isNumber() const175 inline bool JSValuePtr::isNumber() const 176 176 { 177 177 return JSImmediate::isNumber(asValue()) || (!JSImmediate::isImmediate(asValue()) && asCell()->isNumber()); 178 178 } 179 179 180 inline bool JSValue ::isString() const180 inline bool JSValuePtr::isString() const 181 181 { 182 182 return !JSImmediate::isImmediate(asValue()) && asCell()->isString(); 183 183 } 184 184 185 inline bool JSValue ::isGetterSetter() const185 inline bool JSValuePtr::isGetterSetter() const 186 186 { 187 187 return !JSImmediate::isImmediate(asValue()) && asCell()->isGetterSetter(); 188 188 } 189 189 190 inline bool JSValue ::isObject() const190 inline bool JSValuePtr::isObject() const 191 191 { 192 192 return !JSImmediate::isImmediate(asValue()) && asCell()->isObject(); 193 193 } 194 194 195 inline double JSValue ::getNumber() const195 inline double JSValuePtr::getNumber() const 196 196 { 197 197 return JSImmediate::isImmediate(asValue()) ? JSImmediate::toDouble(asValue()) : asCell()->getNumber(); 198 198 } 199 199 200 inline bool JSValue ::getString(UString& s) const200 inline bool JSValuePtr::getString(UString& s) const 201 201 { 202 202 return !JSImmediate::isImmediate(asValue()) && asCell()->getString(s); 203 203 } 204 204 205 inline UString JSValue ::getString() const205 inline UString JSValuePtr::getString() const 206 206 { 207 207 return JSImmediate::isImmediate(asValue()) ? UString() : asCell()->getString(); 208 208 } 209 209 210 inline JSObject* JSValue ::getObject() const210 inline JSObject* JSValuePtr::getObject() const 211 211 { 212 212 return JSImmediate::isImmediate(asValue()) ? 0 : asCell()->getObject(); 213 213 } 214 214 215 inline CallType JSValue ::getCallData(CallData& callData)215 inline CallType JSValuePtr::getCallData(CallData& callData) 216 216 { 217 217 return JSImmediate::isImmediate(asValue()) ? CallTypeNone : asCell()->getCallData(callData); 218 218 } 219 219 220 inline ConstructType JSValue ::getConstructData(ConstructData& constructData)220 inline ConstructType JSValuePtr::getConstructData(ConstructData& constructData) 221 221 { 222 222 return JSImmediate::isImmediate(asValue()) ? ConstructTypeNone : asCell()->getConstructData(constructData); 223 223 } 224 224 225 ALWAYS_INLINE bool JSValue ::getUInt32(uint32_t& v) const225 ALWAYS_INLINE bool JSValuePtr::getUInt32(uint32_t& v) const 226 226 { 227 227 return JSImmediate::isImmediate(asValue()) ? JSImmediate::getUInt32(asValue(), v) : asCell()->getUInt32(v); 228 228 } 229 229 230 ALWAYS_INLINE bool JSValue ::getTruncatedInt32(int32_t& v) const230 ALWAYS_INLINE bool JSValuePtr::getTruncatedInt32(int32_t& v) const 231 231 { 232 232 return JSImmediate::isImmediate(asValue()) ? JSImmediate::getTruncatedInt32(asValue(), v) : asCell()->getTruncatedInt32(v); 233 233 } 234 234 235 inline bool JSValue ::getTruncatedUInt32(uint32_t& v) const235 inline bool JSValuePtr::getTruncatedUInt32(uint32_t& v) const 236 236 { 237 237 return JSImmediate::isImmediate(asValue()) ? JSImmediate::getTruncatedUInt32(asValue(), v) : asCell()->getTruncatedUInt32(v); 238 238 } 239 239 240 inline void JSValue ::mark()240 inline void JSValuePtr::mark() 241 241 { 242 242 asCell()->mark(); // callers should check !marked() before calling mark(), so this should only be called with cells 243 243 } 244 244 245 inline bool JSValue ::marked() const245 inline bool JSValuePtr::marked() const 246 246 { 247 247 return JSImmediate::isImmediate(asValue()) || asCell()->marked(); 248 248 } 249 249 250 inline JSValuePtr JSValue ::toPrimitive(ExecState* exec, PreferredPrimitiveType preferredType) const250 inline JSValuePtr JSValuePtr::toPrimitive(ExecState* exec, PreferredPrimitiveType preferredType) const 251 251 { 252 252 return JSImmediate::isImmediate(asValue()) ? asValue() : asCell()->toPrimitive(exec, preferredType); 253 253 } 254 254 255 inline bool JSValue ::getPrimitiveNumber(ExecState* exec, double& number, JSValuePtr& value)255 inline bool JSValuePtr::getPrimitiveNumber(ExecState* exec, double& number, JSValuePtr& value) 256 256 { 257 257 if (JSImmediate::isImmediate(asValue())) { … … 263 263 } 264 264 265 inline bool JSValue ::toBoolean(ExecState* exec) const265 inline bool JSValuePtr::toBoolean(ExecState* exec) const 266 266 { 267 267 return JSImmediate::isImmediate(asValue()) ? JSImmediate::toBoolean(asValue()) : asCell()->toBoolean(exec); 268 268 } 269 269 270 ALWAYS_INLINE double JSValue ::toNumber(ExecState* exec) const270 ALWAYS_INLINE double JSValuePtr::toNumber(ExecState* exec) const 271 271 { 272 272 return JSImmediate::isImmediate(asValue()) ? JSImmediate::toDouble(asValue()) : asCell()->toNumber(exec); 273 273 } 274 274 275 inline UString JSValue ::toString(ExecState* exec) const275 inline UString JSValuePtr::toString(ExecState* exec) const 276 276 { 277 277 return JSImmediate::isImmediate(asValue()) ? JSImmediate::toString(asValue()) : asCell()->toString(exec); 278 278 } 279 279 280 inline JSObject* JSValue ::toObject(ExecState* exec) const280 inline JSObject* JSValuePtr::toObject(ExecState* exec) const 281 281 { 282 282 return JSImmediate::isImmediate(asValue()) ? JSImmediate::toObject(asValue(), exec) : asCell()->toObject(exec); 283 283 } 284 284 285 inline JSObject* JSValue ::toThisObject(ExecState* exec) const285 inline JSObject* JSValuePtr::toThisObject(ExecState* exec) const 286 286 { 287 287 if (UNLIKELY(JSImmediate::isImmediate(asValue()))) … … 290 290 } 291 291 292 inline bool JSValue ::needsThisConversion() const292 inline bool JSValuePtr::needsThisConversion() const 293 293 { 294 294 if (UNLIKELY(JSImmediate::isImmediate(asValue()))) … … 297 297 } 298 298 299 inline UString JSValue ::toThisString(ExecState* exec) const299 inline UString JSValuePtr::toThisString(ExecState* exec) const 300 300 { 301 301 return JSImmediate::isImmediate(asValue()) ? JSImmediate::toString(asValue()) : asCell()->toThisString(exec); 302 302 } 303 303 304 inline JSValuePtr JSValue ::getJSNumber()304 inline JSValuePtr JSValuePtr::getJSNumber() 305 305 { 306 306 return JSImmediate::isNumber(asValue()) ? asValue() : JSImmediate::isImmediate(asValue()) ? noValue() : asCell()->getJSNumber();
Note:
See TracChangeset
for help on using the changeset viewer.