Changeset 17610 in webkit for trunk/JavaScriptCore/kjs/array_object.cpp
- Timestamp:
- Nov 6, 2006, 12:30:01 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/array_object.cpp
r17372 r17610 470 470 static HashSet<JSObject*> visitedElems; 471 471 if (visitedElems.contains(thisObj)) 472 return jsString("");472 return jsString(""); 473 473 UString separator = ","; 474 474 UString str = ""; … … 476 476 visitedElems.add(thisObj); 477 477 if (id == Join && !args[0]->isUndefined()) 478 separator = args[0]->toString(exec);478 separator = args[0]->toString(exec); 479 479 for (unsigned int k = 0; k < length; k++) { 480 if (k >= 1)481 str += separator;482 483 JSValue *element = thisObj->get(exec, k);484 if (element->isUndefinedOrNull())485 continue;486 487 bool fallback = false;488 if (id == ToLocaleString) {489 JSObject *o = element->toObject(exec);490 JSValue *conversionFunction = o->get(exec, toLocaleStringPropertyName);491 if (conversionFunction->isObject() && static_cast<JSObject *>(conversionFunction)->implementsCall()) {492 str += static_cast<JSObject*>(conversionFunction)->call(exec, o, List())->toString(exec);493 } else {494 // try toString() fallback495 fallback = true;480 if (k >= 1) 481 str += separator; 482 483 JSValue* element = thisObj->get(exec, k); 484 if (element->isUndefinedOrNull()) 485 continue; 486 487 bool fallback = false; 488 if (id == ToLocaleString) { 489 JSObject* o = element->toObject(exec); 490 JSValue* conversionFunction = o->get(exec, toLocaleStringPropertyName); 491 if (conversionFunction->isObject() && static_cast<JSObject*>(conversionFunction)->implementsCall()) 492 str += static_cast<JSObject*>(conversionFunction)->call(exec, o, List())->toString(exec); 493 else 494 // try toString() fallback 495 fallback = true; 496 496 } 497 } 498 499 if (id == ToString || id == Join || fallback) { 500 if (element->isObject()) { 501 JSObject *o = static_cast<JSObject *>(element); 502 JSValue *conversionFunction = o->get(exec, toStringPropertyName); 503 if (conversionFunction->isObject() && static_cast<JSObject *>(conversionFunction)->implementsCall()) { 504 str += static_cast<JSObject *>(conversionFunction)->call(exec, o, List())->toString(exec); 505 } else { 506 visitedElems.remove(thisObj); 507 return throwError(exec, RangeError, "Can't convert " + o->className() + " object to string"); 508 } 509 } else { 510 str += element->toString(exec); 511 } 512 } 513 514 if ( exec->hadException() ) 515 break; 497 498 if (id == ToString || id == Join || fallback) 499 str += element->toString(exec); 500 501 if (exec->hadException()) 502 break; 516 503 } 517 504 visitedElems.remove(thisObj);
Note:
See TracChangeset
for help on using the changeset viewer.