aboutsummaryrefslogtreecommitdiffstats
path: root/qmljs_objects.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@digia.com>2012-11-19 11:54:54 +0100
committerLars Knoll <lars.knoll@digia.com>2012-11-19 13:57:51 +0100
commitb072fd9317fa20d9206e9faaca7b0b45ae28a519 (patch)
tree8df50b7305108c52ed6899e5fa5d7f4655a14076 /qmljs_objects.cpp
parenta2676884804fb523ee586f1ebc6a11353ec79fcb (diff)
Added isNaN and isFinite to the global context.
Change-Id: Ia85d27a6ac82fd5dbf6b0f706747afa6418626b1 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'qmljs_objects.cpp')
-rw-r--r--qmljs_objects.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/qmljs_objects.cpp b/qmljs_objects.cpp
index 4f831b01bf..290a4f793c 100644
--- a/qmljs_objects.cpp
+++ b/qmljs_objects.cpp
@@ -487,6 +487,22 @@ Value EvalFunction::call(ExecutionContext *context, Value thisObject, Value *arg
ctx->leaveCallContext();
}
+/// isNaN [15.1.2.4]
+Value IsNaNFunction::call(ExecutionContext * /*context*/, Value /*thisObject*/, Value *args, int /*argc*/, bool /*strictMode*/)
+{
+ // TODO: see if we can generate code for this directly
+ const Value &v = args[0];
+ return Value::fromBoolean(v.isDouble() ? std::isnan(v.doubleValue()) : false);
+}
+
+/// isFinite [15.1.2.5]
+Value IsFiniteFunction::call(ExecutionContext * /*context*/, Value /*thisObject*/, Value *args, int /*argc*/, bool /*strictMode*/)
+{
+ // TODO: see if we can generate code for this directly
+ const Value &v = args[0];
+ return Value::fromBoolean(v.isDouble() ? std::isfinite(v.doubleValue()) : true);
+}
+
static inline bool protect(const void *addr, size_t size)
{
size_t pageSize = sysconf(_SC_PAGESIZE);