Changeset 11527 in webkit for trunk/JavaScriptCore/kjs/function_object.cpp
- Timestamp:
- Dec 10, 2005, 6:06:17 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/function_object.cpp
r11525 r11527 37 37 using namespace KJS; 38 38 39 // ------------------------------ FunctionPrototype Imp-------------------------40 41 FunctionPrototype Imp::FunctionPrototypeImp(ExecState *exec)39 // ------------------------------ FunctionPrototype ------------------------- 40 41 FunctionPrototype::FunctionPrototype(ExecState *exec) 42 42 { 43 43 putDirect(lengthPropertyName, jsNumber(0), DontDelete|ReadOnly|DontEnum); 44 putDirect(toStringPropertyName, new FunctionProtoFunc Imp(exec, this, FunctionProtoFuncImp::ToString, 0), DontEnum);44 putDirect(toStringPropertyName, new FunctionProtoFunc(exec, this, FunctionProtoFunc::ToString, 0), DontEnum); 45 45 static const Identifier applyPropertyName("apply"); 46 putDirect(applyPropertyName, new FunctionProtoFunc Imp(exec, this, FunctionProtoFuncImp::Apply, 2), DontEnum);46 putDirect(applyPropertyName, new FunctionProtoFunc(exec, this, FunctionProtoFunc::Apply, 2), DontEnum); 47 47 static const Identifier callPropertyName("call"); 48 putDirect(callPropertyName, new FunctionProtoFunc Imp(exec, this, FunctionProtoFuncImp::Call, 1), DontEnum);49 } 50 51 FunctionPrototype Imp::~FunctionPrototypeImp()52 { 53 } 54 55 bool FunctionPrototype Imp::implementsCall() const48 putDirect(callPropertyName, new FunctionProtoFunc(exec, this, FunctionProtoFunc::Call, 1), DontEnum); 49 } 50 51 FunctionPrototype::~FunctionPrototype() 52 { 53 } 54 55 bool FunctionPrototype::implementsCall() const 56 56 { 57 57 return true; … … 59 59 60 60 // ECMA 15.3.4 61 ValueImp *FunctionPrototypeImp::callAsFunction(ExecState */*exec*/, ObjectImp*/*thisObj*/, const List &/*args*/)61 JSValue *FunctionPrototype::callAsFunction(ExecState */*exec*/, JSObject */*thisObj*/, const List &/*args*/) 62 62 { 63 63 return jsUndefined(); 64 64 } 65 65 66 // ------------------------------ FunctionProtoFunc Imp-------------------------67 68 FunctionProtoFunc Imp::FunctionProtoFuncImp(ExecState *exec,69 FunctionPrototype Imp*funcProto, int i, int len)66 // ------------------------------ FunctionProtoFunc ------------------------- 67 68 FunctionProtoFunc::FunctionProtoFunc(ExecState *exec, 69 FunctionPrototype *funcProto, int i, int len) 70 70 : InternalFunctionImp(funcProto), id(i) 71 71 { … … 74 74 75 75 76 bool FunctionProtoFunc Imp::implementsCall() const77 { 78 return true; 79 } 80 81 ValueImp *FunctionProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp*thisObj, const List &args)82 { 83 ValueImp*result = NULL;76 bool FunctionProtoFunc::implementsCall() const 77 { 78 return true; 79 } 80 81 JSValue *FunctionProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args) 82 { 83 JSValue *result = NULL; 84 84 85 85 switch (id) { … … 107 107 break; 108 108 case Apply: { 109 ValueImp*thisArg = args[0];110 ValueImp*argArray = args[1];111 ObjectImp*func = thisObj;109 JSValue *thisArg = args[0]; 110 JSValue *argArray = args[1]; 111 JSObject *func = thisObj; 112 112 113 113 if (!func->implementsCall()) 114 114 return throwError(exec, TypeError); 115 115 116 ObjectImp*applyThis;116 JSObject *applyThis; 117 117 if (thisArg->isUndefinedOrNull()) 118 118 applyThis = exec->dynamicInterpreter()->globalObject(); … … 123 123 if (!argArray->isUndefinedOrNull()) { 124 124 if (argArray->isObject() && 125 (static_cast< ObjectImp *>(argArray)->inherits(&ArrayInstanceImp::info) ||126 static_cast< ObjectImp *>(argArray)->inherits(&ArgumentsImp::info))) {127 128 ObjectImp *argArrayObj = static_cast<ObjectImp*>(argArray);125 (static_cast<JSObject *>(argArray)->inherits(&ArrayInstance::info) || 126 static_cast<JSObject *>(argArray)->inherits(&Arguments::info))) { 127 128 JSObject *argArrayObj = static_cast<JSObject *>(argArray); 129 129 unsigned int length = argArrayObj->get(exec,lengthPropertyName)->toUInt32(exec); 130 130 for (unsigned int i = 0; i < length; i++) … … 138 138 break; 139 139 case Call: { 140 ValueImp*thisArg = args[0];141 ObjectImp*func = thisObj;140 JSValue *thisArg = args[0]; 141 JSObject *func = thisObj; 142 142 143 143 if (!func->implementsCall()) 144 144 return throwError(exec, TypeError); 145 145 146 ObjectImp*callThis;146 JSObject *callThis; 147 147 if (thisArg->isUndefinedOrNull()) 148 148 callThis = exec->dynamicInterpreter()->globalObject(); … … 160 160 // ------------------------------ FunctionObjectImp ---------------------------- 161 161 162 FunctionObjectImp::FunctionObjectImp(ExecState *exec, FunctionPrototype Imp*funcProto)162 FunctionObjectImp::FunctionObjectImp(ExecState *exec, FunctionPrototype *funcProto) 163 163 : InternalFunctionImp(funcProto) 164 164 { … … 179 179 180 180 // ECMA 15.3.2 The Function Constructor 181 ObjectImp*FunctionObjectImp::construct(ExecState *exec, const List &args, const UString &sourceURL, int lineNumber)181 JSObject *FunctionObjectImp::construct(ExecState *exec, const List &args, const UString &sourceURL, int lineNumber) 182 182 { 183 183 UString p(""); … … 208 208 if (!cont) { 209 209 dbg->imp()->abort(); 210 return new ObjectImp();210 return new JSObject(); 211 211 } 212 212 } … … 259 259 List consArgs; 260 260 261 ObjectImp*objCons = exec->lexicalInterpreter()->builtinObject();262 ObjectImp*prototype = objCons->construct(exec,List::empty());261 JSObject *objCons = exec->lexicalInterpreter()->builtinObject(); 262 JSObject *prototype = objCons->construct(exec,List::empty()); 263 263 prototype->put(exec, constructorPropertyName, fimp, DontEnum|DontDelete|ReadOnly); 264 264 fimp->put(exec, prototypePropertyName, prototype, DontEnum|DontDelete|ReadOnly); … … 267 267 268 268 // ECMA 15.3.2 The Function Constructor 269 ObjectImp*FunctionObjectImp::construct(ExecState *exec, const List &args)269 JSObject *FunctionObjectImp::construct(ExecState *exec, const List &args) 270 270 { 271 271 return FunctionObjectImp::construct(exec, args, UString(), 0); … … 279 279 280 280 // ECMA 15.3.1 The Function Constructor Called as a Function 281 ValueImp *FunctionObjectImp::callAsFunction(ExecState *exec, ObjectImp*/*thisObj*/, const List &args)281 JSValue *FunctionObjectImp::callAsFunction(ExecState *exec, JSObject */*thisObj*/, const List &args) 282 282 { 283 283 return construct(exec,args);
Note:
See TracChangeset
for help on using the changeset viewer.