···46 }
47}
4849+#[cfg(feature = "asm")]
50fn load_program(path: &Path) -> std::io::Result<Vec<u32>> {
51 match path.extension().map(|ext| ext.as_encoded_bytes()) {
52+ // In an ideal world we would just add `#[cfg(feature = "asm")]` here.
53+ // Unfortunately this leads some wierd code generation fuckery which
54+ // makes the version without the 'asm' feature ~1-2 seconds slower
55+ // when running the sandmark program.
56 Some(b"uasm") | Some(b"asm") => {
57 let source = std::fs::read_to_string(path)?;
58 Ok(um::asm::assemble(&source))
···63 }
64 }
65}
66+67+#[cfg(not(feature = "asm"))]
68+fn load_program(path: &Path) -> std::io::Result<Vec<u32>> {
69+ let program = std::fs::read(path)?;
70+ Ok(um::conv::bytes_to_program(&program).unwrap())
71+}
+3
src/lib.rs
···15use smallvec::SmallVec;
16use std::io::{Read, Write};
17018pub mod asm;
19pub mod conv;
20pub mod ops;
···324 }
325326 #[test]
0327 fn hello_world() {
328 let program = asm::assemble(include_str!("../files/hello-world.asm"));
329 let mut buffer = Vec::new();
···332 }
333334 #[test]
0335 fn cat() {
336 let program = asm::assemble(include_str!("../files/cat.asm"));
337 let input = include_bytes!("lib.rs");
···15use smallvec::SmallVec;
16use std::io::{Read, Write};
1718+#[cfg(feature = "asm")]
19pub mod asm;
20pub mod conv;
21pub mod ops;
···325 }
326327 #[test]
328+ #[cfg(feature = "asm")]
329 fn hello_world() {
330 let program = asm::assemble(include_str!("../files/hello-world.asm"));
331 let mut buffer = Vec::new();
···334 }
335336 #[test]
337+ #[cfg(feature = "asm")]
338 fn cat() {
339 let program = asm::assemble(include_str!("../files/cat.asm"));
340 let input = include_bytes!("lib.rs");