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);
const ClassInfo ErrorConstructor::s_info = { "Function", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(ErrorConstructor) };
ErrorConstructor::ErrorConstructor(JSGlobalObject* globalObject, Structure* structure)
: InternalFunction(globalObject, structure)
{
}
void ErrorConstructor::finishCreation(ExecState* exec, ErrorPrototype* errorPrototype)
{
Base::finishCreation(exec->globalData(), Identifier(exec, errorPrototype->classInfo()->className));
putDirectWithoutTransition(exec->globalData(), exec->propertyNames().prototype, errorPrototype, DontEnum | DontDelete | ReadOnly);
putDirectWithoutTransition(exec->globalData(), exec->propertyNames().length, jsNumber(1), DontDelete | ReadOnly | DontEnum);
}
static EncodedJSValue JSC_HOST_CALL constructWithErrorConstructor(ExecState* exec)
{
JSValue message = exec->argumentCount() ? exec->argument(0) : jsUndefined();
Structure* errorStructure = asInternalFunction(exec->callee())->globalObject()->errorStructure();
return JSValue::encode(ErrorInstance::create(exec, errorStructure, message));
}
ConstructType ErrorConstructor::getConstructData(JSCell*, ConstructData& constructData)
{
constructData.native.function = constructWithErrorConstructor;
return ConstructTypeHost;
}
static EncodedJSValue JSC_HOST_CALL callErrorConstructor(ExecState* exec)
{
JSValue message = exec->argumentCount() ? exec->argument(0) : jsUndefined();
Structure* errorStructure = asInternalFunction(exec->callee())->globalObject()->errorStructure();
return JSValue::encode(ErrorInstance::create(exec, errorStructure, message));
}
CallType ErrorConstructor::getCallData(JSCell*, CallData& callData)
{
callData.native.function = callErrorConstructor;
return CallTypeHost;
}
}