1mod separator;
6
7pub use separator::Separator;
8
9use crate::{Instruction, instruction::Mnemonic};
10
11pub trait ToAssembly {
13 fn to_assembly(&self, separator: Separator) -> String;
16}
17
18impl ToAssembly for Vec<Instruction> {
21 fn to_assembly(&self, separator: Separator) -> String {
22 self.into_iter().map(|instruction| {
23 let start = match &instruction.mnemonic {
24 Mnemonic::Label(_) => "",
25 Mnemonic::Section(_) => "",
26 _ => "\t",
27 };
28
29 format!("{}{}\n", start, instruction.to_assembly(separator))
30 })
31 .collect::<String>()
32 }
33}