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 "NativeErrorConstructor.h"
24 #include "ErrorInstance.h"
25 #include "JSFunction.h"
27 #include "NativeErrorPrototype.h"
31 ASSERT_CLASS_FITS_IN_CELL(NativeErrorConstructor);
33 const ClassInfo NativeErrorConstructor::s_info = { "Function", &InternalFunction::s_info, 0, 0 };
35 NativeErrorConstructor::NativeErrorConstructor(JSGlobalObject* globalObject, Structure* structure)
36 : InternalFunction(globalObject, structure)
40 void NativeErrorConstructor::visitChildren(SlotVisitor& visitor)
42 ASSERT_GC_OBJECT_INHERITS(this, &s_info);
43 COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
44 ASSERT(structure()->typeInfo().overridesVisitChildren());
45 InternalFunction::visitChildren(visitor);
47 visitor.append(&m_errorStructure);
50 static EncodedJSValue JSC_HOST_CALL constructWithNativeErrorConstructor(ExecState* exec)
52 JSValue message = exec->argumentCount() ? exec->argument(0) : jsUndefined();
53 Structure* errorStructure = static_cast<NativeErrorConstructor*>(exec->callee())->errorStructure();
54 ASSERT(errorStructure);
55 return JSValue::encode(ErrorInstance::create(exec, errorStructure, message));
58 ConstructType NativeErrorConstructor::getConstructData(ConstructData& constructData)
60 constructData.native.function = constructWithNativeErrorConstructor;
61 return ConstructTypeHost;
64 static EncodedJSValue JSC_HOST_CALL callNativeErrorConstructor(ExecState* exec)
66 JSValue message = exec->argumentCount() ? exec->argument(0) : jsUndefined();
67 Structure* errorStructure = static_cast<NativeErrorConstructor*>(exec->callee())->errorStructure();
68 return JSValue::encode(ErrorInstance::create(exec, errorStructure, message));
71 CallType NativeErrorConstructor::getCallData(CallData& callData)
73 callData.native.function = callNativeErrorConstructor;