Changeset 10728 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Oct 4, 2005, 2:33:33 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/object.cpp
r10701 r10728 278 278 } 279 279 280 // ECMA 8.6.2.6 281 ValueImp *ObjectImp::defaultValue(ExecState *exec, Type hint) const 282 { 283 if (hint != StringType && hint != NumberType) { 284 /* Prefer String for Date objects */ 285 if (_proto == exec->lexicalInterpreter()->builtinDatePrototype()) 286 hint = StringType; 287 else 288 hint = NumberType; 289 } 290 291 ValueImp *v; 292 if (hint == StringType) 293 v = get(exec,toStringPropertyName); 294 else 295 v = get(exec,valueOfPropertyName); 296 280 static inline 281 #ifdef __GNUC__ 282 __attribute__((always_inline)) 283 #endif 284 ValueImp *tryGetAndCallProperty(ExecState *exec, const ObjectImp *object, const Identifier &propertyName) { 285 ValueImp *v = object->get(exec, propertyName); 297 286 if (v->isObject()) { 298 287 ObjectImp *o = static_cast<ObjectImp*>(v); 299 288 if (o->implementsCall()) { // spec says "not primitive type" but ... 300 ObjectImp *thisObj = const_cast<ObjectImp*>( this);301 ValueImp *def = o->call(exec, thisObj,List::empty());289 ObjectImp *thisObj = const_cast<ObjectImp*>(object); 290 ValueImp *def = o->call(exec, thisObj, List::empty()); 302 291 Type defType = def->type(); 303 292 if (defType == UnspecifiedType || defType == UndefinedType || … … 308 297 } 309 298 } 310 311 if (hint == StringType) 312 v = get(exec,valueOfPropertyName); 313 else 314 v = get(exec,toStringPropertyName); 315 316 if (v->isObject()) { 317 ObjectImp *o = static_cast<ObjectImp*>(v); 318 if (o->implementsCall()) { // spec says "not primitive type" but ... 319 ObjectImp *thisObj = const_cast<ObjectImp*>(this); 320 ValueImp *def = o->call(exec,thisObj,List::empty()); 321 Type defType = def->type(); 322 if (defType == UnspecifiedType || defType == UndefinedType || 323 defType == NullType || defType == BooleanType || 324 defType == StringType || defType == NumberType) { 325 return def; 326 } 327 } 328 } 299 return NULL; 300 } 301 302 // ECMA 8.6.2.6 303 ValueImp *ObjectImp::defaultValue(ExecState *exec, Type hint) const 304 { 305 Identifier firstPropertyName; 306 Identifier secondPropertyName; 307 /* Prefer String for Date objects */ 308 if ((hint == StringType) || (hint != StringType) && (hint != NumberType) && (_proto == exec->lexicalInterpreter()->builtinDatePrototype())) { 309 firstPropertyName = toStringPropertyName; 310 secondPropertyName = valueOfPropertyName; 311 } else { 312 firstPropertyName = valueOfPropertyName; 313 secondPropertyName = toStringPropertyName; 314 } 315 316 ValueImp *v; 317 if ((v = tryGetAndCallProperty(exec, this, firstPropertyName))) 318 return v; 319 if ((v = tryGetAndCallProperty(exec, this, secondPropertyName))) 320 return v; 329 321 330 322 if (exec->hadException())
Note:
See TracChangeset
for help on using the changeset viewer.