X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/14957cd040308e3eeec43d26bae5d76da13fcd85..cb9aa2694aba0ae4f946ed34b8e0f6c99c1cfe44:/runtime/ErrorInstance.cpp diff --git a/runtime/ErrorInstance.cpp b/runtime/ErrorInstance.cpp index ed95ba4..42e7c53 100644 --- a/runtime/ErrorInstance.cpp +++ b/runtime/ErrorInstance.cpp @@ -21,36 +21,30 @@ #include "config.h" #include "ErrorInstance.h" +#include "JSScope.h" +#include "JSCInlines.h" + namespace JSC { -const ClassInfo ErrorInstance::s_info = { "Error", &JSNonFinalObject::s_info, 0, 0 }; +STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(ErrorInstance); -ErrorInstance::ErrorInstance(JSGlobalData* globalData, Structure* structure) - : JSNonFinalObject(*globalData, structure) - , m_appendSourceToMessage(false) -{ - ASSERT(inherits(&s_info)); - putDirect(*globalData, globalData->propertyNames->message, jsString(globalData, "")); -} +const ClassInfo ErrorInstance::s_info = { "Error", &JSNonFinalObject::s_info, 0, 0, CREATE_METHOD_TABLE(ErrorInstance) }; -ErrorInstance::ErrorInstance(JSGlobalData* globalData, Structure* structure, const UString& message) - : JSNonFinalObject(*globalData, structure) +ErrorInstance::ErrorInstance(VM& vm, Structure* structure) + : JSNonFinalObject(vm, structure) , m_appendSourceToMessage(false) { - ASSERT(inherits(&s_info)); - putDirect(*globalData, globalData->propertyNames->message, jsString(globalData, message)); } -ErrorInstance* ErrorInstance::create(JSGlobalData* globalData, Structure* structure, const UString& message) +void ErrorInstance::finishCreation(VM& vm, const String& message, Vector stackTrace) { - return new (globalData) ErrorInstance(globalData, structure, message); + Base::finishCreation(vm); + ASSERT(inherits(info())); + if (!message.isNull()) + putDirect(vm, vm.propertyNames->message, jsString(&vm, message), DontEnum); + + if (!stackTrace.isEmpty()) + putDirect(vm, vm.propertyNames->stack, vm.interpreter->stackTraceAsString(vm.topCallFrame, stackTrace), DontEnum); } - -ErrorInstance* ErrorInstance::create(ExecState* exec, Structure* structure, JSValue message) -{ - if (message.isUndefined()) - return new (exec) ErrorInstance(&exec->globalData(), structure); - return new (exec) ErrorInstance(&exec->globalData(), structure, message.toString(exec)); -} - + } // namespace JSC