Refactor for style

This commit is contained in:
2023-11-23 12:22:30 -06:00
parent aca20e296b
commit 66e7e1884e
2 changed files with 6 additions and 7 deletions
+3 -6
View File
@@ -82,12 +82,9 @@ impl CompiledFn {
} }
} }
pub(crate) fn text(&self) -> Vec<String> { /// Return an iterator over all the
let preamble = self.preamble.0.clone(); pub fn text(&self) -> impl Iterator<Item = &str> {
let body = self.body.0.clone(); self.preamble.0.iter().chain(self.body.0.iter()).chain(self.outro.0.iter()).map(String::as_str)
let outro = self.outro.0.clone();
[preamble, body, outro].into_iter().flatten().collect()
} }
/// Emit and emit arg should just be delegated to `body` /// Emit and emit arg should just be delegated to `body`
+3 -1
View File
@@ -47,7 +47,9 @@ pub fn build_boot(src: &str) -> Result<Vec<String>, CompileError> {
// Now start dumping compiled objects into there. First functions: // Now start dumping compiled objects into there. First functions:
for (_, val) in state.functions.iter_mut() { for (_, val) in state.functions.iter_mut() {
asm.push(format!("{}:", val.label)); asm.push(format!("{}:", val.label));
asm.append(val.text().as_mut()); for line in val.text() {
asm.push(String::from(line));
}
} }
// Strings: // Strings: