X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/f9bf01c6616d5ddcf65b13b33cedf9e387ff7a63..217a6308cd6a1dc049a0bb69263bd4c91f91c4d0:/runtime/ErrorInstance.h?ds=sidebyside diff --git a/runtime/ErrorInstance.h b/runtime/ErrorInstance.h index 9f53b51..26a8b31 100644 --- a/runtime/ErrorInstance.h +++ b/runtime/ErrorInstance.h @@ -25,12 +25,45 @@ namespace JSC { - class ErrorInstance : public JSObject { + class ErrorInstance : public JSNonFinalObject { public: - explicit ErrorInstance(NonNullPassRefPtr); + typedef JSNonFinalObject Base; - virtual const ClassInfo* classInfo() const { return &info; } - static const ClassInfo info; + static const ClassInfo s_info; + + static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) + { + return Structure::create(vm, globalObject, prototype, TypeInfo(ErrorInstanceType, StructureFlags), &s_info); + } + + static ErrorInstance* create(VM& vm, Structure* structure, const String& message) + { + ErrorInstance* instance = new (NotNull, allocateCell(vm.heap)) ErrorInstance(vm, structure); + instance->finishCreation(vm, message); + return instance; + } + + static ErrorInstance* create(ExecState* exec, Structure* structure, JSValue message) + { + return create(exec->vm(), structure, message.isUndefined() ? String() : message.toString(exec)->value(exec)); + } + + bool appendSourceToMessage() { return m_appendSourceToMessage; } + void setAppendSourceToMessage() { m_appendSourceToMessage = true; } + void clearAppendSourceToMessage() { m_appendSourceToMessage = false; } + + protected: + explicit ErrorInstance(VM&, Structure*); + + void finishCreation(VM& vm, const String& message) + { + Base::finishCreation(vm); + ASSERT(inherits(&s_info)); + if (!message.isNull()) + putDirect(vm, vm.propertyNames->message, jsString(&vm, message), DontEnum); + } + + bool m_appendSourceToMessage; }; } // namespace JSC