| 580 | let code_lines = user_tokens.iter().filter(|t| t.is_code()).count(); |
| 581 | let user_obj = pipeline |
| 582 | .assemble(&user_tokens) |
| 583 | .expect("user assemble failed"); |
| 584 | |
| 585 | let assembled = pipeline |
| 586 | .link_assembled_objects(&link_with_stdlib(&user_obj)) |
| 587 | .expect("link failed"); |
| 588 | let mut vm = VirtualMachine::new(&assembled); |
| 589 | let run = vm.run(5_000_000); |
| 590 | (run.outcome, run.uart_output.clone(), code_lines) |
| 591 | } |
| 592 | |
| 593 | // Constant-heavy program with a dead local: const folding collapses the |
| 594 | // arithmetic and DCE drops the unused computation. |
| 595 | const OPT_CONST_PROGRAM: &str = r#" |
| 596 | main: () -> i32 { |
| 597 | a: i32 = 2 + 3 * 4 |
| 598 | b: i32 = a * 10 |
| 599 | unused: i32 = 100 + 200 + 300 |
| 600 | return b as i32 |