ErrorConstructor.cpp [plain text]
#include "config.h"
#include "ErrorConstructor.h"
#include "ErrorPrototype.h"
#include "Interpreter.h"
#include "JSGlobalObject.h"
#include "JSString.h"
#include "JSCInlines.h"
namespace JSC {
STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(ErrorConstructor);
const ClassInfo ErrorConstructor::s_info = { "Function", &Base::s_info, 0, CREATE_METHOD_TABLE(ErrorConstructor) };
ErrorConstructor::ErrorConstructor(VM& vm, Structure* structure)
: InternalFunction(vm, structure)
{
}
void ErrorConstructor::finishCreation(VM& vm, ErrorPrototype* errorPrototype)
{
Base::finishCreation(vm, ASCIILiteral("Error"));
putDirectWithoutTransition(vm, vm.propertyNames->prototype, errorPrototype, DontEnum | DontDelete | ReadOnly);
putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), DontDelete | ReadOnly | DontEnum);
}
EncodedJSValue JSC_HOST_CALL Interpreter::constructWithErrorConstructor(ExecState* exec)
{
JSValue message = exec->argumentCount() ? exec->argument(0) : jsUndefined();
Structure* errorStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), asInternalFunction(exec->callee())->globalObject()->errorStructure());
if (exec->hadException())
return JSValue::encode(JSValue());
return JSValue::encode(ErrorInstance::create(exec, errorStructure, message, nullptr, TypeNothing, false));
}
ConstructType ErrorConstructor::getConstructData(JSCell*, ConstructData& constructData)
{
constructData.native.function = Interpreter::constructWithErrorConstructor;
return ConstructType::Host;
}
EncodedJSValue JSC_HOST_CALL Interpreter::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, nullptr, TypeNothing, false));
}
CallType ErrorConstructor::getCallData(JSCell*, CallData& callData)
{
callData.native.function = Interpreter::callErrorConstructor;
return CallType::Host;
}
}