(String simple, String c)
| 14 | public class Compile { |
| 15 | |
| 16 | private static Process run(String simple, String c) throws IOException, InterruptedException { |
| 17 | boolean USE_WSL = System.getProperty("os.name").startsWith("Windows"); |
| 18 | CodeGen code = new CodeGen(simple); |
| 19 | code.parse().opto().typeCheck().instSelect("x86_64_v2", "SystemV").GCM().localSched().regAlloc().encode(); |
| 20 | if (c != null) for (var n:code._start._outputs) if (n instanceof FunNode f && f._name.equals("main")) f._name = "simple_main"; |
| 21 | code.exportELF("test.o"); |
| 22 | var params = new ArrayList<String>(); |
| 23 | if (USE_WSL) params.add("wsl.exe"); |
| 24 | params.add("gcc"); |
| 25 | params.add("-o"); |
| 26 | params.add("test"); |
| 27 | if (c != null) { |
| 28 | Files.writeString(Path.of("test.c"), c); |
| 29 | params.add("test.c"); |
| 30 | } |
| 31 | params.add("test.o"); |
| 32 | Process p = Runtime.getRuntime().exec(params.toArray(String[]::new)); |
| 33 | assertEquals(0, p.waitFor()); |
| 34 | return Runtime.getRuntime().exec(USE_WSL ? new String[]{"wsl.exe", "./test"}:new String[]{"./test"}); |
| 35 | } |
| 36 | |
| 37 | @Test |
| 38 | @Ignore |
no test coverage detected