void FunctionObject::construct(Context *ctx)
{
__qmljs_init_object(ctx, &ctx->thisObject, new Object());
- // ### set the prototype
call(ctx);
- ctx->result = ctx->thisObject;
+ Value proto;
+ if (get(String::get(ctx, QLatin1String("prototype")), &proto)) { // ### `prototype' should be a unique symbol
+ if (proto.type == OBJECT_TYPE)
+ ctx->thisObject.objectValue->prototype = proto.objectValue;
+ }
}
ScriptFunction::ScriptFunction(IR::Function *function)
void __qmljs_construct_activation_property(Context *context, Value *result, String *name)
{
+ __qmljs_construct_property(context, result, &context->activation, name);
+}
+
+void __qmljs_construct_property(Context *context, Value *result, Value *base, String *name)
+{
Value func;
- context->parent->activation.objectValue->get(name, &func);
+ Value thisObject = *base;
+ if (thisObject.type != OBJECT_TYPE)
+ __qmljs_to_object(context, &thisObject, base);
+
+ assert(thisObject.type == OBJECT_TYPE);
+ thisObject.objectValue->get(name, &func);
if (func.type == OBJECT_TYPE) {
if (FunctionObject *f = func.objectValue->asFunctionObject()) {
+ context->thisObject = thisObject;
context->formals = f->formalParameterList;
context->formalCount = f->formalParameterCount;
f->construct(context);
if (result)
- __qmljs_copy(result, &context->result);
+ __qmljs_copy(result, &context->thisObject);
} else {
assert(!"not a function");
}
void __qmljs_call_activation_property(Context *, Value *result, String *name);
void __qmljs_construct_activation_property(Context *, Value *result, String *name);
void __qmljs_call_property(Context *context, Value *result, Value *base, String *name);
+void __qmljs_construct_property(Context *context, Value *result, Value *base, String *name);
// constructors
void __qmljs_init_undefined(Context *ctx, Value *result);