F(LoadTemp, loadTemp) \
F(MoveTemp, moveTemp) \
F(LoadName, loadName) \
+ F(StoreName, storeName) \
F(Push, push) \
F(Call, call) \
F(Jump, jump) \
F(CJump, jump) \
F(Binop, binop) \
- F(ActivateProperty, activateProperty)
+ F(LoadThis, loadThis)
#if defined(Q_CC_GNU) && (!defined(Q_CC_INTEL) || __INTEL_COMPILER >= 1200)
# define MOTH_THREADED_INTERPRETER
};
struct instr_loadName {
MOTH_INSTR_HEADER
- VM::String *value;
+ VM::String *name;
+ };
+ struct instr_storeName {
+ MOTH_INSTR_HEADER
+ VM::String *name;
};
struct instr_push {
MOTH_INSTR_HEADER
int rhsTempIndex;
VM::Value (*alu)(const VM::Value , const VM::Value, VM::Context *);
};
- struct instr_activateProperty {
+ struct instr_loadThis {
MOTH_INSTR_HEADER
- VM::String *propName;
};
instr_common common;
instr_loadString loadString;
instr_loadClosure loadClosure;
instr_loadName loadName;
+ instr_storeName storeName;
instr_push push;
instr_call call;
instr_jump jump;
instr_binop binop;
- instr_activateProperty activateProperty;
+ instr_loadThis loadThis;
static int size(Type type);
};
if (IR::Name *n = c->base->asName()) {
if (n->builtin == IR::Name::builtin_invalid) {
Instruction::LoadName load;
- load.value = _engine->newString(*n->id);
+ load.name = _engine->newString(*n->id);
addInstruction(load);
} else {
Q_UNIMPLEMENTED();
Q_UNUSED(n);
// set activation property
if (IR::Temp *t = s->source->asTemp()) {
+ // TODO: fold the next 2 instructions.
Instruction::LoadTemp load;
load.tempIndex = t->index;
addInstruction(load);
- Instruction::ActivateProperty activate;
- activate.propName = _engine->newString(*n->id);
- addInstruction(activate);
+ Instruction::StoreName store;
+ store.name = _engine->newString(*n->id);
+ addInstruction(store);
} else {
Q_UNREACHABLE();
}
} else if (IR::Temp *t = s->target->asTemp()) {
-
+ // Check what kind of load it is, and generate the instruction for that.
+ // The store to the temp (the target) is done afterwards.
if (IR::Name *n = s->source->asName()) {
Q_UNUSED(n);
- qWarning(" NAME");
+ if (*n->id == QStringLiteral("this")) { // ### `this' should be a builtin.
+ addInstruction(Instruction::LoadThis());
+ } else {
+ Instruction::LoadName load;
+ load.name = _engine->newString(*n->id);
+ addInstruction(load);
+ }
} else if (IR::Const *c = s->source->asConst()) {
switch (c->type) {
case IR::UndefinedType:
using namespace QQmlJS::Moth;
#ifdef DO_TRACE_INSTR
-# define TRACE_INSTR(I) fprintf(stderr, "%s\n", #I);
+# define TRACE_INSTR(I) fprintf(stderr, "executing a %s\n", #I);
# define TRACE(n, str, ...) { fprintf(stderr, "-- %s : ", #n); fprintf(stderr, str, __VA_ARGS__); fprintf(stderr, "\n"); }
#else
# define TRACE_INSTR(I)
MOTH_END_INSTR(LoadClosure)
MOTH_BEGIN_INSTR(LoadName)
- tempRegister = __qmljs_get_activation_property(context, instr.value);
+ TRACE(inline, "property name = %s", instr.name->toQString().toUtf8().constData());
+ tempRegister = __qmljs_get_activation_property(context, instr.name);
MOTH_END_INSTR(LoadName)
+ MOTH_BEGIN_INSTR(StoreName)
+ TRACE(inline, "property name = %s", instr.name->toQString().toUtf8().constData());
+ __qmljs_set_activation_property(context, instr.name, tempRegister);
+ MOTH_END_INSTR(StoreName)
+
MOTH_BEGIN_INSTR(Push)
stack.resize(instr.value);
MOTH_END_INSTR(Push)
return;
MOTH_END_INSTR(Ret)
- MOTH_BEGIN_INSTR(ActivateProperty)
- TRACE(inline, "property name = %s", instr.propName->toQString().toUtf8().constData());
- __qmljs_set_activation_property(context, instr.propName, tempRegister);
- MOTH_END_INSTR(ActivateProperty)
+ MOTH_BEGIN_INSTR(LoadThis)
+ tempRegister = __qmljs_get_thisObject(context);
+ MOTH_END_INSTR(LoadThis)
#ifdef MOTH_THREADED_INTERPRETER
// nothing to do