(CompileResult<ByteBuffer> lastResult)
| 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) { |
nothing calls this directly
no test coverage detected