1use core::fmt::Display;
2
3use alloc::string::ToString;
4use alloc::vec::Vec;
5
6use crate::{Allocator, TypeMap};
7
8use super::{Instruction, Variable};
9
10pub trait Processor: core::fmt::Debug {
11 fn transform(&self, processing: ScopeProcessing, allocator: Allocator) -> ScopeProcessing;
12}
13
14pub struct ScopeProcessing {
16 pub variables: Vec<Variable>,
18 pub instructions: Vec<Instruction>,
20 pub typemap: TypeMap,
22}
23
24impl Display for ScopeProcessing {
25 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
26 writeln!(f, "{{")?;
27 for instruction in self.instructions.iter() {
28 let instruction_str = instruction.to_string();
29 if !instruction_str.is_empty() {
30 writeln!(f, " {instruction_str}")?;
31 }
32 }
33 write!(f, "}}")?;
34 Ok(())
35 }
36}