Skip to content

Commit e1d867f

Browse files
authored
Merge pull request #36 from soxfox42/main
Fix address operator on struct and struct pointer fields
2 parents a06d606 + f0b31cd commit e1d867f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

source/backends/arm64.d

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,14 +1101,23 @@ class BackendARM64 : CompilerBackend {
11011101
if (GlobalExists(name)) {
11021102
auto var = GetGlobal(name);
11031103

1104-
LoadAddress("x9", format("__global_%s", node.func.Sanitise()));
1104+
LoadAddress("x9", format("__global_%s", name.Sanitise()));
1105+
if (var.type.ptr) {
1106+
output ~= "ldr x9, [x9]\n";
1107+
}
11051108
output ~= format("add x9, x9, #%d\n", offset);
11061109
output ~= "str x9, [x19], #8\n";
11071110
}
11081111
else if (VariableExists(name)) {
11091112
auto var = GetVariable(name);
11101113

1111-
output ~= format("add x9, x20, #%d\n", var.offset + offset);
1114+
if (var.type.ptr) {
1115+
output ~= format("add x9, x20, #%d\n", var.offset);
1116+
output ~= "ldr x9, [x9]\n";
1117+
output ~= format("add x9, x9, #%d\n", offset);
1118+
} else {
1119+
output ~= format("add x9, x20, #%d\n", var.offset + offset);
1120+
}
11121121
output ~= "str x9, [x19], #8\n";
11131122
}
11141123
else {

0 commit comments

Comments
 (0)