ErrorConstructor.cpp [plain text]
#include "config.h"
#include "ErrorConstructor.h"
#include "ErrorPrototype.h"
#include "JSGlobalObject.h"
#include "JSString.h"
namespace JSC {
ASSERT_CLASS_FITS_IN_CELL(ErrorConstructor);
ErrorConstructor::ErrorConstructor(ExecState* exec, PassRefPtr<Structure> structure, ErrorPrototype* errorPrototype)
: InternalFunction(&exec->globalData(), structure, Identifier(exec, errorPrototype->classInfo()->className))
{
putDirectWithoutTransition(exec->propertyNames().prototype, errorPrototype, DontEnum | DontDelete | ReadOnly);
putDirectWithoutTransition(exec->propertyNames().length, jsNumber(exec, 1), DontDelete | ReadOnly | DontEnum);
}
ErrorInstance* constructError(ExecState* exec, const ArgList& args)
{
ErrorInstance* obj = new (exec) ErrorInstance(exec->lexicalGlobalObject()->errorStructure());
if (!args.at(0).isUndefined())
obj->putDirect(exec->propertyNames().message, jsString(exec, args.at(0).toString(exec)));
return obj;
}
static JSObject* constructWithErrorConstructor(ExecState* exec, JSObject*, const ArgList& args)
{
return constructError(exec, args);
}
ConstructType ErrorConstructor::getConstructData(ConstructData& constructData)
{
constructData.native.function = constructWithErrorConstructor;
return ConstructTypeHost;
}
static JSValue JSC_HOST_CALL callErrorConstructor(ExecState* exec, JSObject*, JSValue, const ArgList& args)
{
return constructError(exec, args);
}
CallType ErrorConstructor::getCallData(CallData& callData)
{
callData.native.function = callErrorConstructor;
return CallTypeHost;
}
}