pub struct CodeWriter<'a> { /* private fields */ }Expand description
Thin instruction-word writer for JIT emission.
This type intentionally owns no label/fixup metadata.
Implementations§
Source§impl<'a> CodeWriter<'a>
impl<'a> CodeWriter<'a>
Sourcepub fn new(buf: &'a mut [u32]) -> Self
pub fn new(buf: &'a mut [u32]) -> Self
Creates a new writer over a caller-provided word buffer.
Sourcepub fn set_position(&mut self, position: usize) -> Result<(), AssembleError>
pub fn set_position(&mut self, position: usize) -> Result<(), AssembleError>
Moves the write cursor to an earlier or equal emitted position.
§Errors
Returns AssembleError::PositionOutOfBounds if position is outside emitted range.
Sourcepub fn emit_word(&mut self, word: u32) -> Result<(), AssembleError>
pub fn emit_word(&mut self, word: u32) -> Result<(), AssembleError>
Emits one already-encoded instruction word.
§Errors
Returns AssembleError::BufferOverflow if the buffer is full.
Sourcepub fn read_u32_at(&self, at: usize) -> Result<u32, AssembleError>
pub fn read_u32_at(&self, at: usize) -> Result<u32, AssembleError>
Reads one emitted instruction word at at.
§Errors
Returns AssembleError::ReadOutOfBounds if at is outside emitted range.
Sourcepub fn write_u32_at(
&mut self,
at: usize,
word: u32,
) -> Result<(), AssembleError>
pub fn write_u32_at( &mut self, at: usize, word: u32, ) -> Result<(), AssembleError>
Overwrites one emitted instruction word at at.
§Errors
Returns AssembleError::WriteOutOfBounds if at is outside emitted range.
Auto Trait Implementations§
impl<'a> Freeze for CodeWriter<'a>
impl<'a> RefUnwindSafe for CodeWriter<'a>
impl<'a> Send for CodeWriter<'a>
impl<'a> Sync for CodeWriter<'a>
impl<'a> Unpin for CodeWriter<'a>
impl<'a> UnsafeUnpin for CodeWriter<'a>
impl<'a> !UnwindSafe for CodeWriter<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more