[−][src]Struct ketos::bytecode::CodeBlock
Contains a series of bytecode instructions
Fields
jump: Option<(JumpInstruction, u32)>
Jump instruction added to the end of the block
next: Option<u32>
Refers to the block that immediately follows this block
Methods
impl CodeBlock
[src]
pub fn new() -> CodeBlock
[src]
Creates an empty CodeBlock
with a small reserved buffer.
pub fn empty() -> CodeBlock
[src]
Creates an empty CodeBlock
without reserving data.
pub fn calculate_size(&self, short: bool) -> usize
[src]
Returns the final size of the block, including all encoded instructions
and final jump instruction.
short
indicates whether jump instruction offsets are encoded in
short format.
If there is an unencoded instruction, its size is estimated.
pub fn len(&self) -> usize
[src]
Returns the size of all encoded instructions.
pub fn is_empty(&self) -> bool
[src]
Returns whether any intruction was encoded.
pub fn bytes(&self) -> &[u8]
[src]
Returns encoded bytecode data.
flush
should be called first to ensure all instructions are encoded.
pub fn is_mostly_empty(&self) -> bool
[src]
Returns whether the code block is mostly empty, permitting the compiler to prune it in some cases.
pub fn set_next(&mut self, block: u32)
[src]
Sets the block which will immediately follow this block.
May only be called once.
pub fn jump_to(&mut self, instr: JumpInstruction, block: u32)
[src]
Sets the jump instruction at the end of the block.
May only be called once.
pub fn write_jump(
&mut self,
label: u32,
short: bool
) -> Result<(), CompileError>
[src]
&mut self,
label: u32,
short: bool
) -> Result<(), CompileError>
Write stored jump instruction to buffer, if present.
pub fn flush(&mut self) -> Result<(), CompileError>
[src]
Forcibly encodes a pending instruction. Does not encode a jump instruction.
pub fn push_instruction(
&mut self,
instr: Instruction
) -> Result<(), CompileError>
[src]
&mut self,
instr: Instruction
) -> Result<(), CompileError>
Adds an instruction the block. The instruction may be stored until later to be merged into a combination instruction.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for CodeBlock
impl Send for CodeBlock
impl Sync for CodeBlock
impl Unpin for CodeBlock
impl UnwindSafe for CodeBlock
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,