···4646 }
4747}
48484949+#[cfg(feature = "asm")]
4950fn load_program(path: &Path) -> std::io::Result<Vec<u32>> {
5051 match path.extension().map(|ext| ext.as_encoded_bytes()) {
5252+ // In an ideal world we would just add `#[cfg(feature = "asm")]` here.
5353+ // Unfortunately this leads some wierd code generation fuckery which
5454+ // makes the version without the 'asm' feature ~1-2 seconds slower
5555+ // when running the sandmark program.
5156 Some(b"uasm") | Some(b"asm") => {
5257 let source = std::fs::read_to_string(path)?;
5358 Ok(um::asm::assemble(&source))
···5863 }
5964 }
6065}
6666+6767+#[cfg(not(feature = "asm"))]
6868+fn load_program(path: &Path) -> std::io::Result<Vec<u32>> {
6969+ let program = std::fs::read(path)?;
7070+ Ok(um::conv::bytes_to_program(&program).unwrap())
7171+}
+3
src/lib.rs
···1515use smallvec::SmallVec;
1616use std::io::{Read, Write};
17171818+#[cfg(feature = "asm")]
1819pub mod asm;
1920pub mod conv;
2021pub mod ops;
···324325 }
325326326327 #[test]
328328+ #[cfg(feature = "asm")]
327329 fn hello_world() {
328330 let program = asm::assemble(include_str!("../files/hello-world.asm"));
329331 let mut buffer = Vec::new();
···332334 }
333335334336 #[test]
337337+ #[cfg(feature = "asm")]
335338 fn cat() {
336339 let program = asm::assemble(include_str!("../files/cat.asm"));
337340 let input = include_bytes!("lib.rs");