Struct fuel_etk_asm::asm::Assembler
source · pub struct Assembler { /* private fields */ }
Expand description
Assembles a series of RawOp
into raw bytes, tracking and resolving macros and labels,
and handling dynamic pushes.
Example
use etk_asm::asm::Assembler;
use etk_asm::ops::AbstractOp;
use etk_ops::london::{Op, GetPc};
let mut asm = Assembler::new();
asm.push_all(vec![
AbstractOp::new(GetPc),
])?;
let output = asm.take();
asm.finish()?;
Implementations§
source§impl Assembler
impl Assembler
sourcepub fn finish(self) -> Result<(), Error>
pub fn finish(self) -> Result<(), Error>
Indicate that the input sequence is complete. Returns any errors that may remain.
sourcepub fn take(&mut self) -> Vec<u8>
pub fn take(&mut self) -> Vec<u8>
Collect any assembled instructions that are ready to be output.
sourcepub fn push_all<I, O>(&mut self, ops: I) -> Result<usize, Error>where
I: IntoIterator<Item = O>,
O: Into<RawOp>,
pub fn push_all<I, O>(&mut self, ops: I) -> Result<usize, Error>where
I: IntoIterator<Item = O>,
O: Into<RawOp>,
Feed instructions into the Assembler
.
Returns the number of bytes that can be collected with Assembler::take
.