aboutsummaryrefslogtreecommitdiffstats
path: root/qmljs_objects.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@digia.com>2012-11-29 14:39:19 +0100
committerLars Knoll <lars.knoll@digia.com>2012-11-29 16:18:21 +0100
commit36356a4b273e19ca599bf2a0cbfb02fda69e6c0a (patch)
tree7f10a6334a95de4d85cc2efae9cc88fa526e910d /qmljs_objects.cpp
parent968fc9c6c9f3532e9456b3bf9049e6aa2282de7a (diff)
Set the name of a function in more (most?) cases.
Change-Id: I1c2b9d61b6d97e3c2a8cb976fb6be8b68d51ae28 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'qmljs_objects.cpp')
-rw-r--r--qmljs_objects.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/qmljs_objects.cpp b/qmljs_objects.cpp
index d55006024b..28932e371c 100644
--- a/qmljs_objects.cpp
+++ b/qmljs_objects.cpp
@@ -76,7 +76,8 @@ void Object::__put__(ExecutionContext *ctx, const QString &name, const Value &va
void Object::__put__(ExecutionContext *ctx, const QString &name, Value (*code)(ExecutionContext *), int count)
{
Q_UNUSED(count);
- __put__(ctx, name, Value::fromObject(ctx->engine->newNativeFunction(ctx, code)));
+ String *nameStr = ctx->engine->newString(name);
+ __put__(ctx, name, Value::fromObject(ctx->engine->newNativeFunction(ctx, nameStr, code)));
}
Value Object::getValue(ExecutionContext *ctx, PropertyDescriptor *p) const
@@ -510,6 +511,12 @@ Value EvalFunction::call(ExecutionContext *context, Value /*thisObject*/, Value
return result;
}
+EvalFunction::EvalFunction(ExecutionContext *scope)
+ : FunctionObject(scope)
+{
+ name = scope->engine->newString(QLatin1String("eval"));
+}
+
QQmlJS::IR::Function *EvalFunction::parseSource(QQmlJS::VM::ExecutionContext *ctx,
const QString &fileName, const QString &source,
QQmlJS::Codegen::Mode mode)
@@ -585,6 +592,12 @@ QQmlJS::IR::Function *EvalFunction::parseSource(QQmlJS::VM::ExecutionContext *ct
/// isNaN [15.1.2.4]
+IsNaNFunction::IsNaNFunction(ExecutionContext *scope)
+ : FunctionObject(scope)
+{
+ name = scope->engine->newString(QLatin1String("isNaN"));
+}
+
Value IsNaNFunction::call(ExecutionContext * /*context*/, Value /*thisObject*/, Value *args, int /*argc*/)
{
// TODO: see if we can generate code for this directly
@@ -593,6 +606,12 @@ Value IsNaNFunction::call(ExecutionContext * /*context*/, Value /*thisObject*/,
}
/// isFinite [15.1.2.5]
+IsFiniteFunction::IsFiniteFunction(ExecutionContext *scope)
+ : FunctionObject(scope)
+{
+ name = scope->engine->newString(QLatin1String("isFinite"));
+}
+
Value IsFiniteFunction::call(ExecutionContext * /*context*/, Value /*thisObject*/, Value *args, int /*argc*/)
{
// TODO: see if we can generate code for this directly
@@ -709,3 +728,11 @@ PropertyDescriptor *ArgumentsObject::__getPropertyDescriptor__(ExecutionContext
return Object::__getPropertyDescriptor__(ctx, name, to_fill);
}
+
+
+NativeFunction::NativeFunction(ExecutionContext *scope, String *name, Value (*code)(ExecutionContext *))
+ : FunctionObject(scope)
+ , code(code)
+{
+ this->name = name;
+}