use crate::constants_table::ConstantsTable; use dvm_lib::instruction::Instruction; pub trait Assemble { fn assemble(&self, builder: &mut InstructionsBuilder, constants_table: &mut ConstantsTable); } pub struct InstructionsBuilder { instructions: Vec, } impl InstructionsBuilder { pub fn new() -> Self { Self { instructions: vec![], } } pub fn push(&mut self, instruction: Instruction) { self.instructions.push(instruction); } pub fn take_instructions(&mut self) -> Vec { std::mem::take(&mut self.instructions) } }