Compile and run a user program with the frame pointer omitted or kept, returning the VM run (exit outcome + UART) and the emitted instruction count.
(src: &str, omit_fp: bool)
| 306 | "export scale: (x: i32) -> i32 { return x * 3 } |
| 307 | export apply: <T>(value: i32) -> i32 { return scale(value) } |
| 308 | " |
| 309 | .to_owned(), |
| 310 | ), |
| 311 | _ => None, |
| 312 | }))); |
| 313 | |
| 314 | let primary = r#" |
| 315 | left := import("left") |
| 316 | right := import("right") |
| 317 | main: () -> i32 { |
| 318 | return left.apply<i32>(6) + right.apply<i32>(10) |
| 319 | } |
| 320 | "#; |
| 321 | let closure = pipeline |
| 322 | .compile_program_closure("user", primary) |
| 323 | .expect("closure compile failed"); |
| 324 | |
| 325 | let mut modules: Vec<(&str, &AssembledOutput)> = cached_stdlib_objs() |
| 326 | .iter() |
| 327 | .map(|(n, o)| (n.as_str(), o)) |
| 328 | .collect(); |
| 329 | for (name, obj) in &closure { |