Compile user HLL, link it against the cached stdlib object, and run in the VM.
(src: &str, max_steps: u64)
| 39 | // Compile user HLL, link it against the cached stdlib object, and run in the VM. |
| 40 | fn run_hll_with_limit(src: &str, max_steps: u64) -> (VirtualMachine, StepOutcome, String) { |
| 41 | let mut pipeline = CompilationPipeline::new(); |
| 42 | pipeline.set_write_artifacts(false); |
| 43 | |
| 44 | let user_result = pipeline.compile(src).expect("user compile failed"); |
| 45 | let (_, user_tokens) = pipeline.compile_ir_to_assembly_with_tokens(&user_result.ir_program); |
| 46 | let user_obj = pipeline |
| 47 | .assemble(&user_tokens) |
| 48 | .expect("user assemble failed"); |
| 49 | |
| 50 | let assembled = pipeline |
| 51 | .link_assembled_objects(&link_with_stdlib(&user_obj)) |
| 52 | .expect("link failed"); |
| 53 | let mut vm = VirtualMachine::new(&assembled); |
| 54 | let run = vm.run(max_steps); |
| 55 | let uart = run.uart_output.clone(); |
| 56 | (vm, run.outcome, uart) |
| 57 | } |
| 58 | |
| 59 | // Runs a directly-constructed IR program, for ops the HLL surface cannot spell. |
| 60 | fn run_ir(program: &IrProgram) -> (VirtualMachine, StepOutcome, String) { |
| 61 | let mut pipeline = CompilationPipeline::new(); |
no test coverage detected