X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/14957cd040308e3eeec43d26bae5d76da13fcd85..4be4e30906bcb8ee30b4d189205cb70bad6707ce:/runtime/NumberConstructor.cpp?ds=inline diff --git a/runtime/NumberConstructor.cpp b/runtime/NumberConstructor.cpp index 6e46969..14e149d 100644 --- a/runtime/NumberConstructor.cpp +++ b/runtime/NumberConstructor.cpp @@ -25,16 +25,15 @@ #include "Lookup.h" #include "NumberObject.h" #include "NumberPrototype.h" +#include "Operations.h" namespace JSC { -ASSERT_CLASS_FITS_IN_CELL(NumberConstructor); - -static JSValue numberConstructorNaNValue(ExecState*, JSValue, const Identifier&); -static JSValue numberConstructorNegInfinity(ExecState*, JSValue, const Identifier&); -static JSValue numberConstructorPosInfinity(ExecState*, JSValue, const Identifier&); -static JSValue numberConstructorMaxValue(ExecState*, JSValue, const Identifier&); -static JSValue numberConstructorMinValue(ExecState*, JSValue, const Identifier&); +static JSValue numberConstructorNaNValue(ExecState*, JSValue, PropertyName); +static JSValue numberConstructorNegInfinity(ExecState*, JSValue, PropertyName); +static JSValue numberConstructorPosInfinity(ExecState*, JSValue, PropertyName); +static JSValue numberConstructorMaxValue(ExecState*, JSValue, PropertyName); +static JSValue numberConstructorMinValue(ExecState*, JSValue, PropertyName); } // namespace JSC @@ -42,7 +41,9 @@ static JSValue numberConstructorMinValue(ExecState*, JSValue, const Identifier&) namespace JSC { -const ClassInfo NumberConstructor::s_info = { "Function", &InternalFunction::s_info, 0, ExecState::numberConstructorTable }; +ASSERT_HAS_TRIVIAL_DESTRUCTOR(NumberConstructor); + +const ClassInfo NumberConstructor::s_info = { "Function", &InternalFunction::s_info, 0, ExecState::numberConstructorTable, CREATE_METHOD_TABLE(NumberConstructor) }; /* Source for NumberConstructor.lut.h @begin numberConstructorTable @@ -54,49 +55,59 @@ const ClassInfo NumberConstructor::s_info = { "Function", &InternalFunction::s_i @end */ -NumberConstructor::NumberConstructor(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, NumberPrototype* numberPrototype) - : InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, numberPrototype->s_info.className)) +NumberConstructor::NumberConstructor(JSGlobalObject* globalObject, Structure* structure) + : InternalFunction(globalObject, structure) +{ +} + +void NumberConstructor::finishCreation(ExecState* exec, NumberPrototype* numberPrototype) { + Base::finishCreation(exec->vm(), numberPrototype->s_info.className); ASSERT(inherits(&s_info)); // Number.Prototype - putDirectWithoutTransition(exec->globalData(), exec->propertyNames().prototype, numberPrototype, DontEnum | DontDelete | ReadOnly); + putDirectWithoutTransition(exec->vm(), exec->propertyNames().prototype, numberPrototype, DontEnum | DontDelete | ReadOnly); // no. of arguments for constructor - putDirectWithoutTransition(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontEnum | DontDelete); + putDirectWithoutTransition(exec->vm(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontEnum | DontDelete); +} + +bool NumberConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot) +{ + return getStaticValueSlot(exec, ExecState::numberConstructorTable(exec), jsCast(cell), propertyName, slot); } -bool NumberConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +bool NumberConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) { - return getStaticValueSlot(exec, ExecState::numberConstructorTable(exec), this, propertyName, slot); + return getStaticValueDescriptor(exec, ExecState::numberConstructorTable(exec), jsCast(object), propertyName, descriptor); } -bool NumberConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +void NumberConstructor::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot) { - return getStaticValueDescriptor(exec, ExecState::numberConstructorTable(exec), this, propertyName, descriptor); + lookupPut(exec, propertyName, value, ExecState::numberConstructorTable(exec), jsCast(cell), slot); } -static JSValue numberConstructorNaNValue(ExecState*, JSValue, const Identifier&) +static JSValue numberConstructorNaNValue(ExecState*, JSValue, PropertyName) { return jsNaN(); } -static JSValue numberConstructorNegInfinity(ExecState*, JSValue, const Identifier&) +static JSValue numberConstructorNegInfinity(ExecState*, JSValue, PropertyName) { - return jsNumber(-Inf); + return jsNumber(-std::numeric_limits::infinity()); } -static JSValue numberConstructorPosInfinity(ExecState*, JSValue, const Identifier&) +static JSValue numberConstructorPosInfinity(ExecState*, JSValue, PropertyName) { - return jsNumber(Inf); + return jsNumber(std::numeric_limits::infinity()); } -static JSValue numberConstructorMaxValue(ExecState*, JSValue, const Identifier&) +static JSValue numberConstructorMaxValue(ExecState*, JSValue, PropertyName) { return jsNumber(1.7976931348623157E+308); } -static JSValue numberConstructorMinValue(ExecState*, JSValue, const Identifier&) +static JSValue numberConstructorMinValue(ExecState*, JSValue, PropertyName) { return jsNumber(5E-324); } @@ -104,13 +115,13 @@ static JSValue numberConstructorMinValue(ExecState*, JSValue, const Identifier&) // ECMA 15.7.1 static EncodedJSValue JSC_HOST_CALL constructWithNumberConstructor(ExecState* exec) { - NumberObject* object = new (exec) NumberObject(exec->globalData(), asInternalFunction(exec->callee())->globalObject()->numberObjectStructure()); + NumberObject* object = NumberObject::create(exec->vm(), asInternalFunction(exec->callee())->globalObject()->numberObjectStructure()); double n = exec->argumentCount() ? exec->argument(0).toNumber(exec) : 0; - object->setInternalValue(exec->globalData(), jsNumber(n)); + object->setInternalValue(exec->vm(), jsNumber(n)); return JSValue::encode(object); } -ConstructType NumberConstructor::getConstructData(ConstructData& constructData) +ConstructType NumberConstructor::getConstructData(JSCell*, ConstructData& constructData) { constructData.native.function = constructWithNumberConstructor; return ConstructTypeHost; @@ -122,7 +133,7 @@ static EncodedJSValue JSC_HOST_CALL callNumberConstructor(ExecState* exec) return JSValue::encode(jsNumber(!exec->argumentCount() ? 0 : exec->argument(0).toNumber(exec))); } -CallType NumberConstructor::getCallData(CallData& callData) +CallType NumberConstructor::getCallData(JSCell*, CallData& callData) { callData.native.function = callNumberConstructor; return CallTypeHost;