Trait CodeSink

Source
pub trait CodeSink {
    // Required methods
    fn put1(&mut self, _: u8);
    fn put2(&mut self, _: u16);
    fn put4(&mut self, _: u32);
    fn put8(&mut self, _: u64);
    fn add_trap(&mut self, code: TrapCode);
    fn use_target(&mut self, target: DeferredTarget);
    fn known_offset(&self, offset: KnownOffset) -> i32;
}
Expand description

Describe how an instruction is emitted into a code buffer.

Required Methods§

Source

fn put1(&mut self, _: u8)

Add 1 byte to the code section.

Source

fn put2(&mut self, _: u16)

Add 2 bytes to the code section.

Source

fn put4(&mut self, _: u32)

Add 4 bytes to the code section.

Source

fn put8(&mut self, _: u64)

Add 8 bytes to the code section.

Source

fn add_trap(&mut self, code: TrapCode)

Inform the code buffer of a possible trap at the current location; required for assembling memory accesses.

Source

fn use_target(&mut self, target: DeferredTarget)

Inform the code buffer that a use of target is about to happen at the current offset.

After this method is called the bytes of the target are then expected to be placed using one of the above put* methods.

Source

fn known_offset(&self, offset: KnownOffset) -> i32

Resolves a KnownOffset value to the actual signed offset.

Implementations on Foreign Types§

Source§

impl CodeSink for Vec<u8>

Provide a convenient implementation for testing.

Source§

fn put1(&mut self, v: u8)

Source§

fn put2(&mut self, v: u16)

Source§

fn put4(&mut self, v: u32)

Source§

fn put8(&mut self, v: u64)

Source§

fn add_trap(&mut self, _: TrapCode)

Source§

fn use_target(&mut self, _: DeferredTarget)

Source§

fn known_offset(&self, offset: KnownOffset) -> i32

Implementors§