Remove toPrimitive from JSCell
https://bugs.webkit.org/show_bug.cgi?id=67875
Reviewed by Darin Adler.
Part of the refactoring process to un-virtualize JSCell. We move
all of the implicit functionality provided by the virtual toPrimitive method
in JSCell to be explicit in JSValue::toPrimitive and JSCell:toPrimitive while
also de-virtualizing JSCell::toPrimitive.
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
* runtime/JSCell.cpp:
(JSC::JSCell::toPrimitive):
* runtime/JSCell.h:
We replace JSNotAnObject::toPrimitive with defaultValue, which it overrides from
JSObject. This pushes the virtual method further down, enabling us to get rid
of the virtual call in JSCell. Eventually we'll probably have to deal with this
again, but we'll cross that bridge when we come to it.
* runtime/JSNotAnObject.cpp:
(JSC::JSNotAnObject::defaultValue):
* runtime/JSNotAnObject.h:
* runtime/JSObject.h:
* runtime/JSString.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@95516 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/runtime/JSCell.cpp b/Source/JavaScriptCore/runtime/JSCell.cpp
index 9a93c59..f112cc4 100644
--- a/Source/JavaScriptCore/runtime/JSCell.cpp
+++ b/Source/JavaScriptCore/runtime/JSCell.cpp
@@ -117,10 +117,11 @@
return JSValue();
}
-JSValue JSCell::toPrimitive(ExecState*, PreferredPrimitiveType) const
+JSValue JSCell::toPrimitive(ExecState* exec, PreferredPrimitiveType preferredType) const
{
- ASSERT_NOT_REACHED();
- return JSValue();
+ if (isString())
+ return static_cast<const JSString*>(this)->toPrimitive(exec, preferredType);
+ return static_cast<const JSObject*>(this)->toPrimitive(exec, preferredType);
}
bool JSCell::getPrimitiveNumber(ExecState*, double&, JSValue&)