| 988 | let (asm, tokens) = compiler.compile_with_tokens(ir); |
| 989 | let stem = if let Some(existing) = self.current_artifact_stem() { |
| 990 | existing |
| 991 | } else { |
| 992 | let stem = self.default_artifact_stem(Location::caller(), "asm", &asm); |
| 993 | *self.last_artifact_stem.borrow_mut() = Some(stem.clone()); |
| 994 | stem |
| 995 | }; |
| 996 | self.write_text_artifact("asm", &stem, ".s", &asm); |
| 997 | (asm, tokens) |
| 998 | } |
| 999 | |
| 1000 | /// Assemble a token stream into machine code. |
| 1001 | #[track_caller] |
| 1002 | pub fn assemble(&self, tokens: &[RvInstruction]) -> Result<AssembledOutput, AssemblerError> { |
| 1003 | let stem = self.current_artifact_stem().unwrap_or_else(|| { |
| 1004 | self.default_artifact_stem(Location::caller(), "obj", &format!("{}", tokens.len())) |
| 1005 | }); |
| 1006 | self.assemble_named(&stem, tokens) |
| 1007 | } |
| 1008 | |
| 1009 | #[track_caller] |