deimos-lang/dmc-lib/src/ir/assemble.rs
2026-03-08 01:27:09 -06:00

27 lines
621 B
Rust

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<Instruction>,
}
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<Instruction> {
std::mem::take(&mut self.instructions)
}
}