MCPcopy Create free account
hub / github.com/badvision/jace / execute

Method execute

src/main/java/jace/assembly/AssemblyHandler.java:54–83  ·  view source on GitHub ↗
(CompileResult<ByteBuffer> lastResult)

Source from the content-addressed store, hash-verified

52 }
53
54 @Override
55 public void execute(CompileResult<ByteBuffer> lastResult) throws Exception {
56 if (lastResult.isSuccessful()) {
57 Computer c = Emulator.withComputer(c1 -> c1, null);
58
59 RAM memory = c.getMemory();
60 ByteBuffer input = lastResult.getCompiledAsset();
61 input.rewind();
62 int startLSB = input.get() & 0x0ff;
63 int startMSB = input.get() & 0x0ff;
64 int start = startLSB + startMSB << 8;
65 // System.out.printf("Executing code at $%s%n", Integer.toHexString(start));
66 c.getCpu().whileSuspended(() -> {
67 // System.out.printf("Storing assembled code to $%s%n", Integer.toHexString(start));
68 int pos = start;
69 while (input.hasRemaining()) {
70 memory.write(pos++, input.get(), false, true);
71 }
72 // System.out.printf("Issuing JSR to $%s%n", Integer.toHexString(start));
73 c.getCpu().JSR(start);
74 });
75 // });
76 } else {
77 System.err.println("Compilation failed");
78 lastResult.getErrors().forEach((line, message) -> System.err.printf("Line %d: %s%n", line, message));
79 lastResult.getOtherMessages().forEach(System.err::println);
80 throw new Exception("Compilation failed");
81 }
82 clean(lastResult);
83 }
84
85 @Override
86 public void clean(CompileResult<ByteBuffer> lastResult) {

Callers

nothing calls this directly

Calls 13

withComputerMethod · 0.95
getMemoryMethod · 0.95
getCpuMethod · 0.95
writeMethod · 0.95
cleanMethod · 0.95
rewindMethod · 0.80
isSuccessfulMethod · 0.65
getCompiledAssetMethod · 0.65
getErrorsMethod · 0.65
getOtherMessagesMethod · 0.65
getMethod · 0.45
whileSuspendedMethod · 0.45

Tested by

no test coverage detected