Run files through the Cranelift interpreter, interpreting any functions with annotations.
(options: &Options)
| 24 | |
| 25 | /// Run files through the Cranelift interpreter, interpreting any functions with annotations. |
| 26 | pub fn run(options: &Options) -> anyhow::Result<()> { |
| 27 | let mut total = 0; |
| 28 | let mut errors = 0; |
| 29 | for file in iterate_files(&options.files) { |
| 30 | total += 1; |
| 31 | let runner = FileInterpreter::from_path(file)?; |
| 32 | match runner.run() { |
| 33 | Ok(_) => { |
| 34 | if options.verbose { |
| 35 | println!("{}", runner.path()); |
| 36 | } |
| 37 | } |
| 38 | Err(e) => { |
| 39 | if options.verbose { |
| 40 | println!("{}: {}", runner.path(), e.to_string()); |
| 41 | } |
| 42 | errors += 1; |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | if options.verbose { |
| 48 | match total { |
| 49 | 0 => println!("0 files"), |
| 50 | 1 => println!("1 file"), |
| 51 | n => println!("{n} files"), |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | match errors { |
| 56 | 0 => Ok(()), |
| 57 | 1 => anyhow::bail!("1 failure"), |
| 58 | n => anyhow::bail!("{n} failures"), |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | /// Contains CLIF code that can be executed with [FileInterpreter::run]. |
| 63 | pub struct FileInterpreter { |