Skip to content

Commit e412744

Browse files
authored
Merge pull request #14 from callisto-lang/main
add arm64 backend to FunctionParameters2 branch
2 parents 5b21d0e + 9798437 commit e412744

File tree

9 files changed

+1205
-30
lines changed

9 files changed

+1205
-30
lines changed

examples/arrays.cal

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ include "std/io.cal"
33
include "std/array.cal"
44

55
let Array myArray
6-
[u16 1 2 3 4 5] myArray a<
6+
[u16 1 2 3 4 5] &myArray a<
77

8-
0 myArray a@ printdec 10 printch
9-
1 myArray a@ printdec 10 printch
8+
0 &myArray a@ printdec 10 printch
9+
1 &myArray a@ printdec 10 printch
1010

11-
100 2 myArray a!
12-
2 myArray a@ printdec 10 printch
11+
100 2 &myArray a!
12+
2 &myArray a@ printdec 10 printch

examples/compare_strings.cal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ let Array str2
1010

1111
&str1 &str2 a= printdec new_line
1212

13-
"Hi" str2 a<
13+
"Hi" &str2 a<
1414
&str1 &str2 a= printdec new_line
1515

16-
"Greetings" str1 a<
16+
"Greetings" &str1 a<
1717
&str1 &str2 a= printdec new_line
1818

1919
&str1 "Greetings" a= printdec new_line

examples/literals.cal

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
include "cores/select.cal"
22
include "std/io.cal"
33

4-
func new_line begin
5-
13 printch 10 printch
6-
end
7-
84
# Hexadecimal - prints 16
95
0x10 printdec new_line
106

examples/variables.cal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let cell myGlobal
55
func myFunc begin
66
let cell myVar
77
'A' -> myVar
8-
myVa printch
8+
myVar printch
99
end
1010

1111
myFunc

examples/version.cal

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
11
include "cores/select.cal"
22
include "std/io.cal"
33

4-
# will execute on RM86 backend
4+
# Print a different message for each core
5+
56
version RM86
67
"Hello, RM86!\n" printstr
78
end
89

9-
# will execute on Linux86 backend
10-
version Linux86
11-
"Hello, Linux86!\n" printstr
10+
version x86_64
11+
"Hello, x86_64!\n" printstr
12+
end
13+
14+
version arm64
15+
"Hello, arm64!\n" printstr
16+
end
17+
18+
version UXN
19+
"Hello, Uxn!\n" printstr
1220
end
1321

14-
# won't execute unless you set the Foo version
22+
# Specify arbitrary versions to use them as compile-time flags
1523
version Foo
16-
"Hello, Foo!\n" printstr
24+
"Foo is enabled :D\n" printstr
1725
end
1826

19-
# will execute because Foo isn't set
27+
# This one will run by default unless you set Foo
2028
version not Foo
21-
"Hello, not Foo!\n" printstr
29+
"Foo is not enabled :(\n" printstr
2230
end

examples/writeFile.cal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if &file @ -2 = then
1010
end
1111

1212
let Array str
13-
"meow\n" str a<
13+
"meow\n" &str a<
1414

1515
&file
1616
&str Array.elements + @

source/app.d

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ import std.stdio;
66
import std.string;
77
import std.process;
88
import std.algorithm;
9+
import callisto.error;
910
import callisto.compiler;
1011
import callisto.language;
1112
import callisto.codeRemover;
1213
import callisto.preprocessor;
1314
import callisto.backends.lua;
1415
import callisto.backends.uxn;
1516
import callisto.backends.rm86;
17+
import callisto.backends.arm64;
1618
import callisto.backends.x86_64;
1719

1820
const static string usage = "
@@ -45,6 +47,7 @@ Flags:
4547
Backends and their operating systems:
4648
rm86 - Real mode x86, for bare-metal, dos
4749
x86_64 - 64-bit x86, for bare-metal, linux
50+
arm64 - 64-bit ARM, for linux
4851
uxn - Varvara/Uxn
4952
lua - Lua, uses subset CallistoScript
5053
@@ -73,7 +76,7 @@ int main(string[] args) {
7376
bool optimise;
7477
string[] versions;
7578
bool runFinal = true;
76-
CompilerBackend backend = new BackendX86_64();
79+
CompilerBackend backend;
7780
bool doDebug;
7881
bool debugParser;
7982
bool exportSymbols;
@@ -85,6 +88,17 @@ int main(string[] args) {
8588
bool assemblyLines;
8689
string os = "DEFAULT";
8790

91+
// choose default backend
92+
version (X86_64) {
93+
backend = new BackendX86_64();
94+
}
95+
else version (AArch64) {
96+
backend = new BackendARM64();
97+
}
98+
else {
99+
WarnNoInfo("No default backend for your system");
100+
}
101+
88102
for (size_t i = 1; i < args.length; ++ i) {
89103
if (args[i][0] == '-') {
90104
switch (args[i]) {
@@ -162,6 +176,10 @@ int main(string[] args) {
162176
backend = new BackendX86_64();
163177
break;
164178
}
179+
case "arm64": {
180+
backend = new BackendARM64();
181+
break;
182+
}
165183
case "uxn": {
166184
backend = new BackendUXN();
167185
break;
@@ -285,6 +303,10 @@ int main(string[] args) {
285303
}
286304
}
287305

306+
if (backend is null) {
307+
ErrorNoInfo("No backend selected");
308+
}
309+
288310
if (os == "DEFAULT") {
289311
os = backend.defaultOS;
290312
}

0 commit comments

Comments
 (0)