Skip to content

Commit b364df7

Browse files
committed
uxn backend less broken
1 parent e04b033 commit b364df7

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

examples/exceptions.cal

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,23 @@ include "cores/select.cal"
22
include "std/io.cal"
33

44
func __uxn_exception begin
5-
65 printch new_line
5+
&_cal_exception Exception.msg + Array.length + @ printdec new_line
6+
&_cal_exception Exception.msg + Array.memberSize + @ printdec new_line
7+
&_cal_exception Exception.msg + Array.elements + @ printdec new_line
68
1 exit
79
end
810

11+
func exception_msg begin
12+
&_cal_exception Exception.msg +
13+
end
14+
915
func error foo begin
1016
c"hi im an exception" throw
1117
end
1218

19+
#try foo
20+
#catch
21+
# exception_msg printstr new_line
22+
#end
23+
1324
foo

source/backends/arm64.d

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,14 @@ class BackendARM64 : CompilerBackend {
206206

207207
override string[] FinalCommands() {
208208
// TODO: allow user to specify commands manually?
209-
bool isCross = executeShell("which aarch64-linux-gnu-as").status == 0;
210-
string assembler = isCross ? "aarch64-linux-gnu-as" : "as";
211-
string linker = isCross ? "aarch64-linux-gnu-ld" : "ld";
209+
version (AArch64) {
210+
string assembler = "as";
211+
string linker = "ld";
212+
}
213+
else {
214+
string assembler = "aarch64-linux-gnu-as";
215+
string linker = "aarch64-linux-gnu-ld";
216+
}
212217

213218
string[] ret = [
214219
format("mv %s %s.asm", compiler.outFile, compiler.outFile),

source/backends/uxn.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ class BackendUXN : CompilerBackend {
300300
if (crash) {
301301
output ~= format(";global_%s LDA2\n", Sanitise("_cal_exception"));
302302
output ~= "#0000 NEQ2\n";
303-
output ~= format(";func__%s JCN\n", Sanitise("__uxn_exception"));
303+
output ~= format(";func__%s JCN2\n", Sanitise("__uxn_exception"));
304304
}
305305
else {
306306
CompileReturn(node);
@@ -1108,7 +1108,7 @@ class BackendUXN : CompilerBackend {
11081108
foreach (i ; 0 .. 3) {
11091109
output ~= "DUP2 LDA2\n";
11101110
output ~= format(
1111-
";global_%s #%.2x ADD2 STA2\n", Sanitise("_cal_exception"), i + 1
1111+
";global_%s #%.2x ADD2 STA2\n", Sanitise("_cal_exception"), i + 2
11121112
);
11131113
output ~= "#0002 ADD2\n";
11141114
}

0 commit comments

Comments
 (0)