]>
Commit | Line | Data |
---|---|---|
b37bf2e1 | 1 | /* |
9dae56ea A |
2 | * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) |
3 | * Copyright (C) 2008 Apple Inc. All rights reserved. | |
b37bf2e1 A |
4 | * |
5 | * This library is free software; you can redistribute it and/or | |
6 | * modify it under the terms of the GNU Lesser General Public | |
7 | * License as published by the Free Software Foundation; either | |
8 | * version 2 of the License, or (at your option) any later version. | |
9 | * | |
10 | * This library is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * Lesser General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU Lesser General Public | |
16 | * License along with this library; if not, write to the Free Software | |
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
18 | * | |
19 | */ | |
20 | ||
9dae56ea A |
21 | #ifndef ErrorInstance_h |
22 | #define ErrorInstance_h | |
b37bf2e1 | 23 | |
9dae56ea | 24 | #include "JSObject.h" |
b37bf2e1 | 25 | |
9dae56ea | 26 | namespace JSC { |
b37bf2e1 | 27 | |
14957cd0 | 28 | class ErrorInstance : public JSNonFinalObject { |
9dae56ea | 29 | public: |
6fe7ccc8 A |
30 | typedef JSNonFinalObject Base; |
31 | ||
14957cd0 | 32 | static const ClassInfo s_info; |
b37bf2e1 | 33 | |
93a37866 | 34 | static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) |
14957cd0 | 35 | { |
93a37866 | 36 | return Structure::create(vm, globalObject, prototype, TypeInfo(ErrorInstanceType, StructureFlags), &s_info); |
14957cd0 A |
37 | } |
38 | ||
93a37866 | 39 | static ErrorInstance* create(VM& vm, Structure* structure, const String& message) |
6fe7ccc8 | 40 | { |
93a37866 A |
41 | ErrorInstance* instance = new (NotNull, allocateCell<ErrorInstance>(vm.heap)) ErrorInstance(vm, structure); |
42 | instance->finishCreation(vm, message); | |
6fe7ccc8 A |
43 | return instance; |
44 | } | |
14957cd0 | 45 | |
6fe7ccc8 A |
46 | static ErrorInstance* create(ExecState* exec, Structure* structure, JSValue message) |
47 | { | |
93a37866 | 48 | return create(exec->vm(), structure, message.isUndefined() ? String() : message.toString(exec)->value(exec)); |
6fe7ccc8 | 49 | } |
14957cd0 A |
50 | |
51 | bool appendSourceToMessage() { return m_appendSourceToMessage; } | |
52 | void setAppendSourceToMessage() { m_appendSourceToMessage = true; } | |
53 | void clearAppendSourceToMessage() { m_appendSourceToMessage = false; } | |
54 | ||
14957cd0 | 55 | protected: |
93a37866 | 56 | explicit ErrorInstance(VM&, Structure*); |
6fe7ccc8 | 57 | |
93a37866 | 58 | void finishCreation(VM& vm, const String& message) |
6fe7ccc8 | 59 | { |
93a37866 | 60 | Base::finishCreation(vm); |
6fe7ccc8 A |
61 | ASSERT(inherits(&s_info)); |
62 | if (!message.isNull()) | |
93a37866 | 63 | putDirect(vm, vm.propertyNames->message, jsString(&vm, message), DontEnum); |
6fe7ccc8 | 64 | } |
14957cd0 A |
65 | |
66 | bool m_appendSourceToMessage; | |
9dae56ea | 67 | }; |
b37bf2e1 | 68 | |
9dae56ea | 69 | } // namespace JSC |
b37bf2e1 | 70 | |
9dae56ea | 71 | #endif // ErrorInstance_h |