Changeset 10084 in webkit for trunk/JavaScriptCore/kjs/function.cpp
- Timestamp:
- Aug 7, 2005, 9:07:46 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/function.cpp
r10076 r10084 59 59 FunctionImp::FunctionImp(ExecState *exec, const Identifier &n) 60 60 : InternalFunctionImp( 61 static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype() .imp())61 static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype()) 62 62 ), param(0L), ident(n) 63 63 { … … 74 74 } 75 75 76 Value FunctionImp::call(ExecState *exec, Object &thisObj, const List &args)77 { 78 Object &globalObj = exec->dynamicInterpreter()->globalObject();76 ValueImp *FunctionImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args) 77 { 78 ObjectImp *globalObj = exec->dynamicInterpreter()->globalObject(); 79 79 80 80 // enter a new execution context … … 98 98 } 99 99 100 Object func(this); 101 bool cont = dbg->callEvent(&newExec,sid,lineno,func,args); 100 bool cont = dbg->callEvent(&newExec,sid,lineno,this,args); 102 101 if (!cont) { 103 102 dbg->imp()->abort(); … … 128 127 newExec.setException(comp.value()); 129 128 130 Object func(this); 131 int cont = dbg->returnEvent(&newExec,sid,lineno,func); 129 int cont = dbg->returnEvent(&newExec,sid,lineno,this); 132 130 if (!cont) { 133 131 dbg->imp()->abort(); … … 173 171 void FunctionImp::processParameters(ExecState *exec, const List &args) 174 172 { 175 Object 173 ObjectImp *variable = exec->context().imp()->variableObject(); 176 174 177 175 #ifdef KJS_VERBOSE … … 190 188 printInfo(exec,"to", *it); 191 189 #endif 192 variable .put(exec, p->name, *it);190 variable->put(exec, p->name, *it); 193 191 it++; 194 192 } else 195 variable .put(exec, p->name, Undefined());193 variable->put(exec, p->name, Undefined()); 196 194 p = p->next; 197 195 } … … 209 207 } 210 208 211 Value 209 ValueImp *FunctionImp::argumentsGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot) 212 210 { 213 211 FunctionImp *thisObj = static_cast<FunctionImp *>(slot.slotBase()); … … 222 220 } 223 221 224 Value 222 ValueImp *FunctionImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot) 225 223 { 226 224 FunctionImp *thisObj = static_cast<FunctionImp *>(slot.slotBase()); … … 251 249 } 252 250 253 void FunctionImp::put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr)251 void FunctionImp::put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr) 254 252 { 255 253 if (propertyName == exec->dynamicInterpreter()->argumentsIdentifier() || propertyName == lengthPropertyName) … … 306 304 : FunctionImp(exec,n), body(b) 307 305 { 308 Value protect(this);309 306 body->ref(); 310 307 setScope(sc); … … 323 320 324 321 // ECMA 13.2.2 [[Construct]] 325 Object 326 { 327 Object 328 Value 329 if (p .type() == ObjectType)330 proto = Object(static_cast<ObjectImp*>(p.imp()));322 ObjectImp *DeclaredFunctionImp::construct(ExecState *exec, const List &args) 323 { 324 ObjectImp *proto; 325 ValueImp *p = get(exec,prototypePropertyName); 326 if (p->isObject()) 327 proto = static_cast<ObjectImp*>(p); 331 328 else 332 329 proto = exec->lexicalInterpreter()->builtinObjectPrototype(); 333 330 334 Object 335 336 Value 337 338 if (res .type() == ObjectType)339 return Object::dynamicCast(res);331 ObjectImp *obj(new ObjectImp(proto)); 332 333 ValueImp *res = call(exec,obj,args); 334 335 if (res->isObject()) 336 return static_cast<ObjectImp *>(res); 340 337 else 341 338 return obj; … … 434 431 indexToNameMap(func, args) 435 432 { 436 Value protect(this);437 433 putDirect(calleePropertyName, func, DontEnum); 438 434 putDirect(lengthPropertyName, args.size(), DontEnum); … … 454 450 } 455 451 456 Value 452 ValueImp *ArgumentsImp::mappedIndexGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot) 457 453 { 458 454 ArgumentsImp *thisObj = static_cast<ArgumentsImp *>(slot.slotBase()); … … 470 466 } 471 467 472 void ArgumentsImp::put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr)468 void ArgumentsImp::put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr) 473 469 { 474 470 if (indexToNameMap.isMapped(propertyName)) { … … 501 497 } 502 498 503 Value 499 ValueImp *ActivationImp::argumentsGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot) 504 500 { 505 501 ActivationImp *thisObj = static_cast<ActivationImp *>(slot.slotBase()); … … 509 505 thisObj->createArgumentsObject(exec); 510 506 511 return Value(thisObj->_argumentsObject);507 return thisObj->_argumentsObject; 512 508 } 513 509 … … 559 555 : InternalFunctionImp(funcProto), id(i) 560 556 { 561 Value protect(this);562 557 putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum); 563 558 } … … 573 568 } 574 569 575 static Value 576 { 577 UString r = "", s, str = args[0] .toString(exec);570 static ValueImp *encode(ExecState *exec, const List &args, const char *do_not_escape) 571 { 572 UString r = "", s, str = args[0]->toString(exec); 578 573 CString cstr = str.UTF8String(); 579 574 const char *p = cstr.c_str(); … … 591 586 } 592 587 593 static Value 594 { 595 UString s = "", str = args[0] .toString(exec);588 static ValueImp *decode(ExecState *exec, const List &args, const char *do_not_unescape, bool strict) 589 { 590 UString s = "", str = args[0]->toString(exec); 596 591 int k = 0, len = str.size(); 597 592 const UChar *d = str.data(); … … 635 630 if (charLen == 0) { 636 631 if (strict) { 637 Object 632 ObjectImp *error = Error::create(exec, URIError); 638 633 exec->setException(error); 639 634 return error; … … 768 763 } 769 764 770 Value GlobalFuncImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)771 { 772 Value res;765 ValueImp *GlobalFuncImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args) 766 { 767 ValueImp *res = jsUndefined(); 773 768 774 769 static const char do_not_escape[] = … … 793 788 switch (id) { 794 789 case Eval: { // eval() 795 Value 796 if ( x.type() != StringType)790 ValueImp *x = args[0]; 791 if (!x->isString()) 797 792 return x; 798 793 else { 799 UString s = x .toString(exec);794 UString s = x->toString(exec); 800 795 801 796 int sid; … … 813 808 // no program node means a syntax occurred 814 809 if (!progNode) { 815 Object 816 err .put(exec,"sid",Number(sid));810 ObjectImp *err = Error::create(exec,SyntaxError,errMsg.ascii(),errLine); 811 err->put(exec,"sid",Number(sid)); 817 812 exec->setException(err); 818 813 return err; … … 822 817 823 818 // enter a new execution context 824 Object thisVal(Object::dynamicCast(exec->context().thisValue()));819 ObjectImp *thisVal = static_cast<ObjectImp *>(exec->context().thisValue()); 825 820 ContextImp ctx(exec->dynamicInterpreter()->globalObject(), 826 821 exec->dynamicInterpreter()->imp(), … … 852 847 } 853 848 case ParseInt: 854 res = Number(parseInt(args[0] .toString(exec), args[1].toInt32(exec)));849 res = Number(parseInt(args[0]->toString(exec), args[1]->toInt32(exec))); 855 850 break; 856 851 case ParseFloat: 857 res = Number(parseFloat(args[0] .toString(exec)));852 res = Number(parseFloat(args[0]->toString(exec))); 858 853 break; 859 854 case IsNaN: 860 res = Boolean(isNaN(args[0] .toNumber(exec)));855 res = Boolean(isNaN(args[0]->toNumber(exec))); 861 856 break; 862 857 case IsFinite: { 863 double n = args[0] .toNumber(exec);858 double n = args[0]->toNumber(exec); 864 859 res = Boolean(!isNaN(n) && !isInf(n)); 865 860 break; … … 879 874 case Escape: 880 875 { 881 UString r = "", s, str = args[0] .toString(exec);876 UString r = "", s, str = args[0]->toString(exec); 882 877 const UChar *c = str.data(); 883 878 for (int k = 0; k < str.size(); k++, c++) { … … 901 896 case UnEscape: 902 897 { 903 UString s = "", str = args[0] .toString(exec);898 UString s = "", str = args[0]->toString(exec); 904 899 int k = 0, len = str.size(); 905 900 while (k < len) { … … 928 923 #ifndef NDEBUG 929 924 case KJSPrint: 930 puts(args[0] .toString(exec).ascii());925 puts(args[0]->toString(exec).ascii()); 931 926 break; 932 927 #endif
Note:
See TracChangeset
for help on using the changeset viewer.