X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/14957cd040308e3eeec43d26bae5d76da13fcd85..81345200c95645a1b0d2635520f96ad55dfde63f:/runtime/ErrorInstance.h diff --git a/runtime/ErrorInstance.h b/runtime/ErrorInstance.h index afcf158..91dd7ef 100644 --- a/runtime/ErrorInstance.h +++ b/runtime/ErrorInstance.h @@ -21,32 +21,43 @@ #ifndef ErrorInstance_h #define ErrorInstance_h +#include "Interpreter.h" #include "JSObject.h" +#include "SourceProvider.h" namespace JSC { class ErrorInstance : public JSNonFinalObject { public: - static const ClassInfo s_info; + typedef JSNonFinalObject Base; - static Structure* createStructure(JSGlobalData& globalData, JSValue prototype) + DECLARE_INFO; + + static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) { - return Structure::create(globalData, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info); + return Structure::create(vm, globalObject, prototype, TypeInfo(ErrorInstanceType, StructureFlags), info()); } - static ErrorInstance* create(JSGlobalData*, Structure*, const UString&); - static ErrorInstance* create(ExecState*, Structure*, JSValue message); + static ErrorInstance* create(VM& vm, Structure* structure, const String& message, Vector stackTrace = Vector()) + { + ErrorInstance* instance = new (NotNull, allocateCell(vm.heap)) ErrorInstance(vm, structure); + instance->finishCreation(vm, message, stackTrace); + return instance; + } + static ErrorInstance* create(ExecState* exec, Structure* structure, JSValue message, Vector stackTrace = Vector()) + { + return create(exec->vm(), structure, message.isUndefined() ? String() : message.toString(exec)->value(exec), stackTrace); + } bool appendSourceToMessage() { return m_appendSourceToMessage; } void setAppendSourceToMessage() { m_appendSourceToMessage = true; } void clearAppendSourceToMessage() { m_appendSourceToMessage = false; } - virtual bool isErrorInstance() const { return true; } - protected: - explicit ErrorInstance(JSGlobalData*, Structure*); - explicit ErrorInstance(JSGlobalData*, Structure*, const UString&); + explicit ErrorInstance(VM&, Structure*); + + void finishCreation(VM&, const String&, Vector = Vector()); bool m_appendSourceToMessage; };