Skip to content

Commit

Permalink
fix a bad bad bug
Browse files Browse the repository at this point in the history
  • Loading branch information
MESYETI committed Jan 31, 2025
1 parent 10ff6d9 commit a06d606
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 11 deletions.
6 changes: 4 additions & 2 deletions source/backends/arm64.d
Original file line number Diff line number Diff line change
Expand Up @@ -1105,13 +1105,15 @@ class BackendARM64 : CompilerBackend {
output ~= format("add x9, x9, #%d\n", offset);
output ~= "str x9, [x19], #8\n";
}
else if (VariableExists(node.func)) {
else if (VariableExists(name)) {
auto var = GetVariable(name);

output ~= format("add x9, x20, #%d\n", var.offset + offset);
output ~= "str x9, [x19], #8\n";
}
else assert(0);
else {
Error(node.error, "Variable '%s' does not exist", name);
}
}
else {
Error(node.error, "Undefined identifier '%s'", node.func);
Expand Down
6 changes: 4 additions & 2 deletions source/backends/lua.d
Original file line number Diff line number Diff line change
Expand Up @@ -788,13 +788,15 @@ class BackendLua : CompilerBackend {
output ~= format("mem[dsp] = %d\n", extra.addr + offset);
output ~= "dsp = dsp + 1\n";
}
else if (VariableExists(node.func)) {
else if (VariableExists(name)) {
auto var = GetVariable(name);

output ~= format("mem[dsp] = vsp + %d\n", var.offset + offset);
output ~= "dsp = dsp + 1";
}
else assert(0);
else {
Error(node.error, "Variable '%s' does not exist", name);
}
}
else {
Error(node.error, "Undefined identifier '%s'", node.func);
Expand Down
6 changes: 4 additions & 2 deletions source/backends/rm86.d
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ class BackendRM86 : CompilerBackend {
output ~= "mov [si], ax\n";
output ~= "add si, 2\n";
}
else if (VariableExists(node.func)) {
else if (VariableExists(name)) {
auto var = GetVariable(name);

output ~= "mov ax, si\n";
Expand All @@ -905,7 +905,9 @@ class BackendRM86 : CompilerBackend {
output ~= "mov [si], ax\n";
output ~= "add si, 2\n";
}
else assert(0);
else {
Error(node.error, "Variable '%s' does not exist", name);
}
}
else {
Error(node.error, "Undefined identifier '%s'", node.func);
Expand Down
6 changes: 4 additions & 2 deletions source/backends/uxn.d
Original file line number Diff line number Diff line change
Expand Up @@ -821,11 +821,13 @@ class BackendUXN : CompilerBackend {
auto var = GetGlobal(name);
output ~= format(";global_%s #%.4x ADD2\n", name.Sanitise(), offset);
}
else if (VariableExists(node.func)) {
else if (VariableExists(name)) {
auto var = GetVariable(name);
output ~= format(".vsp LDZ2 #%.4x ADD2\n", var.offset + offset);
}
else assert(0);
else {
Error(node.error, "Variable '%s' does not exist", name);
}
}
else if (GlobalExists(node.func)) {
output ~= format(";global_%s\n", node.func.Sanitise());
Expand Down
6 changes: 4 additions & 2 deletions source/backends/x86_64.d
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@ class BackendX86_64 : CompilerBackend {
output ~= "mov [r15], rax\n";
output ~= "add r15, 8\n";
}
else if (VariableExists(node.func)) {
else if (VariableExists(name)) {
auto var = GetVariable(name);

output ~= "mov rdi, rsp\n";
Expand All @@ -1219,7 +1219,9 @@ class BackendX86_64 : CompilerBackend {
output ~= "mov [r15], rdi\n";
output ~= "add r15, 8\n";
}
else assert(0);
else {
Error(node.error, "Variable '%s' does not exist", name);
}
}
else {
Error(node.error, "Undefined identifier '%s'", node.func);
Expand Down
2 changes: 1 addition & 1 deletion source/compiler.d
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class CompilerBackend {
members ~= member.name;

offset += newMember.array?
newMember.type.size * newMember.size : newMember.type.size;
newMember.type.Size() * newMember.size : newMember.type.size;
}

foreach (ref member ; entries) {
Expand Down

0 comments on commit a06d606

Please sign in to comment.