]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - runtime/NumberConstructor.cpp
JavaScriptCore-7600.1.4.15.12.tar.gz
[apple/javascriptcore.git] / runtime / NumberConstructor.cpp
index 6e469699a8320693e3095940c0b7723525ecec8f..04c509838e40c13a716cc233e8175753767891ee 100644 (file)
 #include "Lookup.h"
 #include "NumberObject.h"
 #include "NumberPrototype.h"
+#include "JSCInlines.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 EncodedJSValue numberConstructorNaNValue(ExecState*, JSObject*, EncodedJSValue, PropertyName);
+static EncodedJSValue numberConstructorNegInfinity(ExecState*, JSObject*, EncodedJSValue, PropertyName);
+static EncodedJSValue numberConstructorPosInfinity(ExecState*, JSObject*, EncodedJSValue, PropertyName);
+static EncodedJSValue numberConstructorMaxValue(ExecState*, JSObject*, EncodedJSValue, PropertyName);
+static EncodedJSValue numberConstructorMinValue(ExecState*, JSObject*, EncodedJSValue, 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 };
+STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(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,63 +55,63 @@ 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(VM& vm, Structure* structure)
+    : InternalFunction(vm, structure)
+{
+}
+
+void NumberConstructor::finishCreation(VM& vm, NumberPrototype* numberPrototype)
 {
-    ASSERT(inherits(&s_info));
+    Base::finishCreation(vm, NumberPrototype::info()->className);
+    ASSERT(inherits(info()));
 
     // Number.Prototype
-    putDirectWithoutTransition(exec->globalData(), exec->propertyNames().prototype, numberPrototype, DontEnum | DontDelete | ReadOnly);
+    putDirectWithoutTransition(vm, vm.propertyNames->prototype, numberPrototype, DontEnum | DontDelete | ReadOnly);
 
     // no. of arguments for constructor
-    putDirectWithoutTransition(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontEnum | DontDelete);
-}
-
-bool NumberConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
-{
-    return getStaticValueSlot<NumberConstructor, InternalFunction>(exec, ExecState::numberConstructorTable(exec), this, propertyName, slot);
+    putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum | DontDelete);
 }
 
-bool NumberConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
+bool NumberConstructor::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
 {
-    return getStaticValueDescriptor<NumberConstructor, InternalFunction>(exec, ExecState::numberConstructorTable(exec), this, propertyName, descriptor);
+    return getStaticValueSlot<NumberConstructor, InternalFunction>(exec, ExecState::numberConstructorTable(exec->vm()), jsCast<NumberConstructor*>(object), propertyName, slot);
 }
 
-static JSValue numberConstructorNaNValue(ExecState*, JSValue, const Identifier&)
+static EncodedJSValue numberConstructorNaNValue(ExecState*, JSObject*, EncodedJSValue, PropertyName)
 {
-    return jsNaN();
+    return JSValue::encode(jsNaN());
 }
 
-static JSValue numberConstructorNegInfinity(ExecState*, JSValue, const Identifier&)
+static EncodedJSValue numberConstructorNegInfinity(ExecState*, JSObject*, EncodedJSValue, PropertyName)
 {
-    return jsNumber(-Inf);
+    return JSValue::encode(jsNumber(-std::numeric_limits<double>::infinity()));
 }
 
-static JSValue numberConstructorPosInfinity(ExecState*, JSValue, const Identifier&)
+static EncodedJSValue numberConstructorPosInfinity(ExecState*, JSObject*, EncodedJSValue, PropertyName)
 {
-    return jsNumber(Inf);
+    return JSValue::encode(jsNumber(std::numeric_limits<double>::infinity()));
 }
 
-static JSValue numberConstructorMaxValue(ExecState*, JSValue, const Identifier&)
+static EncodedJSValue numberConstructorMaxValue(ExecState*, JSObject*, EncodedJSValue, PropertyName)
 {
-    return jsNumber(1.7976931348623157E+308);
+    return JSValue::encode(jsNumber(1.7976931348623157E+308));
 }
 
-static JSValue numberConstructorMinValue(ExecState*, JSValue, const Identifier&)
+static EncodedJSValue numberConstructorMinValue(ExecState*, JSObject*, EncodedJSValue, PropertyName)
 {
-    return jsNumber(5E-324);
+    return JSValue::encode(jsNumber(5E-324));
 }
 
 // ECMA 15.7.1
 static EncodedJSValue JSC_HOST_CALL constructWithNumberConstructor(ExecState* exec)
 {
-    NumberObject* object = new (exec) NumberObject(exec->globalData(), asInternalFunction(exec->callee())->globalObject()->numberObjectStructure());
-    double n = exec->argumentCount() ? exec->argument(0).toNumber(exec) : 0;
-    object->setInternalValue(exec->globalData(), jsNumber(n));
+    NumberObject* object = NumberObject::create(exec->vm(), asInternalFunction(exec->callee())->globalObject()->numberObjectStructure());
+    double n = exec->argumentCount() ? exec->uncheckedArgument(0).toNumber(exec) : 0;
+    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;
@@ -119,10 +120,10 @@ ConstructType NumberConstructor::getConstructData(ConstructData& constructData)
 // ECMA 15.7.2
 static EncodedJSValue JSC_HOST_CALL callNumberConstructor(ExecState* exec)
 {
-    return JSValue::encode(jsNumber(!exec->argumentCount() ? 0 : exec->argument(0).toNumber(exec)));
+    return JSValue::encode(jsNumber(!exec->argumentCount() ? 0 : exec->uncheckedArgument(0).toNumber(exec)));
 }
 
-CallType NumberConstructor::getCallData(CallData& callData)
+CallType NumberConstructor::getCallData(JSCell*, CallData& callData)
 {
     callData.native.function = callNumberConstructor;
     return CallTypeHost;