mod separator;
pub use separator::Separator;
use crate::{Instruction, instruction::Mnemonic};
pub trait ToAssembly {
fn to_assembly(&self, separator: Separator) -> String;
}
impl ToAssembly for Vec<Instruction> {
fn to_assembly(&self, separator: Separator) -> String {
self.into_iter().map(|instruction| {
let start = match &instruction.mnemonic {
Mnemonic::Label(_) => "",
Mnemonic::Section(_) => "",
_ => "\t",
};
format!("{}{}\n", start, instruction.to_assembly(separator))
})
.collect::<String>()
}
}