2008-06-30 Sam Weinig <sam@webkit.org>
Rubber-stamped by Darin Adler.
Remove internal.cpp and move its contents to there own .cpp files.
* GNUmakefile.am:
* JavaScriptCore.pri:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* JavaScriptCoreSources.bkl:
* kjs/AllInOneFile.cpp:
* kjs/GetterSetter.cpp: Copied from kjs/internal.cpp.
* kjs/InternalFunction.cpp: Copied from kjs/internal.cpp.
* kjs/JSNumberCell.cpp: Copied from kjs/internal.cpp.
* kjs/JSString.cpp: Copied from kjs/internal.cpp.
* kjs/JSString.h:
* kjs/LabelStack.cpp: Copied from kjs/internal.cpp.
* kjs/NumberConstructor.cpp:
* kjs/NumberObject.cpp:
(KJS::constructNumber):
(KJS::constructNumberFromImmediateNumber):
* kjs/internal.cpp: Removed.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@34893 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/kjs/AllInOneFile.cpp b/JavaScriptCore/kjs/AllInOneFile.cpp
index 5eccf21..cfb32ad 100644
--- a/JavaScriptCore/kjs/AllInOneFile.cpp
+++ b/JavaScriptCore/kjs/AllInOneFile.cpp
@@ -51,7 +51,11 @@
#include "FunctionPrototype.cpp"
#include "grammar.cpp"
#include "identifier.cpp"
-#include "internal.cpp"
+#include "JSString.cpp"
+#include "JSNumberCell.cpp"
+#include "GetterSetter.cpp"
+#include "LabelStack.cpp"
+#include "InternalFunction.cpp"
#include "interpreter.cpp"
#include "JSImmediate.cpp"
#include "JSLock.cpp"
diff --git a/JavaScriptCore/kjs/GetterSetter.cpp b/JavaScriptCore/kjs/GetterSetter.cpp
new file mode 100644
index 0000000..df2e8d4
--- /dev/null
+++ b/JavaScriptCore/kjs/GetterSetter.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 1999-2002 Harri Porten (porten@kde.org)
+ * Copyright (C) 2001 Peter Kelly (pmk@post.com)
+ * Copyright (C) 2004, 2007, 2008 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "JSObject.h"
+
+#include <wtf/Assertions.h>
+
+namespace KJS {
+
+void GetterSetter::mark()
+{
+ JSCell::mark();
+
+ if (m_getter && !m_getter->marked())
+ m_getter->mark();
+ if (m_setter && !m_setter->marked())
+ m_setter->mark();
+}
+
+JSValue* GetterSetter::toPrimitive(ExecState*, JSType) const
+{
+ ASSERT_NOT_REACHED();
+ return jsNull();
+}
+
+bool GetterSetter::getPrimitiveNumber(ExecState*, double& number, JSValue*& value)
+{
+ ASSERT_NOT_REACHED();
+ number = 0;
+ value = 0;
+ return true;
+}
+
+bool GetterSetter::toBoolean(ExecState*) const
+{
+ ASSERT_NOT_REACHED();
+ return false;
+}
+
+double GetterSetter::toNumber(ExecState*) const
+{
+ ASSERT_NOT_REACHED();
+ return 0.0;
+}
+
+UString GetterSetter::toString(ExecState*) const
+{
+ ASSERT_NOT_REACHED();
+ return UString::null();
+}
+
+JSObject* GetterSetter::toObject(ExecState* exec) const
+{
+ ASSERT_NOT_REACHED();
+ return jsNull()->toObject(exec);
+}
+
+}
diff --git a/JavaScriptCore/kjs/InternalFunction.cpp b/JavaScriptCore/kjs/InternalFunction.cpp
new file mode 100644
index 0000000..466d9ac
--- /dev/null
+++ b/JavaScriptCore/kjs/InternalFunction.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 1999-2002 Harri Porten (porten@kde.org)
+ * Copyright (C) 2001 Peter Kelly (pmk@post.com)
+ * Copyright (C) 2004, 2007, 2008 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "JSFunction.h"
+
+#include "FunctionPrototype.h"
+
+namespace KJS {
+
+const ClassInfo InternalFunction::info = { "Function", 0, 0, 0 };
+
+InternalFunction::InternalFunction()
+{
+}
+
+InternalFunction::InternalFunction(FunctionPrototype* prototype, const Identifier& name)
+ : JSObject(prototype)
+ , m_name(name)
+{
+}
+
+bool InternalFunction::implementsHasInstance() const
+{
+ return true;
+}
+
+} // namespace KJS
diff --git a/JavaScriptCore/kjs/JSNumberCell.cpp b/JavaScriptCore/kjs/JSNumberCell.cpp
new file mode 100644
index 0000000..ff917fa
--- /dev/null
+++ b/JavaScriptCore/kjs/JSNumberCell.cpp
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 1999-2002 Harri Porten (porten@kde.org)
+ * Copyright (C) 2001 Peter Kelly (pmk@post.com)
+ * Copyright (C) 2004, 2007, 2008 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "JSValue.h"
+
+#include "JSType.h"
+#include "NumberObject.h"
+#include "ustring.h"
+
+namespace KJS {
+
+JSType JSNumberCell::type() const
+{
+ return NumberType;
+}
+
+JSValue* JSNumberCell::toPrimitive(ExecState*, JSType) const
+{
+ return const_cast<JSNumberCell*>(this);
+}
+
+bool JSNumberCell::getPrimitiveNumber(ExecState*, double& number, JSValue*& value)
+{
+ number = val;
+ value = this;
+ return true;
+}
+
+bool JSNumberCell::toBoolean(ExecState *) const
+{
+ return val < 0.0 || val > 0.0; // false for NaN
+}
+
+double JSNumberCell::toNumber(ExecState *) const
+{
+ return val;
+}
+
+UString JSNumberCell::toString(ExecState*) const
+{
+ if (val == 0.0) // +0.0 or -0.0
+ return "0";
+ return UString::from(val);
+}
+
+UString JSNumberCell::toThisString(ExecState*) const
+{
+ if (val == 0.0) // +0.0 or -0.0
+ return "0";
+ return UString::from(val);
+}
+
+JSObject* JSNumberCell::toObject(ExecState* exec) const
+{
+ return constructNumber(exec, const_cast<JSNumberCell*>(this));
+}
+
+JSObject* JSNumberCell::toThisObject(ExecState* exec) const
+{
+ return constructNumber(exec, const_cast<JSNumberCell*>(this));
+}
+
+bool JSNumberCell::getUInt32(uint32_t& uint32) const
+{
+ uint32 = static_cast<uint32_t>(val);
+ return uint32 == val;
+}
+
+bool JSNumberCell::getTruncatedInt32(int32_t& int32) const
+{
+ if (!(val >= -2147483648.0 && val < 2147483648.0))
+ return false;
+ int32 = static_cast<int32_t>(val);
+ return true;
+}
+
+bool JSNumberCell::getTruncatedUInt32(uint32_t& uint32) const
+{
+ if (!(val >= 0.0 && val < 4294967296.0))
+ return false;
+ uint32 = static_cast<uint32_t>(val);
+ return true;
+}
+
+JSValue* JSNumberCell::getJSNumber()
+{
+ return this;
+}
+
+} // namespace KJS
diff --git a/JavaScriptCore/kjs/JSString.cpp b/JavaScriptCore/kjs/JSString.cpp
new file mode 100644
index 0000000..9d6cc79
--- /dev/null
+++ b/JavaScriptCore/kjs/JSString.cpp
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 1999-2002 Harri Porten (porten@kde.org)
+ * Copyright (C) 2001 Peter Kelly (pmk@post.com)
+ * Copyright (C) 2004, 2007, 2008 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "JSString.h"
+
+#include "JSGlobalObject.h"
+#include "JSObject.h"
+#include "StringObject.h"
+#include "StringPrototype.h"
+
+namespace KJS {
+
+JSValue* JSString::toPrimitive(ExecState*, JSType) const
+{
+ return const_cast<JSString*>(this);
+}
+
+bool JSString::getPrimitiveNumber(ExecState*, double& number, JSValue*& value)
+{
+ value = this;
+ number = m_value.toDouble();
+ return false;
+}
+
+bool JSString::toBoolean(ExecState*) const
+{
+ return !m_value.isEmpty();
+}
+
+double JSString::toNumber(ExecState*) const
+{
+ return m_value.toDouble();
+}
+
+UString JSString::toString(ExecState*) const
+{
+ return m_value;
+}
+
+UString JSString::toThisString(ExecState*) const
+{
+ return m_value;
+}
+
+JSString* JSString::toThisJSString(ExecState*)
+{
+ return this;
+}
+
+inline StringObject* StringObject::create(ExecState* exec, JSString* string)
+{
+ return new (exec) StringObject(exec->lexicalGlobalObject()->stringPrototype(), string);
+}
+
+JSObject* JSString::toObject(ExecState* exec) const
+{
+ return StringObject::create(exec, const_cast<JSString*>(this));
+}
+
+JSObject* JSString::toThisObject(ExecState* exec) const
+{
+ return StringObject::create(exec, const_cast<JSString*>(this));
+}
+
+JSValue* JSString::lengthGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
+{
+ return jsNumber(exec, static_cast<JSString*>(slot.slotBase())->value().size());
+}
+
+JSValue* JSString::indexGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
+{
+ return jsString(exec, static_cast<JSString*>(slot.slotBase())->value().substr(slot.index(), 1));
+}
+
+JSValue* JSString::indexNumericPropertyGetter(ExecState* exec, unsigned index, const PropertySlot& slot)
+{
+ return jsString(exec, static_cast<JSString*>(slot.slotBase())->value().substr(index, 1));
+}
+
+bool JSString::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
+{
+ // The semantics here are really getPropertySlot, not getOwnPropertySlot.
+ // This function should only be called by JSValue::get.
+ if (getStringPropertySlot(exec, propertyName, slot))
+ return true;
+ slot.setBase(this);
+ JSObject* object;
+ for (JSValue* prototype = exec->lexicalGlobalObject()->stringPrototype(); prototype != jsNull(); prototype = object->prototype()) {
+ ASSERT(prototype->isObject());
+ object = static_cast<JSObject*>(prototype);
+ if (object->getOwnPropertySlot(exec, propertyName, slot))
+ return true;
+ }
+ slot.setUndefined();
+ return true;
+}
+
+bool JSString::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
+{
+ // The semantics here are really getPropertySlot, not getOwnPropertySlot.
+ // This function should only be called by JSValue::get.
+ if (getStringPropertySlot(propertyName, slot))
+ return true;
+ return JSString::getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot);
+}
+
+} // namespace KJS
diff --git a/JavaScriptCore/kjs/JSString.h b/JavaScriptCore/kjs/JSString.h
index 169c6347..1385840 100644
--- a/JavaScriptCore/kjs/JSString.h
+++ b/JavaScriptCore/kjs/JSString.h
@@ -24,7 +24,10 @@
#ifndef JSString_h
#define JSString_h
-#include "JSObject.h"
+#include "CommonIdentifiers.h"
+#include "JSValue.h"
+#include "PropertySlot.h"
+#include "identifier.h"
#include "ustring.h"
namespace KJS {
@@ -94,4 +97,4 @@
} // namespace
-#endif // JSString_h
+#endif // JSString_h
diff --git a/JavaScriptCore/kjs/LabelStack.cpp b/JavaScriptCore/kjs/LabelStack.cpp
new file mode 100644
index 0000000..3bb2e4b
--- /dev/null
+++ b/JavaScriptCore/kjs/LabelStack.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 1999-2002 Harri Porten (porten@kde.org)
+ * Copyright (C) 2001 Peter Kelly (pmk@post.com)
+ * Copyright (C) 2004, 2007, 2008 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "LabelStack.h"
+
+namespace KJS {
+
+bool LabelStack::push(const Identifier &id)
+{
+ if (contains(id))
+ return false;
+
+ StackElem *newtos = new StackElem;
+ newtos->id = id;
+ newtos->prev = tos;
+ tos = newtos;
+ return true;
+}
+
+bool LabelStack::contains(const Identifier &id) const
+{
+ if (id.isEmpty())
+ return true;
+
+ for (StackElem *curr = tos; curr; curr = curr->prev)
+ if (curr->id == id)
+ return true;
+
+ return false;
+}
+
+} // namespace KJS
diff --git a/JavaScriptCore/kjs/NumberConstructor.cpp b/JavaScriptCore/kjs/NumberConstructor.cpp
index 8e336ab..ed1d736 100644
--- a/JavaScriptCore/kjs/NumberConstructor.cpp
+++ b/JavaScriptCore/kjs/NumberConstructor.cpp
@@ -101,18 +101,4 @@
return CallTypeNative;
}
-NumberObject* constructNumber(ExecState* exec, JSNumberCell* number)
-{
- NumberObject* obj = new (exec) NumberObject(exec->lexicalGlobalObject()->numberPrototype());
- obj->setInternalValue(number);
- return obj;
-}
-
-NumberObject* constructNumberFromImmediateNumber(ExecState* exec, JSValue* value)
-{
- NumberObject* obj = new (exec) NumberObject(exec->lexicalGlobalObject()->numberPrototype());
- obj->setInternalValue(value);
- return obj;
-}
-
} // namespace KJS
diff --git a/JavaScriptCore/kjs/NumberObject.cpp b/JavaScriptCore/kjs/NumberObject.cpp
index b568d02..30758a2 100644
--- a/JavaScriptCore/kjs/NumberObject.cpp
+++ b/JavaScriptCore/kjs/NumberObject.cpp
@@ -22,6 +22,9 @@
#include "config.h"
#include "NumberObject.h"
+#include "JSGlobalObject.h"
+#include "NumberPrototype.h"
+
namespace KJS {
const ClassInfo NumberObject::info = { "Number", 0, 0, 0 };
@@ -36,4 +39,18 @@
return internalValue();
}
+NumberObject* constructNumber(ExecState* exec, JSNumberCell* number)
+{
+ NumberObject* obj = new (exec) NumberObject(exec->lexicalGlobalObject()->numberPrototype());
+ obj->setInternalValue(number);
+ return obj;
+}
+
+NumberObject* constructNumberFromImmediateNumber(ExecState* exec, JSValue* value)
+{
+ NumberObject* obj = new (exec) NumberObject(exec->lexicalGlobalObject()->numberPrototype());
+ obj->setInternalValue(value);
+ return obj;
+}
+
} // namespace KJS
diff --git a/JavaScriptCore/kjs/internal.cpp b/JavaScriptCore/kjs/internal.cpp
deleted file mode 100644
index acd37c5..0000000
--- a/JavaScriptCore/kjs/internal.cpp
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * Copyright (C) 1999-2002 Harri Porten (porten@kde.org)
- * Copyright (C) 2001 Peter Kelly (pmk@post.com)
- * Copyright (C) 2004, 2007, 2008 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "JSString.h"
-
-#include "ExecState.h"
-#include "FunctionPrototype.h"
-#include "JSObject.h"
-#include "MathObject.h"
-#include "NumberObject.h"
-#include "StringPrototype.h"
-#include "collector.h"
-#include "debugger.h"
-#include "lexer.h"
-#include "nodes.h"
-#include "operations.h"
-#include <math.h>
-#include <stdio.h>
-#include <wtf/Assertions.h>
-#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
-#include <wtf/Vector.h>
-
-namespace KJS {
-
-// ------------------------------ JSString ------------------------------------
-
-JSValue* JSString::toPrimitive(ExecState*, JSType) const
-{
- return const_cast<JSString*>(this);
-}
-
-bool JSString::getPrimitiveNumber(ExecState*, double& number, JSValue*& value)
-{
- value = this;
- number = m_value.toDouble();
- return false;
-}
-
-bool JSString::toBoolean(ExecState*) const
-{
- return !m_value.isEmpty();
-}
-
-double JSString::toNumber(ExecState*) const
-{
- return m_value.toDouble();
-}
-
-UString JSString::toString(ExecState*) const
-{
- return m_value;
-}
-
-UString JSString::toThisString(ExecState*) const
-{
- return m_value;
-}
-
-JSString* JSString::toThisJSString(ExecState*)
-{
- return this;
-}
-
-inline StringObject* StringObject::create(ExecState* exec, JSString* string)
-{
- return new (exec) StringObject(exec->lexicalGlobalObject()->stringPrototype(), string);
-}
-
-JSObject* JSString::toObject(ExecState* exec) const
-{
- return StringObject::create(exec, const_cast<JSString*>(this));
-}
-
-JSObject* JSString::toThisObject(ExecState* exec) const
-{
- return StringObject::create(exec, const_cast<JSString*>(this));
-}
-
-JSValue* JSString::lengthGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
-{
- return jsNumber(exec, static_cast<JSString*>(slot.slotBase())->value().size());
-}
-
-JSValue* JSString::indexGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
-{
- return jsString(exec, static_cast<JSString*>(slot.slotBase())->value().substr(slot.index(), 1));
-}
-
-JSValue* JSString::indexNumericPropertyGetter(ExecState* exec, unsigned index, const PropertySlot& slot)
-{
- return jsString(exec, static_cast<JSString*>(slot.slotBase())->value().substr(index, 1));
-}
-
-bool JSString::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
-{
- // The semantics here are really getPropertySlot, not getOwnPropertySlot.
- // This function should only be called by JSValue::get.
- if (getStringPropertySlot(exec, propertyName, slot))
- return true;
- slot.setBase(this);
- JSObject* object;
- for (JSValue* prototype = exec->lexicalGlobalObject()->stringPrototype(); prototype != jsNull(); prototype = object->prototype()) {
- ASSERT(prototype->isObject());
- object = static_cast<JSObject*>(prototype);
- if (object->getOwnPropertySlot(exec, propertyName, slot))
- return true;
- }
- slot.setUndefined();
- return true;
-}
-
-bool JSString::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
-{
- // The semantics here are really getPropertySlot, not getOwnPropertySlot.
- // This function should only be called by JSValue::get.
- if (getStringPropertySlot(propertyName, slot))
- return true;
- return JSString::getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot);
-}
-
-// ------------------------------ JSNumberCell ------------------------------------
-
-JSType JSNumberCell::type() const
-{
- return NumberType;
-}
-
-JSValue* JSNumberCell::toPrimitive(ExecState*, JSType) const
-{
- return const_cast<JSNumberCell*>(this);
-}
-
-bool JSNumberCell::getPrimitiveNumber(ExecState*, double& number, JSValue*& value)
-{
- number = val;
- value = this;
- return true;
-}
-
-bool JSNumberCell::toBoolean(ExecState *) const
-{
- return val < 0.0 || val > 0.0; // false for NaN
-}
-
-double JSNumberCell::toNumber(ExecState *) const
-{
- return val;
-}
-
-UString JSNumberCell::toString(ExecState*) const
-{
- if (val == 0.0) // +0.0 or -0.0
- return "0";
- return UString::from(val);
-}
-
-UString JSNumberCell::toThisString(ExecState*) const
-{
- if (val == 0.0) // +0.0 or -0.0
- return "0";
- return UString::from(val);
-}
-
-JSObject* JSNumberCell::toObject(ExecState* exec) const
-{
- return constructNumber(exec, const_cast<JSNumberCell*>(this));
-}
-
-JSObject* JSNumberCell::toThisObject(ExecState* exec) const
-{
- return constructNumber(exec, const_cast<JSNumberCell*>(this));
-}
-
-bool JSNumberCell::getUInt32(uint32_t& uint32) const
-{
- uint32 = static_cast<uint32_t>(val);
- return uint32 == val;
-}
-
-bool JSNumberCell::getTruncatedInt32(int32_t& int32) const
-{
- if (!(val >= -2147483648.0 && val < 2147483648.0))
- return false;
- int32 = static_cast<int32_t>(val);
- return true;
-}
-
-bool JSNumberCell::getTruncatedUInt32(uint32_t& uint32) const
-{
- if (!(val >= 0.0 && val < 4294967296.0))
- return false;
- uint32 = static_cast<uint32_t>(val);
- return true;
-}
-
-JSValue* JSNumberCell::getJSNumber()
-{
- return this;
-}
-
-// --------------------------- GetterSetter ---------------------------------
-
-void GetterSetter::mark()
-{
- JSCell::mark();
-
- if (m_getter && !m_getter->marked())
- m_getter->mark();
- if (m_setter && !m_setter->marked())
- m_setter->mark();
-}
-
-JSValue* GetterSetter::toPrimitive(ExecState*, JSType) const
-{
- ASSERT_NOT_REACHED();
- return jsNull();
-}
-
-bool GetterSetter::getPrimitiveNumber(ExecState*, double& number, JSValue*& value)
-{
- ASSERT_NOT_REACHED();
- number = 0;
- value = 0;
- return true;
-}
-
-bool GetterSetter::toBoolean(ExecState*) const
-{
- ASSERT_NOT_REACHED();
- return false;
-}
-
-double GetterSetter::toNumber(ExecState*) const
-{
- ASSERT_NOT_REACHED();
- return 0.0;
-}
-
-UString GetterSetter::toString(ExecState*) const
-{
- ASSERT_NOT_REACHED();
- return UString::null();
-}
-
-JSObject* GetterSetter::toObject(ExecState* exec) const
-{
- ASSERT_NOT_REACHED();
- return jsNull()->toObject(exec);
-}
-
-// ------------------------------ LabelStack -----------------------------------
-
-bool LabelStack::push(const Identifier &id)
-{
- if (contains(id))
- return false;
-
- StackElem *newtos = new StackElem;
- newtos->id = id;
- newtos->prev = tos;
- tos = newtos;
- return true;
-}
-
-bool LabelStack::contains(const Identifier &id) const
-{
- if (id.isEmpty())
- return true;
-
- for (StackElem *curr = tos; curr; curr = curr->prev)
- if (curr->id == id)
- return true;
-
- return false;
-}
-
-// ------------------------------ InternalFunction --------------------------
-
-const ClassInfo InternalFunction::info = { "Function", 0, 0, 0 };
-
-InternalFunction::InternalFunction()
-{
-}
-
-InternalFunction::InternalFunction(FunctionPrototype* prototype, const Identifier& name)
- : JSObject(prototype)
- , m_name(name)
-{
-}
-
-bool InternalFunction::implementsHasInstance() const
-{
- return true;
-}
-
-}