From 150e18e05bbf3600c02861e046776f1f72758a08 Mon Sep 17 00:00:00 2001 From: nitrix Date: Thu, 5 Mar 2020 16:40:31 +0100 Subject: [PATCH] inspec type of expression instead of the type of the assignment, since the assignment type is always null --- .../de/hsrm/compiler/Klang/visitors/GenASM.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/hsrm/compiler/Klang/visitors/GenASM.java b/src/main/java/de/hsrm/compiler/Klang/visitors/GenASM.java index 4735a05..d75e87f 100644 --- a/src/main/java/de/hsrm/compiler/Klang/visitors/GenASM.java +++ b/src/main/java/de/hsrm/compiler/Klang/visitors/GenASM.java @@ -577,14 +577,15 @@ public class GenASM implements Visitor { public Void visit(VariableAssignment e) { e.expression.welcome(this); int offset = this.env.get(e.name); - // TODO: Check why e.type is null - // x = (x - 1) - // if (e.type.equals(Type.getFloatType())) { - // this.ex.write(" movq %xmm0, " + offset + "(%rbp)\n"); - // } else { - // this.ex.write(" movq %rax, " + offset + "(%rbp)\n"); - // } - this.ex.write(" movq %rax, " + offset + "(%rbp)\n"); + + // Determine where the result of this expression was placed into + // and move it onto the stack from there + if (e.expression.type.equals(Type.getFloatType())) { + this.ex.write(" movq %xmm0, " + offset + "(%rbp)\n"); + } else { + this.ex.write(" movq %rax, " + offset + "(%rbp)\n"); + } + return null; }