MCPcopy Create free account
hub / github.com/SeaOfNodes/Simple / run

Method run

chapter21/src/test/java/com/seaofnodes/simple/Compile.java:16–35  ·  view source on GitHub ↗
(String simple, String c)

Source from the content-addressed store, hash-verified

14public 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

Callers 1

testCompileMethod · 0.95

Calls 12

parseMethod · 0.95
exportELFMethod · 0.95
encodeMethod · 0.45
regAllocMethod · 0.45
localSchedMethod · 0.45
GCMMethod · 0.45
instSelectMethod · 0.45
typeCheckMethod · 0.45
optoMethod · 0.45
equalsMethod · 0.45
addMethod · 0.45
execMethod · 0.45

Tested by

no test coverage detected