ObjectConstructor.cpp [plain text]
#include "config.h"
#include "ObjectConstructor.h"
#include "JSFunction.h"
#include "JSGlobalObject.h"
#include "ObjectPrototype.h"
namespace JSC {
ASSERT_CLASS_FITS_IN_CELL(ObjectConstructor);
ObjectConstructor::ObjectConstructor(ExecState* exec, PassRefPtr<Structure> structure, ObjectPrototype* objectPrototype)
: InternalFunction(&exec->globalData(), structure, Identifier(exec, "Object"))
{
putDirectWithoutTransition(exec->propertyNames().prototype, objectPrototype, DontEnum | DontDelete | ReadOnly);
putDirectWithoutTransition(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontEnum | DontDelete);
}
static ALWAYS_INLINE JSObject* constructObject(ExecState* exec, const ArgList& args)
{
JSValue arg = args.at(0);
if (arg.isUndefinedOrNull())
return new (exec) JSObject(exec->lexicalGlobalObject()->emptyObjectStructure());
return arg.toObject(exec);
}
static JSObject* constructWithObjectConstructor(ExecState* exec, JSObject*, const ArgList& args)
{
return constructObject(exec, args);
}
ConstructType ObjectConstructor::getConstructData(ConstructData& constructData)
{
constructData.native.function = constructWithObjectConstructor;
return ConstructTypeHost;
}
static JSValue JSC_HOST_CALL callObjectConstructor(ExecState* exec, JSObject*, JSValue, const ArgList& args)
{
return constructObject(exec, args);
}
CallType ObjectConstructor::getCallData(CallData& callData)
{
callData.native.function = callObjectConstructor;
return CallTypeHost;
}
}