From 59c7dad30755a18d74f23ac644e16c0f7d39fbe4 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Fri, 4 May 2012 13:03:14 +0200 Subject: [PATCH] Add copy instructions to the qmljs runtime --- qmljs_runtime.cpp | 12 ++++++++++++ qmljs_runtime.h | 2 ++ qv4isel.cpp | 6 ++++++ 3 files changed, 20 insertions(+) diff --git a/qmljs_runtime.cpp b/qmljs_runtime.cpp index c6a2dd9..cc811c7 100644 --- a/qmljs_runtime.cpp +++ b/qmljs_runtime.cpp @@ -189,6 +189,11 @@ void __qmljs_set_activation_property(Context *ctx, String *name, Value *value) __qmljs_set_property(ctx, &ctx->activation, name, value); } +void __qmljs_copy_activation_property(Context *ctx, String *name, String *other) +{ + __qmljs_copy_property(ctx, &ctx->activation, name, &ctx->activation, other); +} + void __qmljs_set_activation_property_boolean(Context *ctx, String *name, bool value) { __qmljs_set_property_boolean(ctx, &ctx->activation, name, value); @@ -225,6 +230,13 @@ void __qmljs_get_thisObject(Context *ctx, Value *result) *result = ctx->thisObject; } +void __qmljs_copy_property(Context *ctx, Value *target, String *name, Value *source, String *other) +{ + Value v; + source->objectValue->get(other, &v); + target->objectValue->put(name, v); +} + void __qmljs_compare(Context *ctx, Value *result, const Value *x, const Value *y, bool leftFirst) { Value px, py; diff --git a/qmljs_runtime.h b/qmljs_runtime.h index f31f54c..18d0c61 100644 --- a/qmljs_runtime.h +++ b/qmljs_runtime.h @@ -80,6 +80,8 @@ void __qmljs_set_activation_property_number(Context *ctx, String *name, double v void __qmljs_set_activation_property_string(Context *ctx, String *name, String *value); void __qmljs_get_property(Context *ctx, Value *result, Value *object, String *name); void __qmljs_get_activation_property(Context *ctx, Value *result, String *name); +void __qmljs_copy_activation_property(Context *ctx, String *name, String *other); +void __qmljs_copy_property(Context *ctx, Value *target, String *name, Value *source, String *other); // context void __qmljs_get_activation(Context *ctx, Value *result); diff --git a/qv4isel.cpp b/qv4isel.cpp index 78e67a1..6c25b66 100644 --- a/qv4isel.cpp +++ b/qv4isel.cpp @@ -248,6 +248,12 @@ void InstructionSelection::visitMove(IR::Move *s) loadTempAddress(AMD64_RDX, t); amd64_call_code(_codePtr, __qmljs_set_activation_property); return; + } else if (IR::Name *other = s->source->asName()) { + amd64_mov_reg_reg(_codePtr, AMD64_RDI, AMD64_R14, 8); + amd64_mov_reg_imm(_codePtr, AMD64_RSI, propertyName); + amd64_mov_reg_imm(_codePtr, AMD64_RDX, identifier(*other->id)); + amd64_call_code(_codePtr, __qmljs_copy_activation_property); + return; } } else if (IR::Temp *t = s->target->asTemp()) { if (IR::Name *n = s->source->asName()) { -- 2.7.4