Skip to content

Commit 2b8b8d3

Browse files
committed
make uxn backend use module prefixes
1 parent efafe0e commit 2b8b8d3

File tree

6 files changed

+193
-105
lines changed

6 files changed

+193
-105
lines changed

source/app.d

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ Backend options:
7676
use-libc - Makes Callisto use the C runtime and links libc
7777
frame-ptr - Makes Callisto use both rbp (frame pointer) and rsp for stack frames
7878
use-gas - Makes Callisto use GNU Assembler instead of nasm
79+
uxn:
80+
asm=ASM - Uses ASM as the assembler, instead of `uxnasm`
7981
8082
Programs:
8183
cac link <MODULES...> - Links MODULES... together into one executable

source/backends/arm64.d

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ class BackendARM64 : CompilerBackend {
331331
}
332332

333333
foreach (var ; globals) {
334+
if (var.mod != output.GetModName()) continue;
335+
334336
output ~= format(".lcomm %s, %d\n", Label("__global_", var.name.Sanitise()), var.Size());
335337

336338
if (exportSymbols) {

source/backends/rm86.d

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,7 @@ class BackendRM86 : CompilerBackend {
103103
// what?
104104
foreach (global ; globals) {
105105
if (global.type.hasInit && !global.type.ptr) {
106-
if (
107-
(output.mode == OutputMode.Module) &&
108-
(global.mod != output.GetModName())
109-
) {
106+
if (output.mode == OutputMode.Module) {
110107
continue;
111108
}
112109

@@ -116,8 +113,10 @@ class BackendRM86 : CompilerBackend {
116113
);
117114
output ~= "add si, 2\n";
118115
output ~= format(
119-
"call %s\n",
120-
Label("__type_init_", "%s", global.type.name.Sanitise())
116+
"call %s\n", ExtLabel(
117+
global.type.mod, "__type_init_", "%s",
118+
global.type.name.Sanitise()
119+
)
121120
);
122121
}
123122
}
@@ -171,9 +170,17 @@ class BackendRM86 : CompilerBackend {
171170
override void End() {
172171
foreach (global ; globals) {
173172
if (global.type.hasDeinit && !global.type.ptr) {
174-
output ~= format("mov word [si], word __global_%s\n", Sanitise(global.name));
173+
output ~= format(
174+
"mov word [si], word %s\n",
175+
Label("__global_", "%s", Sanitise(global.name))
176+
);
175177
output ~= "add si, 2\n";
176-
output ~= format("call __type_deinit_%s\n", Sanitise(global.type.name));
178+
output ~= format(
179+
"call __type_deinit_%s\n", ExtLabel(
180+
global.type.mod, "__type_deinit_", "%s",
181+
Sanitise(global.type.name)
182+
)
183+
);
177184
}
178185
}
179186

@@ -201,6 +208,8 @@ class BackendRM86 : CompilerBackend {
201208

202209
output.StartSection(SectionType.Data);
203210
foreach (var ; globals) {
211+
if (var.mod != output.GetModName()) continue;
212+
204213
output ~= format(
205214
"%s: times %d db 0\n",
206215
Label("__global_", "%s", var.name.Sanitise()), var.Size()
@@ -410,6 +419,10 @@ class BackendRM86 : CompilerBackend {
410419
else if (IsStructMember(node.name)) {
411420
string name = node.name[0 .. node.name.countUntil(".")];
412421
auto structVar = GetStructVariable(node, node.name);
422+
423+
if (CountAll(name)) {
424+
Error(node.error, "Multiple matches for identifier '%s'", name);
425+
}
413426

414427
if (structVar.structure) {
415428
Error(node.error, "Can't push the value of an array or structure");

0 commit comments

Comments
 (0)