*result = Value::fromString(__qmljs_string_from_utf8(ctx, str));
}
-void __qmljs_llvm_init_native_function(ExecutionContext *ctx, Value *result, Value (*code)(ExecutionContext *))
+void __qmljs_llvm_init_native_function(ExecutionContext *ctx, Value *result, String *name, Value (*code)(ExecutionContext *))
{
- *result = __qmljs_init_native_function(code, ctx);
+ *result = __qmljs_init_native_function(name, code, ctx);
}
bool __qmljs_llvm_to_boolean(ExecutionContext *ctx, const Value *value)
struct Print: FunctionObject
{
- Print(ExecutionContext *scope): FunctionObject(scope) {}
+ Print(ExecutionContext *scope): FunctionObject(scope) {
+ name = scope->engine->newString("print");
+ }
virtual Value call(ExecutionContext *ctx)
{
struct TestHarnessError: FunctionObject
{
- TestHarnessError(ExecutionContext *scope, bool &errorInTestHarness): FunctionObject(scope), errorOccurred(errorInTestHarness) {}
+ TestHarnessError(ExecutionContext *scope, bool &errorInTestHarness): FunctionObject(scope), errorOccurred(errorInTestHarness) {
+ name = scope->engine->newString("$ERROR");
+ }
virtual Value call(ExecutionContext *ctx)
{
return id;
}
-FunctionObject *ExecutionEngine::newNativeFunction(ExecutionContext *scope, Value (*code)(ExecutionContext *))
+FunctionObject *ExecutionEngine::newNativeFunction(ExecutionContext *scope, String *name, Value (*code)(ExecutionContext *))
{
- NativeFunction *f = new NativeFunction(scope, code);
+ NativeFunction *f = new NativeFunction(scope, name, code);
f->prototype = scope->engine->functionPrototype;
return f;
}
String *identifier(const QString &s);
- FunctionObject *newNativeFunction(ExecutionContext *scope, Value (*code)(ExecutionContext *));
+ FunctionObject *newNativeFunction(ExecutionContext *scope, String *name, Value (*code)(ExecutionContext *));
FunctionObject *newScriptFunction(ExecutionContext *scope, IR::Function *function);
Object *newObject();
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
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)
/// 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
}
/// 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
return Object::__getPropertyDescriptor__(ctx, name, to_fill);
}
+
+
+NativeFunction::NativeFunction(ExecutionContext *scope, String *name, Value (*code)(ExecutionContext *))
+ : FunctionObject(scope)
+ , code(code)
+{
+ this->name = name;
+}
struct NativeFunction: FunctionObject {
Value (*code)(ExecutionContext *);
- NativeFunction(ExecutionContext *scope, Value (*code)(ExecutionContext *)): FunctionObject(scope), code(code) {}
+ NativeFunction(ExecutionContext *scope, String *name, Value (*code)(ExecutionContext *));
virtual Value call(ExecutionContext *ctx) { return code(ctx); }
virtual Value construct(ExecutionContext *ctx) { ctx->thisObject = code(ctx); return ctx->thisObject; }
};
struct EvalFunction : FunctionObject
{
- EvalFunction(ExecutionContext *scope): FunctionObject(scope) {}
+ EvalFunction(ExecutionContext *scope);
static QQmlJS::IR::Function *parseSource(QQmlJS::VM::ExecutionContext *ctx,
const QString &fileName, const QString &source,
struct IsNaNFunction: FunctionObject
{
- IsNaNFunction(ExecutionContext *scope): FunctionObject(scope) {}
+ IsNaNFunction(ExecutionContext *scope);
virtual Value call(ExecutionContext *context, Value thisObject, Value *args, int argc);
};
struct IsFiniteFunction: FunctionObject
{
- IsFiniteFunction(ExecutionContext *scope): FunctionObject(scope) {}
+ IsFiniteFunction(ExecutionContext *scope);
virtual Value call(ExecutionContext *context, Value thisObject, Value *args, int argc);
};
return Value::fromObject(ctx->engine->newScriptFunction(ctx, clos));
}
-Value __qmljs_init_native_function(Value (*code)(ExecutionContext *), ExecutionContext *ctx)
+Value __qmljs_init_native_function(String *name, Value (*code)(ExecutionContext *), ExecutionContext *ctx)
{
- return Value::fromObject(ctx->engine->newNativeFunction(ctx, code));
+ return Value::fromObject(ctx->engine->newNativeFunction(ctx, name, code));
}
Value __qmljs_string_literal_undefined(ExecutionContext *ctx)
// constructors
Value __qmljs_init_closure(IR::Function *clos, ExecutionContext *ctx);
-Value __qmljs_init_native_function(Value (*code)(ExecutionContext *), ExecutionContext *ctx);
+Value __qmljs_init_native_function(String *name, Value (*code)(ExecutionContext *), ExecutionContext *ctx);
Bool __qmljs_is_function(Value value);