glo->__put__(rootContext, identifier(QStringLiteral("Infinity")), Value::fromDouble(INFINITY));
glo->__put__(rootContext, identifier(QStringLiteral("eval")), Value::fromObject(new EvalFunction(rootContext)));
-
+ // TODO: parseInt [15.1.2.2]
+ // TODO: parseFloat [15.1.2.3]
+ glo->__put__(rootContext, identifier(QStringLiteral("isNaN")), Value::fromObject(new IsNaNFunction(rootContext))); // isNaN [15.1.2.4]
+ glo->__put__(rootContext, identifier(QStringLiteral("isFinite")), Value::fromObject(new IsFiniteFunction(rootContext))); // isFinite [15.1.2.5]
}
ExecutionContext *ExecutionEngine::newContext()
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);
virtual Value call(ExecutionContext *context, Value thisObject, Value *args, int argc, bool strictMode = false);
};
+struct IsNaNFunction: FunctionObject
+{
+ IsNaNFunction(ExecutionContext *scope): FunctionObject(scope) {}
+
+ virtual Value call(ExecutionContext *context, Value thisObject, Value *args, int argc, bool strictMode = false);
+};
+
+struct IsFiniteFunction: FunctionObject
+{
+ IsFiniteFunction(ExecutionContext *scope): FunctionObject(scope) {}
+
+ virtual Value call(ExecutionContext *context, Value thisObject, Value *args, int argc, bool strictMode = false);
+};
+
struct RegExpObject: Object {
QRegularExpression value;
Value lastIndex;