pub struct Program { /* private fields */ }Expand description
Machine code with the offset of each function.
§Examples
use backend_lang::mir::Function;
use backend_lang::x86_64::{op, Emitter, SYSV};
let mut f = Function::new("f", &SYSV);
let b = f.block()?;
f.push(b, op::RET, &[])?;
let mut e = Emitter::new();
e.function(&f)?;
let program = e.finish()?;
assert_eq!(program.symbol("f"), Some(0));
// push rbp; mov rbp, rsp; pop rbp; ret
assert_eq!(program.bytes(), [0x55, 0x48, 0x89, 0xE5, 0x5D, 0xC3]);Implementations§
Source§impl Program
impl Program
Sourcepub fn bytes(&self) -> &[u8] ⓘ
pub fn bytes(&self) -> &[u8] ⓘ
The machine code.
§Examples
use backend_lang::x86_64::Emitter;
assert!(Emitter::new().finish()?.bytes().is_empty());Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
The machine code, by value.
§Examples
use backend_lang::x86_64::Emitter;
assert!(Emitter::new().finish()?.into_bytes().is_empty());Trait Implementations§
impl Eq for Program
impl StructuralPartialEq for Program
Auto Trait Implementations§
impl Freeze for Program
impl RefUnwindSafe for Program
impl Send for Program
impl Sync for Program
impl Unpin for Program
impl UnsafeUnpin for Program
impl UnwindSafe for Program
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