void __qmljs_llvm_get_property(ExecutionContext *ctx, Value *result, Value *object, String *name)
{
- *result = __qmljs_get_property(ctx, *object, name);
+ __qmljs_get_property(ctx, result, object, name);
}
void __qmljs_llvm_call_property(ExecutionContext *context, Value *result, const Value *base, String *name, Value *args, int argc)
void __qmljs_llvm_set_property(ExecutionContext *ctx, Value *object, String *name, Value *value)
{
- __qmljs_set_property(ctx, *object, name, *value);
+ __qmljs_set_property(ctx, object, name, value);
}
void __qmljs_llvm_builtin_declare_var(ExecutionContext *ctx, bool deletable, String *name)
addInstruction(load);
}
-void InstructionSelection::setProperty(IR::Expr *source, IR::Temp *targetBase, const QString &targetName)
+void InstructionSelection::setProperty(IR::Temp *source, IR::Temp *targetBase, const QString &targetName)
{
Instruction::StoreProperty store;
store.base = getParam(targetBase);
virtual void setActivationProperty(IR::Temp *source, const QString &targetName);
virtual void initClosure(IR::Closure *closure, IR::Temp *target);
virtual void getProperty(IR::Temp *base, const QString &name, IR::Temp *target);
- virtual void setProperty(IR::Expr *source, IR::Temp *targetBase, const QString &targetName);
+ virtual void setProperty(IR::Temp *source, IR::Temp *targetBase, const QString &targetName);
virtual void getElement(IR::Temp *base, IR::Temp *index, IR::Temp *target);
virtual void setElement(IR::Expr *source, IR::Temp *targetBase, IR::Temp *targetIndex);
virtual void copyValue(IR::Temp *sourceTemp, IR::Temp *targetTemp);
MOTH_END_INSTR(StoreElement)
MOTH_BEGIN_INSTR(LoadProperty)
- VALUE(instr.result) = __qmljs_get_property(context, VALUE(instr.base), instr.name);
+ __qmljs_get_property(context, VALUEPTR(instr.result), VALUEPTR(instr.base), instr.name);
MOTH_END_INSTR(LoadProperty)
MOTH_BEGIN_INSTR(StoreProperty)
- __qmljs_set_property(context, VALUE(instr.base), instr.name, VALUE(instr.source));
+ __qmljs_set_property(context, VALUEPTR(instr.base), instr.name, VALUEPTR(instr.source));
MOTH_END_INSTR(StoreProperty)
MOTH_BEGIN_INSTR(Push)
return Value::fromObject(ctx->engine->newStringObject(ctx, value));
}
-void __qmljs_set_property(ExecutionContext *ctx, Value object, String *name, Value value)
+void __qmljs_set_property(ExecutionContext *ctx, const Value *object, String *name, const Value *value)
{
- if (! object.isObject())
- object = __qmljs_to_object(object, ctx);
- object.objectValue()->__put__(ctx, name, value);
+ Object *o = object->isObject() ? object->objectValue() : __qmljs_to_object(*object, ctx).objectValue();
+ o->__put__(ctx, name, *value);
}
Value __qmljs_get_element(ExecutionContext *ctx, Value object, Value index)
ctx->setProperty(name, *value);
}
-Value __qmljs_get_property(ExecutionContext *ctx, Value object, String *name)
+void __qmljs_get_property(ExecutionContext *ctx, Value *result, Value *object, String *name)
{
- if (object.isObject()) {
- return object.objectValue()->__get__(ctx, name);
- } else if (object.isString() && name->isEqualTo(ctx->engine->id_length)) {
- return Value::fromInt32(object.stringValue()->toQString().length());
+ Value res;
+ Object *o = object->asObject();
+ if (o) {
+ res = o->__get__(ctx, name);
+ } else if (object->isString() && name->isEqualTo(ctx->engine->id_length)) {
+ res = Value::fromInt32(object->stringValue()->toQString().length());
} else {
- object = __qmljs_to_object(object, ctx);
-
- if (object.isObject()) {
- return object.objectValue()->__get__(ctx, name);
- } else {
- ctx->throwTypeError();
- return Value::undefinedValue();
- }
+ o = __qmljs_to_object(*object, ctx).objectValue();
+ res = o->__get__(ctx, name);
}
+ if (result)
+ *result = res;
}
void __qmljs_get_activation_property(ExecutionContext *ctx, Value *result, String *name)
*result = ctx->getProperty(name);
}
-Value __qmljs_get_property_lookup(ExecutionContext *ctx, Value object, int lookupIndex)
+void __qmljs_get_property_lookup(ExecutionContext *ctx, Value *result, const Value *object, int lookupIndex)
{
+ Value res;
Lookup *l = ctx->lookups + lookupIndex;
- if (Object *o = object.asObject()) {
+ if (Object *o = object->asObject()) {
PropertyDescriptor *p = 0;
if (o->internalClass == l->mainClass) {
if (!l->protoClass) {
}
if (p)
- return p->type == PropertyDescriptor::Data ? p->value : o->getValue(ctx, p);
+ res = p->type == PropertyDescriptor::Data ? p->value : o->getValue(ctx, p);
else
- return object.objectValue()->__get__(ctx, l->name);
- }
-
- if (object.isString() && l->name->isEqualTo(ctx->engine->id_length)) {
- return Value::fromInt32(object.stringValue()->toQString().length());
+ res = o->__get__(ctx, l->name);
} else {
- object = __qmljs_to_object(object, ctx);
-
- if (object.isObject()) {
- return object.objectValue()->__get__(ctx, l->name);
+ if (object->isString() && l->name->isEqualTo(ctx->engine->id_length)) {
+ res = Value::fromInt32(object->stringValue()->toQString().length());
} else {
- ctx->throwTypeError();
- return Value::undefinedValue();
+ o = __qmljs_to_object(*object, ctx).objectValue();
+ res = o->__get__(ctx, l->name);
}
}
+ if (result)
+ *result = res;
}
-void __qmljs_set_property_lookup(ExecutionContext *ctx, Value object, int lookupIndex, Value value)
+void __qmljs_set_property_lookup(ExecutionContext *ctx, const Value *object, int lookupIndex, const Value *value)
{
- if (! object.isObject())
- object = __qmljs_to_object(object, ctx);
-
- Object *o = object.objectValue();
+ Object *o = object->isObject() ? object->objectValue() : __qmljs_to_object(*object, ctx).objectValue();
Lookup *l = ctx->lookups + lookupIndex;
if (l->index != ArrayObject::LengthPropertyIndex || !o->isArrayObject()) {
if (o->internalClass == l->mainClass) {
- o->putValue(ctx, o->memberData + l->index, value);
+ o->putValue(ctx, o->memberData + l->index, *value);
return;
}
if (idx < UINT_MAX) {
l->mainClass = o->internalClass;
l->index = idx;
- return o->putValue(ctx, o->memberData + idx, value);
+ return o->putValue(ctx, o->memberData + idx, *value);
}
}
- o->__put__(ctx, l->name, value);
+ o->__put__(ctx, l->name, *value);
}
Value __qmljs_new_number_object(ExecutionContext *ctx, double n);
Value __qmljs_new_string_object(ExecutionContext *ctx, String *string);
void __qmljs_set_activation_property(ExecutionContext *ctx, String *name, const Value *value);
-void __qmljs_set_property(ExecutionContext *ctx, Value object, String *name, Value value);
-Value __qmljs_get_property(ExecutionContext *ctx, Value object, String *name);
+void __qmljs_set_property(ExecutionContext *ctx, const Value *object, String *name, const Value *value);
+void __qmljs_get_property(ExecutionContext *ctx, Value *result, Value *object, String *name);
void __qmljs_get_activation_property(ExecutionContext *ctx, Value *result, String *name);
-Value __qmljs_get_property_lookup(ExecutionContext *ctx, Value object, int lookupIndex);
-void __qmljs_set_property_lookup(ExecutionContext *ctx, Value object, int lookupIndex, Value value);
+void __qmljs_get_property_lookup(ExecutionContext *ctx, Value *result, const Value *object, int lookupIndex);
+void __qmljs_set_property_lookup(ExecutionContext *ctx, const Value *object, int lookupIndex, const Value *value);
Value __qmljs_get_element(ExecutionContext *ctx, Value object, Value index);
_block->MOVE(_block->TEMP(t), source);
source = _block->TEMP(t);
}
- if (target->asName() && source->asConst()) {
+ if (!target->asTemp() && source->asConst()) {
unsigned t = _block->newTemp();
_block->MOVE(_block->TEMP(t), source);
source = _block->TEMP(t);
_llvmFunction->arg_begin(), t, base, name);
}
-void InstructionSelection::setProperty(IR::Expr *source, IR::Temp *targetBase, const QString &targetName)
+void InstructionSelection::setProperty(IR::Temp *source, IR::Temp *targetBase, const QString &targetName)
{
llvm::Value *base = getLLVMTempReference(targetBase);
llvm::Value *name = getIdentifier(targetName);
virtual void setActivationProperty(IR::Temp *source, const QString &targetName);
virtual void initClosure(IR::Closure *closure, IR::Temp *target);
virtual void getProperty(IR::Temp *sourceBase, const QString &sourceName, IR::Temp *target);
- virtual void setProperty(IR::Expr *source, IR::Temp *targetBase, const QString &targetName);
+ virtual void setProperty(IR::Temp *source, IR::Temp *targetBase, const QString &targetName);
virtual void getElement(IR::Temp *sourceBase, IR::Temp *sourceIndex, IR::Temp *target);
virtual void setElement(IR::Expr *source, IR::Temp *targetBase, IR::Temp *targetIndex);
virtual void copyValue(IR::Temp *sourceTemp, IR::Temp *targetTemp);
if (useFastLookups) {
VM::String *s = identifier(name);
uint index = addLookup(s);
- generateFunctionCall(target, __qmljs_get_property_lookup, Assembler::ContextRegister, base, Assembler::TrustedImm32(index));
+ generateFunctionCall(Assembler::Void, __qmljs_get_property_lookup, Assembler::ContextRegister, Assembler::PointerToValue(target),
+ Assembler::PointerToValue(base), Assembler::TrustedImm32(index));
} else {
- generateFunctionCall(target, __qmljs_get_property, Assembler::ContextRegister, base, identifier(name));
+ generateFunctionCall(Assembler::Void, __qmljs_get_property, Assembler::ContextRegister, Assembler::PointerToValue(target),
+ Assembler::PointerToValue(base), identifier(name));
}
}
-void InstructionSelection::setProperty(IR::Expr *source, IR::Temp *targetBase, const QString &targetName)
+void InstructionSelection::setProperty(IR::Temp *source, IR::Temp *targetBase, const QString &targetName)
{
if (useFastLookups) {
VM::String *s = identifier(targetName);
uint index = addLookup(s);
- generateFunctionCall(Assembler::Void, __qmljs_set_property_lookup, Assembler::ContextRegister, targetBase, Assembler::TrustedImm32(index), source);
+ generateFunctionCall(Assembler::Void, __qmljs_set_property_lookup, Assembler::ContextRegister, Assembler::PointerToValue(targetBase),
+ Assembler::TrustedImm32(index), Assembler::PointerToValue(source));
} else {
- generateFunctionCall(Assembler::Void, __qmljs_set_property, Assembler::ContextRegister, targetBase, identifier(targetName), source);
+ generateFunctionCall(Assembler::Void, __qmljs_set_property, Assembler::ContextRegister, Assembler::PointerToValue(targetBase),
+ identifier(targetName), Assembler::PointerToValue(source));
}
}
virtual void setActivationProperty(IR::Temp *source, const QString &targetName);
virtual void initClosure(IR::Closure *closure, IR::Temp *target);
virtual void getProperty(IR::Temp *base, const QString &name, IR::Temp *target);
- virtual void setProperty(IR::Expr *source, IR::Temp *targetBase, const QString &targetName);
+ virtual void setProperty(IR::Temp *source, IR::Temp *targetBase, const QString &targetName);
virtual void getElement(IR::Temp *base, IR::Temp *index, IR::Temp *target);
virtual void setElement(IR::Expr *source, IR::Temp *targetBase, IR::Temp *targetIndex);
virtual void copyValue(IR::Temp *sourceTemp, IR::Temp *targetTemp);
}
} else if (IR::Member *m = s->target->asMember()) {
if (IR::Temp *base = m->base->asTemp()) {
- if (s->source->asTemp() || s->source->asConst()) {
- setProperty(s->source, base, *m->name);
+ if (s->source->asTemp()) {
+ setProperty(s->source->asTemp(), base, *m->name);
return;
}
}
virtual void setActivationProperty(IR::Temp *source, const QString &targetName) = 0;
virtual void initClosure(IR::Closure *closure, IR::Temp *target) = 0;
virtual void getProperty(IR::Temp *base, const QString &name, IR::Temp *target) = 0;
- virtual void setProperty(IR::Expr *source, IR::Temp *targetBase, const QString &targetName) = 0;
+ virtual void setProperty(IR::Temp *source, IR::Temp *targetBase, const QString &targetName) = 0;
virtual void getElement(IR::Temp *base, IR::Temp *index, IR::Temp *target) = 0;
virtual void setElement(IR::Expr *source, IR::Temp *targetBase, IR::Temp *targetIndex) = 0;
virtual void copyValue(IR::Temp *sourceTemp, IR::Temp *targetTemp) = 0;