Fix missing code generation for inplace operations on locals.
authorErik Verbruggen <erik.verbruggen@digia.com>
Thu, 29 Nov 2012 13:36:16 +0000 (14:36 +0100)
committerLars Knoll <lars.knoll@digia.com>
Thu, 29 Nov 2012 15:17:12 +0000 (16:17 +0100)
Change-Id: I8fe7d87eabf2566f251319e8dae005aacc27eb0d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
moth/qv4isel_moth.cpp

index d166789..94a06d3 100644 (file)
@@ -578,44 +578,57 @@ void InstructionSelection::visitMove(IR::Move *s)
                 load.targetTempIndex = targetTempIndex;
                 addInstruction(load);
             }
-        } else if (IR::Const *c = s->source->asConst()) {
-            switch (c->type) {
-            case IR::UndefinedType: {
-                Instruction::LoadUndefined load;
-                load.targetTempIndex = targetTempIndex;
-                addInstruction(load);
-            } break;
-            case IR::NullType: {
-                Instruction::LoadNull load;
-                load.targetTempIndex = targetTempIndex;
-                addInstruction(load);
-            } break;
-            case IR::BoolType:
-                if (c->value) {
-                    Instruction::LoadTrue load;
-                    load.targetTempIndex = targetTempIndex;
-                    addInstruction(load);
+        } else if (s->source->asTemp() || s->source->asConst()) {
+            if (s->op == IR::OpInvalid) {
+                if (IR::Temp *t2 = s->source->asTemp()) {
+                    Instruction::MoveTemp move;
+                    move.fromTempIndex = t2->index;
+                    move.toTempIndex = targetTempIndex;
+                    addInstruction(move);
                 } else {
-                    Instruction::LoadFalse load;
-                    load.targetTempIndex = targetTempIndex;
-                    addInstruction(load);
+                    IR::Const *c = s->source->asConst();
+                    assert(c);
+                    switch (c->type) {
+                    case IR::UndefinedType: {
+                        Instruction::LoadUndefined load;
+                        load.targetTempIndex = targetTempIndex;
+                        addInstruction(load);
+                    } break;
+                    case IR::NullType: {
+                        Instruction::LoadNull load;
+                        load.targetTempIndex = targetTempIndex;
+                        addInstruction(load);
+                    } break;
+                    case IR::BoolType:
+                        if (c->value) {
+                            Instruction::LoadTrue load;
+                            load.targetTempIndex = targetTempIndex;
+                            addInstruction(load);
+                        } else {
+                            Instruction::LoadFalse load;
+                            load.targetTempIndex = targetTempIndex;
+                            addInstruction(load);
+                        }
+                        break;
+                    case IR::NumberType: {
+                        Instruction::LoadNumber load;
+                        load.value = c->value;
+                        load.targetTempIndex = targetTempIndex;
+                        addInstruction(load);
+                    } break;
+                    default:
+                        Q_UNREACHABLE();
+                        break;
+                    }
                 }
-                break;
-            case IR::NumberType: {
-                Instruction::LoadNumber load;
-                load.value = c->value;
-                load.targetTempIndex = targetTempIndex;
-                addInstruction(load);
-            } break;
-            default:
-                Q_UNREACHABLE();
-                break;
+            } else {
+                Instruction::Binop binop;
+                binop.alu = aluOpFunction(s->op);
+                binop.lhsIsTemp = toValueOrTemp(t, binop.lhs);
+                binop.rhsIsTemp = toValueOrTemp(s->source, binop.rhs);
+                binop.targetTempIndex = targetTempIndex;
+                addInstruction(binop);
             }
-        } else if (IR::Temp *t2 = s->source->asTemp()) {
-            Instruction::MoveTemp move;
-            move.fromTempIndex = t2->index;
-            move.toTempIndex = targetTempIndex;
-            addInstruction(move);
         } else if (IR::String *str = s->source->asString()) {
             Instruction::LoadString load;
             load.value = _engine->newString(*str->value);