use crate::ir::IR; #[derive(Debug, Default, PartialEq)] pub struct Block { ir: Vec, } impl Block { pub fn push(&mut self, ir: IR) { self.ir.push(ir); } pub fn pop(&mut self) -> Option { self.ir.pop() } pub fn is_empty(&self) -> bool { self.ir.is_empty() } /// Consumes the block and returns the IR data. pub fn ir(self) -> Vec { self.ir } } #[derive(Debug, Clone, PartialEq)] pub struct BlockIdx(usize); impl From for BlockIdx { fn from(i: usize) -> BlockIdx { BlockIdx(i) } } impl From for usize { fn from(i: BlockIdx) -> usize { i.0 } } impl From<&BlockIdx> for usize { fn from(i: &BlockIdx) -> usize { i.0 } }