]>
git.saurik.com Git - apple/javascriptcore.git/blob - runtime/ErrorInstance.h
2 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
3 * Copyright (C) 2008 Apple Inc. All rights reserved.
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.
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.
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
21 #ifndef ErrorInstance_h
22 #define ErrorInstance_h
28 class ErrorInstance
: public JSNonFinalObject
{
30 typedef JSNonFinalObject Base
;
32 static const ClassInfo s_info
;
34 static Structure
* createStructure(VM
& vm
, JSGlobalObject
* globalObject
, JSValue prototype
)
36 return Structure::create(vm
, globalObject
, prototype
, TypeInfo(ErrorInstanceType
, StructureFlags
), &s_info
);
39 static ErrorInstance
* create(VM
& vm
, Structure
* structure
, const String
& message
)
41 ErrorInstance
* instance
= new (NotNull
, allocateCell
<ErrorInstance
>(vm
.heap
)) ErrorInstance(vm
, structure
);
42 instance
->finishCreation(vm
, message
);
46 static ErrorInstance
* create(ExecState
* exec
, Structure
* structure
, JSValue message
)
48 return create(exec
->vm(), structure
, message
.isUndefined() ? String() : message
.toString(exec
)->value(exec
));
51 bool appendSourceToMessage() { return m_appendSourceToMessage
; }
52 void setAppendSourceToMessage() { m_appendSourceToMessage
= true; }
53 void clearAppendSourceToMessage() { m_appendSourceToMessage
= false; }
56 explicit ErrorInstance(VM
&, Structure
*);
58 void finishCreation(VM
& vm
, const String
& message
)
60 Base::finishCreation(vm
);
61 ASSERT(inherits(&s_info
));
62 if (!message
.isNull())
63 putDirect(vm
, vm
.propertyNames
->message
, jsString(&vm
, message
), DontEnum
);
66 bool m_appendSourceToMessage
;
71 #endif // ErrorInstance_h