Changeset 11527 in webkit for trunk/JavaScriptCore/kjs/array_object.cpp
- Timestamp:
- Dec 10, 2005, 6:06:17 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/array_object.cpp
r11525 r11527 41 41 using namespace KJS; 42 42 43 // ------------------------------ ArrayInstance Imp-----------------------------43 // ------------------------------ ArrayInstance ----------------------------- 44 44 45 45 const unsigned sparseArrayCutoff = 10000; 46 46 47 const ClassInfo ArrayInstance Imp::info = {"Array", 0, 0, 0};48 49 ArrayInstance Imp::ArrayInstanceImp(ObjectImp*proto, unsigned initialLength)50 : ObjectImp(proto)47 const ClassInfo ArrayInstance::info = {"Array", 0, 0, 0}; 48 49 ArrayInstance::ArrayInstance(JSObject *proto, unsigned initialLength) 50 : JSObject(proto) 51 51 , length(initialLength) 52 52 , storageLength(initialLength < sparseArrayCutoff ? initialLength : 0) 53 53 , capacity(storageLength) 54 , storage(capacity ? ( ValueImp **)fastCalloc(capacity, sizeof(ValueImp*)) : 0)55 { 56 } 57 58 ArrayInstance Imp::ArrayInstanceImp(ObjectImp*proto, const List &list)59 : ObjectImp(proto)54 , storage(capacity ? (JSValue **)fastCalloc(capacity, sizeof(JSValue *)) : 0) 55 { 56 } 57 58 ArrayInstance::ArrayInstance(JSObject *proto, const List &list) 59 : JSObject(proto) 60 60 , length(list.size()) 61 61 , storageLength(length) 62 62 , capacity(storageLength) 63 , storage(capacity ? ( ValueImp **)fastMalloc(sizeof(ValueImp*) * capacity) : 0)63 , storage(capacity ? (JSValue **)fastMalloc(sizeof(JSValue *) * capacity) : 0) 64 64 { 65 65 ListIterator it = list.begin(); … … 70 70 } 71 71 72 ArrayInstance Imp::~ArrayInstanceImp()72 ArrayInstance::~ArrayInstance() 73 73 { 74 74 fastFree(storage); 75 75 } 76 76 77 ValueImp *ArrayInstanceImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)78 { 79 return jsNumber(static_cast<ArrayInstance Imp*>(slot.slotBase())->length);80 } 81 82 bool ArrayInstance Imp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)77 JSValue *ArrayInstance::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot) 78 { 79 return jsNumber(static_cast<ArrayInstance *>(slot.slotBase())->length); 80 } 81 82 bool ArrayInstance::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot) 83 83 { 84 84 if (propertyName == lengthPropertyName) { … … 93 93 return false; 94 94 if (index < storageLength) { 95 ValueImp*v = storage[index];95 JSValue *v = storage[index]; 96 96 if (!v || v->isUndefined()) 97 97 return false; … … 101 101 } 102 102 103 return ObjectImp::getOwnPropertySlot(exec, propertyName, slot);104 } 105 106 bool ArrayInstance Imp::getOwnPropertySlot(ExecState *exec, unsigned index, PropertySlot& slot)103 return JSObject::getOwnPropertySlot(exec, propertyName, slot); 104 } 105 106 bool ArrayInstance::getOwnPropertySlot(ExecState *exec, unsigned index, PropertySlot& slot) 107 107 { 108 108 if (index >= length) 109 109 return false; 110 110 if (index < storageLength) { 111 ValueImp*v = storage[index];111 JSValue *v = storage[index]; 112 112 if (!v || v->isUndefined()) 113 113 return false; … … 116 116 } 117 117 118 return ObjectImp::getOwnPropertySlot(exec, index, slot);118 return JSObject::getOwnPropertySlot(exec, index, slot); 119 119 } 120 120 121 121 // Special implementation of [[Put]] - see ECMA 15.4.5.1 122 void ArrayInstance Imp::put(ExecState *exec, const Identifier &propertyName, ValueImp*value, int attr)122 void ArrayInstance::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr) 123 123 { 124 124 if (propertyName == lengthPropertyName) { … … 134 134 } 135 135 136 ObjectImp::put(exec, propertyName, value, attr);137 } 138 139 void ArrayInstance Imp::put(ExecState *exec, unsigned index, ValueImp*value, int attr)136 JSObject::put(exec, propertyName, value, attr); 137 } 138 139 void ArrayInstance::put(ExecState *exec, unsigned index, JSValue *value, int attr) 140 140 { 141 141 if (index < sparseArrayCutoff && index >= storageLength) { … … 153 153 154 154 assert(index >= sparseArrayCutoff); 155 ObjectImp::put(exec, Identifier::from(index), value, attr);156 } 157 158 bool ArrayInstance Imp::deleteProperty(ExecState *exec, const Identifier &propertyName)155 JSObject::put(exec, Identifier::from(index), value, attr); 156 } 157 158 bool ArrayInstance::deleteProperty(ExecState *exec, const Identifier &propertyName) 159 159 { 160 160 if (propertyName == lengthPropertyName) … … 172 172 } 173 173 174 return ObjectImp::deleteProperty(exec, propertyName);175 } 176 177 bool ArrayInstance Imp::deleteProperty(ExecState *exec, unsigned index)174 return JSObject::deleteProperty(exec, propertyName); 175 } 176 177 bool ArrayInstance::deleteProperty(ExecState *exec, unsigned index) 178 178 { 179 179 if (index >= length) … … 184 184 } 185 185 186 return ObjectImp::deleteProperty(exec, Identifier::from(index));187 } 188 189 ReferenceList ArrayInstance Imp::propList(ExecState *exec, bool recursive)190 { 191 ReferenceList properties = ObjectImp::propList(exec,recursive);186 return JSObject::deleteProperty(exec, Identifier::from(index)); 187 } 188 189 ReferenceList ArrayInstance::propList(ExecState *exec, bool recursive) 190 { 191 ReferenceList properties = JSObject::propList(exec,recursive); 192 192 193 193 // avoid fetching this every time through the loop 194 ValueImp*undefined = jsUndefined();194 JSValue *undefined = jsUndefined(); 195 195 196 196 for (unsigned i = 0; i < storageLength; ++i) { 197 ValueImp*imp = storage[i];197 JSValue *imp = storage[i]; 198 198 if (imp && imp != undefined) { 199 199 properties.append(Reference(this, i)); … … 203 203 } 204 204 205 void ArrayInstance Imp::resizeStorage(unsigned newLength)205 void ArrayInstance::resizeStorage(unsigned newLength) 206 206 { 207 207 if (newLength < storageLength) { 208 memset(storage + newLength, 0, sizeof( ValueImp*) * (storageLength - newLength));208 memset(storage + newLength, 0, sizeof(JSValue *) * (storageLength - newLength)); 209 209 } 210 210 if (newLength > capacity) { … … 218 218 } 219 219 } 220 storage = ( ValueImp **)fastRealloc(storage, newCapacity * sizeof (ValueImp*));221 memset(storage + capacity, 0, sizeof( ValueImp*) * (newCapacity - capacity));220 storage = (JSValue **)fastRealloc(storage, newCapacity * sizeof (JSValue *)); 221 memset(storage + capacity, 0, sizeof(JSValue *) * (newCapacity - capacity)); 222 222 capacity = newCapacity; 223 223 } … … 225 225 } 226 226 227 void ArrayInstance Imp::setLength(unsigned newLength, ExecState *exec)227 void ArrayInstance::setLength(unsigned newLength, ExecState *exec) 228 228 { 229 229 if (newLength <= storageLength) { … … 250 250 } 251 251 252 void ArrayInstance Imp::mark()253 { 254 ObjectImp::mark();252 void ArrayInstance::mark() 253 { 254 JSObject::mark(); 255 255 unsigned l = storageLength; 256 256 for (unsigned i = 0; i < l; ++i) { 257 ValueImp*imp = storage[i];257 JSValue *imp = storage[i]; 258 258 if (imp && !imp->marked()) 259 259 imp->mark(); … … 266 266 { 267 267 ExecState *exec = execForCompareByStringForQSort; 268 ValueImp *va = *(ValueImp**)a;269 ValueImp *vb = *(ValueImp**)b;268 JSValue *va = *(JSValue **)a; 269 JSValue *vb = *(JSValue **)b; 270 270 if (va->isUndefined()) { 271 271 return vb->isUndefined() ? 0 : 1; … … 277 277 } 278 278 279 void ArrayInstance Imp::sort(ExecState *exec)279 void ArrayInstance::sort(ExecState *exec) 280 280 { 281 281 int lengthNotIncludingUndefined = pushUndefinedObjectsToEnd(exec); 282 282 283 283 execForCompareByStringForQSort = exec; 284 qsort(storage, lengthNotIncludingUndefined, sizeof( ValueImp*), compareByStringForQSort);284 qsort(storage, lengthNotIncludingUndefined, sizeof(JSValue *), compareByStringForQSort); 285 285 execForCompareByStringForQSort = 0; 286 286 } 287 287 288 288 struct CompareWithCompareFunctionArguments { 289 CompareWithCompareFunctionArguments(ExecState *e, ObjectImp*cf)289 CompareWithCompareFunctionArguments(ExecState *e, JSObject *cf) 290 290 : exec(e) 291 291 , compareFunction(cf) … … 297 297 298 298 ExecState *exec; 299 ObjectImp*compareFunction;299 JSObject *compareFunction; 300 300 List arguments; 301 ObjectImp*globalObject;301 JSObject *globalObject; 302 302 }; 303 303 … … 308 308 CompareWithCompareFunctionArguments *args = compareWithCompareFunctionArguments; 309 309 310 ValueImp *va = *(ValueImp**)a;311 ValueImp *vb = *(ValueImp**)b;310 JSValue *va = *(JSValue **)a; 311 JSValue *vb = *(JSValue **)b; 312 312 if (va->isUndefined()) { 313 313 return vb->isUndefined() ? 0 : 1; … … 325 325 } 326 326 327 void ArrayInstance Imp::sort(ExecState *exec, ObjectImp*compareFunction)327 void ArrayInstance::sort(ExecState *exec, JSObject *compareFunction) 328 328 { 329 329 int lengthNotIncludingUndefined = pushUndefinedObjectsToEnd(exec); … … 331 331 CompareWithCompareFunctionArguments args(exec, compareFunction); 332 332 compareWithCompareFunctionArguments = &args; 333 qsort(storage, lengthNotIncludingUndefined, sizeof( ValueImp*), compareWithCompareFunctionForQSort);333 qsort(storage, lengthNotIncludingUndefined, sizeof(JSValue *), compareWithCompareFunctionForQSort); 334 334 compareWithCompareFunctionArguments = 0; 335 335 } 336 336 337 unsigned ArrayInstance Imp::pushUndefinedObjectsToEnd(ExecState *exec)338 { 339 ValueImp*undefined = jsUndefined();337 unsigned ArrayInstance::pushUndefinedObjectsToEnd(ExecState *exec) 338 { 339 JSValue *undefined = jsUndefined(); 340 340 341 341 unsigned o = 0; 342 342 343 343 for (unsigned i = 0; i != storageLength; ++i) { 344 ValueImp*v = storage[i];344 JSValue *v = storage[i]; 345 345 if (v && v != undefined) { 346 346 if (o != i) … … 362 362 Reference ref = it++; 363 363 storage[o] = ref.getValue(exec); 364 ObjectImp::deleteProperty(exec, ref.getPropertyName(exec));364 JSObject::deleteProperty(exec, ref.getPropertyName(exec)); 365 365 o++; 366 366 } 367 367 368 368 if (newLength != storageLength) 369 memset(storage + o, 0, sizeof( ValueImp*) * (storageLength - o));369 memset(storage + o, 0, sizeof(JSValue *) * (storageLength - o)); 370 370 371 371 return o; 372 372 } 373 373 374 // ------------------------------ ArrayPrototype Imp----------------------------375 376 const ClassInfo ArrayPrototype Imp::info = {"Array", &ArrayInstanceImp::info, &arrayTable, 0};374 // ------------------------------ ArrayPrototype ---------------------------- 375 376 const ClassInfo ArrayPrototype::info = {"Array", &ArrayInstance::info, &arrayTable, 0}; 377 377 378 378 /* Source for array_object.lut.h 379 379 @begin arrayTable 16 380 toString ArrayProtoFunc Imp::ToString DontEnum|Function 0381 toLocaleString ArrayProtoFunc Imp::ToLocaleString DontEnum|Function 0382 concat ArrayProtoFunc Imp::Concat DontEnum|Function 1383 join ArrayProtoFunc Imp::Join DontEnum|Function 1384 pop ArrayProtoFunc Imp::Pop DontEnum|Function 0385 push ArrayProtoFunc Imp::Push DontEnum|Function 1386 reverse ArrayProtoFunc Imp::Reverse DontEnum|Function 0387 shift ArrayProtoFunc Imp::Shift DontEnum|Function 0388 slice ArrayProtoFunc Imp::Slice DontEnum|Function 2389 sort ArrayProtoFunc Imp::Sort DontEnum|Function 1390 splice ArrayProtoFunc Imp::Splice DontEnum|Function 2391 unshift ArrayProtoFunc Imp::UnShift DontEnum|Function 1392 every ArrayProtoFunc Imp::Every DontEnum|Function 5393 forEach ArrayProtoFunc Imp::ForEach DontEnum|Function 5394 some ArrayProtoFunc Imp::Some DontEnum|Function 5380 toString ArrayProtoFunc::ToString DontEnum|Function 0 381 toLocaleString ArrayProtoFunc::ToLocaleString DontEnum|Function 0 382 concat ArrayProtoFunc::Concat DontEnum|Function 1 383 join ArrayProtoFunc::Join DontEnum|Function 1 384 pop ArrayProtoFunc::Pop DontEnum|Function 0 385 push ArrayProtoFunc::Push DontEnum|Function 1 386 reverse ArrayProtoFunc::Reverse DontEnum|Function 0 387 shift ArrayProtoFunc::Shift DontEnum|Function 0 388 slice ArrayProtoFunc::Slice DontEnum|Function 2 389 sort ArrayProtoFunc::Sort DontEnum|Function 1 390 splice ArrayProtoFunc::Splice DontEnum|Function 2 391 unshift ArrayProtoFunc::UnShift DontEnum|Function 1 392 every ArrayProtoFunc::Every DontEnum|Function 5 393 forEach ArrayProtoFunc::ForEach DontEnum|Function 5 394 some ArrayProtoFunc::Some DontEnum|Function 5 395 395 @end 396 396 */ 397 397 398 398 // ECMA 15.4.4 399 ArrayPrototype Imp::ArrayPrototypeImp(ExecState *exec,400 ObjectPrototype Imp*objProto)401 : ArrayInstance Imp(objProto, 0)399 ArrayPrototype::ArrayPrototype(ExecState *exec, 400 ObjectPrototype *objProto) 401 : ArrayInstance(objProto, 0) 402 402 { 403 403 setInternalValue(jsNull()); 404 404 } 405 405 406 bool ArrayPrototype Imp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)407 { 408 return getStaticFunctionSlot<ArrayProtoFunc Imp, ArrayInstanceImp>(exec, &arrayTable, this, propertyName, slot);409 } 410 411 // ------------------------------ ArrayProtoFunc Imp----------------------------412 413 ArrayProtoFunc Imp::ArrayProtoFuncImp(ExecState *exec, int i, int len)406 bool ArrayPrototype::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot) 407 { 408 return getStaticFunctionSlot<ArrayProtoFunc, ArrayInstance>(exec, &arrayTable, this, propertyName, slot); 409 } 410 411 // ------------------------------ ArrayProtoFunc ---------------------------- 412 413 ArrayProtoFunc::ArrayProtoFunc(ExecState *exec, int i, int len) 414 414 : InternalFunctionImp( 415 static_cast<FunctionPrototype Imp*>(exec->lexicalInterpreter()->builtinFunctionPrototype())415 static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()) 416 416 ), id(i) 417 417 { … … 419 419 } 420 420 421 bool ArrayProtoFunc Imp::implementsCall() const421 bool ArrayProtoFunc::implementsCall() const 422 422 { 423 423 return true; 424 424 } 425 425 426 static ValueImp *getProperty(ExecState *exec, ObjectImp*obj, unsigned index)426 static JSValue *getProperty(ExecState *exec, JSObject *obj, unsigned index) 427 427 { 428 428 PropertySlot slot; … … 433 433 434 434 // ECMA 15.4.4 435 ValueImp *ArrayProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp*thisObj, const List &args)435 JSValue *ArrayProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args) 436 436 { 437 437 unsigned length = thisObj->get(exec,lengthPropertyName)->toUInt32(exec); 438 438 439 ValueImp*result = 0; // work around gcc 4.0 bug in uninitialized variable warning439 JSValue *result = 0; // work around gcc 4.0 bug in uninitialized variable warning 440 440 441 441 switch (id) { … … 443 443 case ToString: 444 444 445 if (!thisObj->inherits(&ArrayInstance Imp::info))445 if (!thisObj->inherits(&ArrayInstance::info)) 446 446 return throwError(exec, TypeError); 447 447 448 448 // fall through 449 449 case Join: { 450 static HashSet< ObjectImp*, PointerHash<ObjectImp*> > visitedElems;450 static HashSet< JSObject*, PointerHash<JSObject*> > visitedElems; 451 451 if (visitedElems.contains(thisObj)) 452 452 return jsString(""); … … 461 461 str += separator; 462 462 463 ValueImp*element = thisObj->get(exec, k);463 JSValue *element = thisObj->get(exec, k); 464 464 if (element->isUndefinedOrNull()) 465 465 continue; … … 467 467 bool fallback = false; 468 468 if (id == ToLocaleString) { 469 ObjectImp*o = element->toObject(exec);470 ValueImp*conversionFunction = o->get(exec, toLocaleStringPropertyName);471 if (conversionFunction->isObject() && static_cast< ObjectImp*>(conversionFunction)->implementsCall()) {472 str += static_cast< ObjectImp*>(conversionFunction)->call(exec, o, List())->toString(exec);469 JSObject *o = element->toObject(exec); 470 JSValue *conversionFunction = o->get(exec, toLocaleStringPropertyName); 471 if (conversionFunction->isObject() && static_cast<JSObject *>(conversionFunction)->implementsCall()) { 472 str += static_cast<JSObject *>(conversionFunction)->call(exec, o, List())->toString(exec); 473 473 } else { 474 474 // try toString() fallback … … 479 479 if (id == ToString || id == Join || fallback) { 480 480 if (element->isObject()) { 481 ObjectImp *o = static_cast<ObjectImp*>(element);482 ValueImp*conversionFunction = o->get(exec, toStringPropertyName);483 if (conversionFunction->isObject() && static_cast< ObjectImp*>(conversionFunction)->implementsCall()) {484 str += static_cast< ObjectImp*>(conversionFunction)->call(exec, o, List())->toString(exec);481 JSObject *o = static_cast<JSObject *>(element); 482 JSValue *conversionFunction = o->get(exec, toStringPropertyName); 483 if (conversionFunction->isObject() && static_cast<JSObject *>(conversionFunction)->implementsCall()) { 484 str += static_cast<JSObject *>(conversionFunction)->call(exec, o, List())->toString(exec); 485 485 } else { 486 486 return throwError(exec, RangeError, "Can't convert " + o->className() + " object to string"); … … 499 499 } 500 500 case Concat: { 501 ObjectImp *arr = static_cast<ObjectImp*>(exec->lexicalInterpreter()->builtinArray()->construct(exec,List::empty()));501 JSObject *arr = static_cast<JSObject *>(exec->lexicalInterpreter()->builtinArray()->construct(exec,List::empty())); 502 502 int n = 0; 503 ValueImp*curArg = thisObj;504 ObjectImp *curObj = static_cast<ObjectImp*>(thisObj);503 JSValue *curArg = thisObj; 504 JSObject *curObj = static_cast<JSObject *>(thisObj); 505 505 ListIterator it = args.begin(); 506 506 for (;;) { 507 507 if (curArg->isObject() && 508 curObj->inherits(&ArrayInstance Imp::info)) {508 curObj->inherits(&ArrayInstance::info)) { 509 509 unsigned int k = 0; 510 510 // Older versions tried to optimize out getting the length of thisObj … … 512 512 length = curObj->get(exec,lengthPropertyName)->toUInt32(exec); 513 513 while (k < length) { 514 if ( ValueImp*v = getProperty(exec, curObj, k))514 if (JSValue *v = getProperty(exec, curObj, k)) 515 515 arr->put(exec, n, v); 516 516 n++; … … 524 524 break; 525 525 curArg = *it; 526 curObj = static_cast< ObjectImp*>(it++); // may be 0526 curObj = static_cast<JSObject *>(it++); // may be 0 527 527 } 528 528 arr->put(exec,lengthPropertyName, jsNumber(n), DontEnum | DontDelete); … … 555 555 for (unsigned int k = 0; k < middle; k++) { 556 556 unsigned lk1 = length - k - 1; 557 ValueImp*obj2 = getProperty(exec, thisObj, lk1);558 ValueImp*obj = getProperty(exec, thisObj, k);557 JSValue *obj2 = getProperty(exec, thisObj, lk1); 558 JSValue *obj = getProperty(exec, thisObj, k); 559 559 560 560 if (obj2) … … 578 578 result = thisObj->get(exec, 0); 579 579 for(unsigned int k = 1; k < length; k++) { 580 if ( ValueImp*obj = getProperty(exec, thisObj, k))580 if (JSValue *obj = getProperty(exec, thisObj, k)) 581 581 thisObj->put(exec, k-1, obj); 582 582 else … … 592 592 593 593 // We return a new array 594 ObjectImp *resObj = static_cast<ObjectImp*>(exec->lexicalInterpreter()->builtinArray()->construct(exec,List::empty()));594 JSObject *resObj = static_cast<JSObject *>(exec->lexicalInterpreter()->builtinArray()->construct(exec,List::empty())); 595 595 result = resObj; 596 596 double begin = 0; … … 624 624 int e = static_cast<int>(end); 625 625 for(int k = b; k < e; k++, n++) { 626 if ( ValueImp*v = getProperty(exec, thisObj, k))626 if (JSValue *v = getProperty(exec, thisObj, k)) 627 627 resObj->put(exec, n, v); 628 628 } … … 636 636 printf("KJS Array::Sort: %d: %s\n", i, thisObj->get(exec, i)->toString(exec).ascii() ); 637 637 #endif 638 ObjectImp*sortFunction = NULL;638 JSObject *sortFunction = NULL; 639 639 if (!args[0]->isUndefined()) 640 640 { … … 644 644 } 645 645 646 if (thisObj->classInfo() == &ArrayInstance Imp::info) {646 if (thisObj->classInfo() == &ArrayInstance::info) { 647 647 if (sortFunction) 648 ((ArrayInstance Imp*)thisObj)->sort(exec, sortFunction);648 ((ArrayInstance *)thisObj)->sort(exec, sortFunction); 649 649 else 650 ((ArrayInstance Imp*)thisObj)->sort(exec);650 ((ArrayInstance *)thisObj)->sort(exec); 651 651 result = thisObj; 652 652 break; … … 663 663 for ( unsigned int i = 0 ; i<length-1 ; ++i ) 664 664 { 665 ValueImp*iObj = thisObj->get(exec,i);665 JSValue *iObj = thisObj->get(exec,i); 666 666 unsigned int themin = i; 667 ValueImp*minObj = iObj;667 JSValue *minObj = iObj; 668 668 for ( unsigned int j = i+1 ; j<length ; ++j ) 669 669 { 670 ValueImp*jObj = thisObj->get(exec,j);670 JSValue *jObj = thisObj->get(exec,j); 671 671 double cmp; 672 672 if (jObj->isUndefined()) { … … 706 706 case Splice: { 707 707 // 15.4.4.12 - oh boy this is huge 708 ObjectImp *resObj = static_cast<ObjectImp*>(exec->lexicalInterpreter()->builtinArray()->construct(exec,List::empty()));708 JSObject *resObj = static_cast<JSObject *>(exec->lexicalInterpreter()->builtinArray()->construct(exec,List::empty())); 709 709 result = resObj; 710 710 int begin = args[0]->toUInt32(exec); … … 717 717 //printf( "Splicing from %d, deleteCount=%d \n", begin, deleteCount ); 718 718 for(unsigned int k = 0; k < deleteCount; k++) { 719 if ( ValueImp*v = getProperty(exec, thisObj, k+begin))719 if (JSValue *v = getProperty(exec, thisObj, k+begin)) 720 720 resObj->put(exec, k, v); 721 721 } … … 729 729 for ( unsigned int k = begin; k < length - deleteCount; ++k ) 730 730 { 731 if ( ValueImp*v = getProperty(exec, thisObj, k+deleteCount))731 if (JSValue *v = getProperty(exec, thisObj, k+deleteCount)) 732 732 thisObj->put(exec, k+additionalArgs, v); 733 733 else … … 741 741 for ( unsigned int k = length - deleteCount; (int)k > begin; --k ) 742 742 { 743 if ( ValueImp*obj = getProperty(exec, thisObj, k + deleteCount - 1))743 if (JSValue *obj = getProperty(exec, thisObj, k + deleteCount - 1)) 744 744 thisObj->put(exec, k + additionalArgs - 1, obj); 745 745 else … … 759 759 for ( unsigned int k = length; k > 0; --k ) 760 760 { 761 if ( ValueImp*v = getProperty(exec, thisObj, k - 1))761 if (JSValue *v = getProperty(exec, thisObj, k - 1)) 762 762 thisObj->put(exec, k+nrArgs-1, v); 763 763 else … … 778 778 //http://developer-test.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:some 779 779 780 ObjectImp*eachFunction = args[0]->toObject(exec);780 JSObject *eachFunction = args[0]->toObject(exec); 781 781 782 782 if (!eachFunction->implementsCall()) 783 783 return throwError(exec, TypeError); 784 784 785 ObjectImp*applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicInterpreter()->globalObject() : args[1]->toObject(exec);785 JSObject *applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicInterpreter()->globalObject() : args[1]->toObject(exec); 786 786 787 787 if (id == Some || id == Every) … … 823 823 824 824 ArrayObjectImp::ArrayObjectImp(ExecState *exec, 825 FunctionPrototype Imp*funcProto,826 ArrayPrototype Imp*arrayProto)825 FunctionPrototype *funcProto, 826 ArrayPrototype *arrayProto) 827 827 : InternalFunctionImp(funcProto) 828 828 { … … 840 840 841 841 // ECMA 15.4.2 842 ObjectImp*ArrayObjectImp::construct(ExecState *exec, const List &args)842 JSObject *ArrayObjectImp::construct(ExecState *exec, const List &args) 843 843 { 844 844 // a single numeric argument denotes the array size (!) … … 847 847 if (n != args[0]->toNumber(exec)) 848 848 return throwError(exec, RangeError, "Array size is not a small enough positive integer."); 849 return new ArrayInstance Imp(exec->lexicalInterpreter()->builtinArrayPrototype(), n);849 return new ArrayInstance(exec->lexicalInterpreter()->builtinArrayPrototype(), n); 850 850 } 851 851 852 852 // otherwise the array is constructed with the arguments in it 853 return new ArrayInstance Imp(exec->lexicalInterpreter()->builtinArrayPrototype(), args);853 return new ArrayInstance(exec->lexicalInterpreter()->builtinArrayPrototype(), args); 854 854 } 855 855 … … 860 860 861 861 // ECMA 15.6.1 862 ValueImp *ArrayObjectImp::callAsFunction(ExecState *exec, ObjectImp*/*thisObj*/, const List &args)862 JSValue *ArrayObjectImp::callAsFunction(ExecState *exec, JSObject */*thisObj*/, const List &args) 863 863 { 864 864 // equivalent to 'new Array(....)'
Note:
See TracChangeset
for help on using the changeset viewer.