Changeset 11527 in webkit for trunk/JavaScriptCore/kjs/number_object.cpp
- Timestamp:
- Dec 10, 2005, 6:06:17 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/number_object.cpp
r11525 r11527 37 37 38 38 39 // ------------------------------ NumberInstance Imp----------------------------40 41 const ClassInfo NumberInstance Imp::info = {"Number", 0, 0, 0};42 43 NumberInstance Imp::NumberInstanceImp(ObjectImp*proto)44 : ObjectImp(proto)45 { 46 } 47 // ------------------------------ NumberPrototype Imp---------------------------39 // ------------------------------ NumberInstance ---------------------------- 40 41 const ClassInfo NumberInstance::info = {"Number", 0, 0, 0}; 42 43 NumberInstance::NumberInstance(JSObject *proto) 44 : JSObject(proto) 45 { 46 } 47 // ------------------------------ NumberPrototype --------------------------- 48 48 49 49 // ECMA 15.7.4 50 50 51 NumberPrototype Imp::NumberPrototypeImp(ExecState *exec,52 ObjectPrototype Imp*objProto,53 FunctionPrototype Imp*funcProto)54 : NumberInstance Imp(objProto)51 NumberPrototype::NumberPrototype(ExecState *exec, 52 ObjectPrototype *objProto, 53 FunctionPrototype *funcProto) 54 : NumberInstance(objProto) 55 55 { 56 56 setInternalValue(jsNumber(0)); … … 58 58 // The constructor will be added later, after NumberObjectImp has been constructed 59 59 60 putDirect(toStringPropertyName, new NumberProtoFunc Imp(exec,funcProto,NumberProtoFuncImp::ToString, 1), DontEnum);61 putDirect(toLocaleStringPropertyName, new NumberProtoFunc Imp(exec,funcProto,NumberProtoFuncImp::ToLocaleString, 0), DontEnum);62 putDirect(valueOfPropertyName, new NumberProtoFunc Imp(exec,funcProto,NumberProtoFuncImp::ValueOf, 0), DontEnum);63 putDirect(toFixedPropertyName, new NumberProtoFunc Imp(exec,funcProto,NumberProtoFuncImp::ToFixed, 1), DontEnum);64 putDirect(toExponentialPropertyName, new NumberProtoFunc Imp(exec,funcProto,NumberProtoFuncImp::ToExponential, 1), DontEnum);65 putDirect(toPrecisionPropertyName, new NumberProtoFunc Imp(exec,funcProto,NumberProtoFuncImp::ToPrecision, 1), DontEnum);66 } 67 68 69 // ------------------------------ NumberProtoFunc Imp---------------------------70 71 NumberProtoFunc Imp::NumberProtoFuncImp(ExecState *exec,72 FunctionPrototype Imp*funcProto, int i, int len)60 putDirect(toStringPropertyName, new NumberProtoFunc(exec,funcProto,NumberProtoFunc::ToString, 1), DontEnum); 61 putDirect(toLocaleStringPropertyName, new NumberProtoFunc(exec,funcProto,NumberProtoFunc::ToLocaleString, 0), DontEnum); 62 putDirect(valueOfPropertyName, new NumberProtoFunc(exec,funcProto,NumberProtoFunc::ValueOf, 0), DontEnum); 63 putDirect(toFixedPropertyName, new NumberProtoFunc(exec,funcProto,NumberProtoFunc::ToFixed, 1), DontEnum); 64 putDirect(toExponentialPropertyName, new NumberProtoFunc(exec,funcProto,NumberProtoFunc::ToExponential, 1), DontEnum); 65 putDirect(toPrecisionPropertyName, new NumberProtoFunc(exec,funcProto,NumberProtoFunc::ToPrecision, 1), DontEnum); 66 } 67 68 69 // ------------------------------ NumberProtoFunc --------------------------- 70 71 NumberProtoFunc::NumberProtoFunc(ExecState *exec, 72 FunctionPrototype *funcProto, int i, int len) 73 73 : InternalFunctionImp(funcProto), id(i) 74 74 { … … 77 77 78 78 79 bool NumberProtoFunc Imp::implementsCall() const79 bool NumberProtoFunc::implementsCall() const 80 80 { 81 81 return true; … … 127 127 128 128 // ECMA 15.7.4.2 - 15.7.4.7 129 ValueImp *NumberProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp*thisObj, const List &args)129 JSValue *NumberProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args) 130 130 { 131 131 // no generic function. "this" has to be a Number object 132 if (!thisObj->inherits(&NumberInstance Imp::info))132 if (!thisObj->inherits(&NumberInstance::info)) 133 133 return throwError(exec, TypeError); 134 134 135 ValueImp*v = thisObj->internalValue();135 JSValue *v = thisObj->internalValue(); 136 136 switch (id) { 137 137 case ToString: { … … 159 159 case ToFixed: 160 160 { 161 ValueImp*fractionDigits = args[0];161 JSValue *fractionDigits = args[0]; 162 162 double df = fractionDigits->toInteger(exec); 163 163 if (!(df >= 0 && df <= 20)) // true for NaN … … 204 204 return jsString(UString::from(x)); 205 205 206 ValueImp*fractionDigits = args[0];206 JSValue *fractionDigits = args[0]; 207 207 double df = fractionDigits->toInteger(exec); 208 208 if (!(df >= 0 && df <= 20)) // true for NaN … … 368 368 */ 369 369 NumberObjectImp::NumberObjectImp(ExecState *exec, 370 FunctionPrototype Imp*funcProto,371 NumberPrototype Imp*numberProto)370 FunctionPrototype *funcProto, 371 NumberPrototype *numberProto) 372 372 : InternalFunctionImp(funcProto) 373 373 { … … 384 384 } 385 385 386 ValueImp*NumberObjectImp::getValueProperty(ExecState *, int token) const386 JSValue *NumberObjectImp::getValueProperty(ExecState *, int token) const 387 387 { 388 388 // ECMA 15.7.3 … … 409 409 410 410 // ECMA 15.7.1 411 ObjectImp*NumberObjectImp::construct(ExecState *exec, const List &args)412 { 413 ObjectImp*proto = exec->lexicalInterpreter()->builtinNumberPrototype();414 ObjectImp *obj(new NumberInstanceImp(proto));411 JSObject *NumberObjectImp::construct(ExecState *exec, const List &args) 412 { 413 JSObject *proto = exec->lexicalInterpreter()->builtinNumberPrototype(); 414 JSObject *obj(new NumberInstance(proto)); 415 415 416 416 double n; … … 431 431 432 432 // ECMA 15.7.2 433 ValueImp *NumberObjectImp::callAsFunction(ExecState *exec, ObjectImp*/*thisObj*/, const List &args)433 JSValue *NumberObjectImp::callAsFunction(ExecState *exec, JSObject */*thisObj*/, const List &args) 434 434 { 435 435 if (args.isEmpty())
Note:
See TracChangeset
for help on using the changeset viewer.