2 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
3 * Copyright (C) 2003, 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
22 #include "ErrorConstructor.h"
24 #include "ErrorPrototype.h"
25 #include "Interpreter.h"
26 #include "JSGlobalObject.h"
28 #include "JSCInlines.h"
32 STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(ErrorConstructor
);
34 const ClassInfo
ErrorConstructor::s_info
= { "Function", &Base::s_info
, 0, 0, CREATE_METHOD_TABLE(ErrorConstructor
) };
36 ErrorConstructor::ErrorConstructor(VM
& vm
, Structure
* structure
)
37 : InternalFunction(vm
, structure
)
41 void ErrorConstructor::finishCreation(VM
& vm
, ErrorPrototype
* errorPrototype
)
43 Base::finishCreation(vm
, errorPrototype
->classInfo()->className
);
44 // ECMA 15.11.3.1 Error.prototype
45 putDirectWithoutTransition(vm
, vm
.propertyNames
->prototype
, errorPrototype
, DontEnum
| DontDelete
| ReadOnly
);
46 putDirectWithoutTransition(vm
, vm
.propertyNames
->length
, jsNumber(1), DontDelete
| ReadOnly
| DontEnum
);
51 EncodedJSValue JSC_HOST_CALL
Interpreter::constructWithErrorConstructor(ExecState
* exec
)
53 JSValue message
= exec
->argumentCount() ? exec
->argument(0) : jsUndefined();
54 Structure
* errorStructure
= asInternalFunction(exec
->callee())->globalObject()->errorStructure();
55 Vector
<StackFrame
> stackTrace
;
56 exec
->vm().interpreter
->getStackTrace(stackTrace
, std::numeric_limits
<size_t>::max());
58 return JSValue::encode(ErrorInstance::create(exec
, errorStructure
, message
, stackTrace
));
61 ConstructType
ErrorConstructor::getConstructData(JSCell
*, ConstructData
& constructData
)
63 constructData
.native
.function
= Interpreter::constructWithErrorConstructor
;
64 return ConstructTypeHost
;
67 EncodedJSValue JSC_HOST_CALL
Interpreter::callErrorConstructor(ExecState
* exec
)
69 JSValue message
= exec
->argumentCount() ? exec
->argument(0) : jsUndefined();
70 Structure
* errorStructure
= asInternalFunction(exec
->callee())->globalObject()->errorStructure();
71 Vector
<StackFrame
> stackTrace
;
72 exec
->vm().interpreter
->getStackTrace(stackTrace
, std::numeric_limits
<size_t>::max());
74 return JSValue::encode(ErrorInstance::create(exec
, errorStructure
, message
, stackTrace
));
77 CallType
ErrorConstructor::getCallData(JSCell
*, CallData
& callData
)
79 callData
.native
.function
= Interpreter::callErrorConstructor
;