#include "config.h"
#include "JSImmediate.h"
-#include "BooleanConstructor.h"
-#include "BooleanPrototype.h"
-#include "Error.h"
-#include "ExceptionHelpers.h"
-#include "JSGlobalObject.h"
-#include "JSNotAnObject.h"
-#include "NumberConstructor.h"
-#include "NumberPrototype.h"
-
namespace JSC {
-JSObject* JSImmediate::toThisObject(JSValuePtr v, ExecState* exec)
-{
- ASSERT(isImmediate(v));
- if (isNumber(v))
- return constructNumber(exec, v);
- if (isBoolean(v))
- return constructBooleanFromImmediateBoolean(exec, v);
- if (v.isNull())
- return exec->globalThisValue();
-
- JSNotAnObjectErrorStub* exception = createNotAnObjectErrorStub(exec, v.isNull());
- exec->setException(exception);
- return new (exec) JSNotAnObject(exec, exception);
-}
-
-JSObject* JSImmediate::toObject(JSValuePtr v, ExecState* exec)
-{
- ASSERT(isImmediate(v));
- if (isNumber(v))
- return constructNumber(exec, v);
- if (isBoolean(v))
- return constructBooleanFromImmediateBoolean(exec, v);
-
- JSNotAnObjectErrorStub* exception = createNotAnObjectErrorStub(exec, v.isNull());
- exec->setException(exception);
- return new (exec) JSNotAnObject(exec, exception);
-}
-
-JSObject* JSImmediate::prototype(JSValuePtr v, ExecState* exec)
-{
- ASSERT(isImmediate(v));
- if (isNumber(v))
- return exec->lexicalGlobalObject()->numberPrototype();
- if (isBoolean(v))
- return exec->lexicalGlobalObject()->booleanPrototype();
-
- JSNotAnObjectErrorStub* exception = createNotAnObjectErrorStub(exec, v.isNull());
- exec->setException(exception);
- return new (exec) JSNotAnObject(exec, exception);
-}
-
-UString JSImmediate::toString(JSValuePtr v)
-{
- ASSERT(isImmediate(v));
- if (isIntegerNumber(v))
- return UString::from(getTruncatedInt32(v));
-#if USE(ALTERNATE_JSIMMEDIATE)
- if (isNumber(v)) {
- ASSERT(isDoubleNumber(v));
- double value = doubleValue(v);
- if (value == 0.0) // +0.0 or -0.0
- return "0";
- return UString::from(value);
- }
-#else
- ASSERT(!isNumber(v));
-#endif
- if (jsBoolean(false) == v)
- return "false";
- if (jsBoolean(true) == v)
- return "true";
- if (v.isNull())
- return "null";
- ASSERT(v.isUndefined());
- return "undefined";
-}
-
-NEVER_INLINE double JSImmediate::nonInlineNaN()
-{
- return std::numeric_limits<double>::quiet_NaN();
-}
-
} // namespace JSC