1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
extern crate bfcore; use bfcore::Output; use crate::Lang; use std::fmt::{Display, Formatter, Error}; #[derive(Default, Debug, Clone)] pub struct CompilerOutput { lang: Lang, output_script: String } impl CompilerOutput { pub fn new(lang: Lang) -> Self { Self { lang, output_script: String::from("") } } pub fn extension(self, name: &str) -> String { name.to_owned() + self.lang.extension() } } impl Output for CompilerOutput { fn output(&mut self, ch: char) { self.output_script.push(ch) } } impl Display for CompilerOutput { fn fmt(&self, f: &mut Formatter) -> Result<(), Error> { write!(f, "{}", self.output_script) } }