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<ErrorInstance>(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;
};