Compile a directly-constructed IR program (for ops the HLL surface lacks), link against the cached stdlib, and run it.
(program: &IrProgram)
| 60 | /// Compile a directly-constructed IR program (for ops the HLL surface lacks), |
| 61 | /// link against the cached stdlib, and run it. |
| 62 | fn run_ir(program: &IrProgram) -> (VirtualMachine, StepOutcome, String) { |
| 63 | let mut pipeline = CompilationPipeline::new(); |
| 64 | pipeline.set_write_artifacts(false); |
| 65 | |
| 66 | let (_, user_tokens) = pipeline.compile_ir_to_assembly_with_tokens(program); |
| 67 | let user_obj = pipeline |
| 68 | .assemble(&user_tokens) |
| 69 | .expect("user assemble failed"); |
| 70 | |
| 71 | let assembled = pipeline |
| 72 | .link_assembled_objects(&link_with_stdlib(&user_obj)) |
| 73 | .expect("link failed"); |
| 74 | let mut vm = VirtualMachine::new(&assembled); |
| 75 | let run = vm.run(5_000_000); |
| 76 | let uart = run.uart_output.clone(); |
| 77 | (vm, run.outcome, uart) |
| 78 | } |
| 79 | |
| 80 | /// Build a minimal pass/fail IR program around an entry block. `entry` must not |
| 81 | /// yet have a terminator; this adds the branch, a pass block (return 0), and a |