X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/14957cd040308e3eeec43d26bae5d76da13fcd85..a253471d7f8e4d91bf6ebabab00155c3b387d3d0:/runtime/ErrorInstance.h?ds=sidebyside diff --git a/runtime/ErrorInstance.h b/runtime/ErrorInstance.h index afcf158..d6fa32f 100644 --- a/runtime/ErrorInstance.h +++ b/runtime/ErrorInstance.h @@ -27,26 +27,41 @@ namespace JSC { class ErrorInstance : public JSNonFinalObject { public: + typedef JSNonFinalObject Base; + static const ClassInfo s_info; - static Structure* createStructure(JSGlobalData& globalData, JSValue prototype) + static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype) { - return Structure::create(globalData, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info); + return Structure::create(globalData, globalObject, prototype, TypeInfo(ErrorInstanceType, StructureFlags), &s_info); } - static ErrorInstance* create(JSGlobalData*, Structure*, const UString&); - static ErrorInstance* create(ExecState*, Structure*, JSValue message); + static ErrorInstance* create(JSGlobalData& globalData, Structure* structure, const UString& message) + { + ErrorInstance* instance = new (NotNull, allocateCell(globalData.heap)) ErrorInstance(globalData, structure); + instance->finishCreation(globalData, message); + return instance; + } + static ErrorInstance* create(ExecState* exec, Structure* structure, JSValue message) + { + return create(exec->globalData(), structure, message.isUndefined() ? UString() : message.toString(exec)->value(exec)); + } 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(JSGlobalData&, Structure*); + + void finishCreation(JSGlobalData& globalData, const UString& message) + { + Base::finishCreation(globalData); + ASSERT(inherits(&s_info)); + if (!message.isNull()) + putDirect(globalData, globalData.propertyNames->message, jsString(&globalData, message), DontEnum); + } bool m_appendSourceToMessage; };