Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions Main.arm
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ public class Main {
IO.println("arc: run: cd ".concat(name).concat(" && arc build"));
}

private static compile(inputPath: String, stdlibPath: String, checkOnly: Boolean, outName: String, isLinux: Boolean) : Void {
if (!File.exists(inputPath)) {
private static compile(inputPath: String, stdlibPath: String, checkOnly: Boolean, outName: String, isLinux: Boolean, safeRegAlloc: Boolean) : Void {
if (File.exists(inputPath) == false) {
IO.println("arc: file not found: ${inputPath}");
return;
}
Expand Down Expand Up @@ -335,6 +335,10 @@ public class Main {

IO.println("arc: generating native code...");
NativeBackend nb = NativeBackend(isLinux);
if (safeRegAlloc) {
nb.setSafeRegAlloc(true);
IO.println("arc: using SafeRegAlloc (stack-canonical, correctness-first)");
}
nb.compile(modules, exeFile);
if (isLinux) { Process.exec("chmod +x ".concat(exeFile)); }
IO.println("arc: done -> ${exeFile}");
Expand All @@ -353,14 +357,16 @@ public class Main {
String stdlibPath = Main.findStdlib(exePath);

String cmd = argv.get(1);
Boolean checkOnly = false;
Boolean doRun = false;
Boolean isLinux = Env.platform().compareTo("linux") == 0;
Boolean checkOnly = false;
Boolean doRun = false;
Boolean isLinux = Env.platform().compareTo("linux") == 0;
Boolean safeRegAlloc = false;

Integer fi = 2;
while (fi < argc) {
String flag = argv.get(fi);
if (flag.compareTo("--check") == 0) { checkOnly = true; }
if (flag.compareTo("--check") == 0) { checkOnly = true; }
if (flag.compareTo("--safe-regalloc") == 0) { safeRegAlloc = true; }
if (flag.compareTo("--stdlib-path") == 0) {
fi++;
if (fi < argc) { stdlibPath = argv.get(fi); }
Expand Down Expand Up @@ -391,7 +397,7 @@ public class Main {
if (cmd.compareTo("run") == 0) { doRun = true; }
if (cmd.compareTo("check") == 0) { checkOnly = true; }

if (!File.exists("arc.toml")) {
if (File.exists("arc.toml") == false) {
IO.println("arc: arc.toml not found - run from project root");
return;
}
Expand All @@ -402,7 +408,7 @@ public class Main {
if (projName.length() == 0) { projName = "app"; }

IO.println("arc v1.0 - building '${projName}'");
Main.compile(entry, stdlibPath, checkOnly, projName, isLinux);
Main.compile(entry, stdlibPath, checkOnly, projName, isLinux, safeRegAlloc);

if (doRun && !checkOnly) {
String runCmd = ".\\".concat(projName).concat(".exe");
Expand All @@ -415,7 +421,7 @@ public class Main {

if (cmd.endsWith(".arm")) {
IO.println("arc v1.0 - compiling '${cmd}'");
Main.compile(cmd, stdlibPath, checkOnly, "", isLinux);
Main.compile(cmd, stdlibPath, checkOnly, "", isLinux, safeRegAlloc);
return;
}

Expand Down
Loading
Loading