]>
git.saurik.com Git - apple/javascriptcore.git/blob - runtime/ErrorInstance.h
d6fa32f99cf3b3dc4b0f1249397f5d607556527d
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(JSGlobalData
& globalData
, JSGlobalObject
* globalObject
, JSValue prototype
)
36 return Structure::create(globalData
, globalObject
, prototype
, TypeInfo(ErrorInstanceType
, StructureFlags
), &s_info
);
39 static ErrorInstance
* create(JSGlobalData
& globalData
, Structure
* structure
, const UString
& message
)
41 ErrorInstance
* instance
= new (NotNull
, allocateCell
<ErrorInstance
>(globalData
.heap
)) ErrorInstance(globalData
, structure
);
42 instance
->finishCreation(globalData
, message
);
46 static ErrorInstance
* create(ExecState
* exec
, Structure
* structure
, JSValue message
)
48 return create(exec
->globalData(), structure
, message
.isUndefined() ? UString() : 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(JSGlobalData
&, Structure
*);
58 void finishCreation(JSGlobalData
& globalData
, const UString
& message
)
60 Base::finishCreation(globalData
);
61 ASSERT(inherits(&s_info
));
62 if (!message
.isNull())
63 putDirect(globalData
, globalData
.propertyNames
->message
, jsString(&globalData
, message
), DontEnum
);
66 bool m_appendSourceToMessage
;
71 #endif // ErrorInstance_h