2 * Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
3 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
4 * Copyright (C) 2003, 2007, 2008 Apple Inc. All rights reserved.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
26 #include "JSFunction.h"
29 #include <wtf/MathExtras.h>
33 bool JSCell::getString(ExecState* exec, UString&stringValue) const
37 stringValue = static_cast<const JSString*>(this)->value(exec);
41 UString JSCell::getString(ExecState* exec) const
43 return isString() ? static_cast<const JSString*>(this)->value(exec) : UString();
46 JSObject* JSCell::getObject()
48 return isObject() ? asObject(this) : 0;
51 const JSObject* JSCell::getObject() const
53 return isObject() ? static_cast<const JSObject*>(this) : 0;
56 CallType JSCell::getCallData(CallData&)
61 ConstructType JSCell::getConstructData(ConstructData&)
63 return ConstructTypeNone;
66 bool JSCell::getOwnPropertySlot(ExecState* exec, const Identifier& identifier, PropertySlot& slot)
68 // This is not a general purpose implementation of getOwnPropertySlot.
69 // It should only be called by JSValue::get.
70 // It calls getPropertySlot, not getOwnPropertySlot.
71 JSObject* object = toObject(exec, exec->lexicalGlobalObject());
73 if (!object->getPropertySlot(exec, identifier, slot))
78 bool JSCell::getOwnPropertySlot(ExecState* exec, unsigned identifier, PropertySlot& slot)
80 // This is not a general purpose implementation of getOwnPropertySlot.
81 // It should only be called by JSValue::get.
82 // It calls getPropertySlot, not getOwnPropertySlot.
83 JSObject* object = toObject(exec, exec->lexicalGlobalObject());
85 if (!object->getPropertySlot(exec, identifier, slot))
90 void JSCell::put(ExecState* exec, const Identifier& identifier, JSValue value, PutPropertySlot& slot)
92 toObject(exec, exec->lexicalGlobalObject())->put(exec, identifier, value, slot);
95 void JSCell::put(ExecState* exec, unsigned identifier, JSValue value)
97 toObject(exec, exec->lexicalGlobalObject())->put(exec, identifier, value);
100 bool JSCell::deleteProperty(ExecState* exec, const Identifier& identifier)
102 return toObject(exec, exec->lexicalGlobalObject())->deleteProperty(exec, identifier);
105 bool JSCell::deleteProperty(ExecState* exec, unsigned identifier)
107 return toObject(exec, exec->lexicalGlobalObject())->deleteProperty(exec, identifier);
110 JSObject* JSCell::toThisObject(ExecState* exec) const
112 return toObject(exec, exec->lexicalGlobalObject());
115 JSValue JSCell::getJSNumber()
120 JSValue JSCell::toPrimitive(ExecState*, PreferredPrimitiveType) const
122 ASSERT_NOT_REACHED();
126 bool JSCell::getPrimitiveNumber(ExecState*, double&, JSValue&)
128 ASSERT_NOT_REACHED();
132 double JSCell::toNumber(ExecState*) const
134 ASSERT_NOT_REACHED();
138 UString JSCell::toString(ExecState*) const
140 ASSERT_NOT_REACHED();
144 JSObject* JSCell::toObject(ExecState*, JSGlobalObject*) const
146 ASSERT_NOT_REACHED();
150 void slowValidateCell(JSCell* cell)
152 ASSERT_GC_OBJECT_LOOKS_VALID(cell);