Skip to main content

BytecodeBuilder

Struct BytecodeBuilder 

Source
pub struct BytecodeBuilder<'src> { /* private fields */ }

Implementations§

Source§

impl<'src> BytecodeBuilder<'src>

Source

pub fn set_dump_flags(&mut self, flags: BytecodeDumpFlags)

Source

pub fn set_dump_source(&mut self, source: impl AsRef<[u8]>)

Source

pub fn needs_debug_remarks(&self) -> bool

Source

pub fn add_debug_remark(&mut self, text: impl AsRef<[u8]>)

Source

pub fn dump_function(&self, id: usize) -> BString

Source

pub fn dump_everything(&self) -> BString

Source

pub fn dump_source_remarks(&self) -> BString

Source

pub fn dump_type_info(&self) -> BString

Source

pub fn annotate_instruction( &self, result: &mut BString, function_id: u32, instruction_pc: u32, )

Source§

impl<'src> BytecodeBuilder<'src>

Source

pub fn emit_abc(&mut self, opcode: Opcode, a: u8, b: u8, c: u8)

Source

pub fn set_debug_function_name( &mut self, name: impl Into<BytecodeStringRef<'src>>, )

Source

pub fn set_debug_function_line_defined(&mut self, line: i32)

Source

pub fn add_flags(&mut self, flags: u8)

Source

pub fn push_open_debug_local( &mut self, name: impl Into<BytecodeStringRef<'src>>, register: Register, )

Source

pub fn push_debug_local( &mut self, name: impl Into<BytecodeStringRef<'src>>, register: Register, start_pc: u32, end_pc: u32, )

Source

pub fn close_debug_locals_from(&mut self, register: Register)

Source

pub fn push_debug_upvalue(&mut self, name: impl Into<BytecodeStringRef<'src>>)

Source

pub fn emit_ad(&mut self, opcode: Opcode, a: u8, d: i16)

Source

pub fn emit_e(&mut self, opcode: Opcode, e: i32)

Source

pub fn set_debug_line(&mut self, line: usize)

Source

pub fn current_line(&self) -> i32

Source

pub fn restore_line(&mut self, line: i32)

Source

pub fn emit_aux(&mut self, aux: InstructionWord)

Source

pub fn undo_emit(&mut self, opcode: Opcode)

Source

pub fn emit_label(&mut self) -> usize

Source

pub fn patch_jump_d(&mut self, jump_label: usize, target_label: usize) -> bool

Source

pub fn patch_jump_e(&mut self, jump_label: usize, target_label: usize) -> bool

Source

pub fn patch_skip_c(&mut self, jump_label: usize, target_label: usize) -> bool

Source

pub fn patch_aux(&mut self, target_aux: usize, value: i32)

Source

pub fn fold_jumps(&mut self)

Source

pub fn expand_jumps(&mut self)

Source

pub fn get_instruction_count(&self) -> usize

Source

pub fn get_total_instruction_count(&self) -> usize

Source

pub fn get_debug_pc(&self) -> u32

Source§

impl<'src> BytecodeBuilder<'src>

Source

pub fn add_constant_nil(&mut self) -> ConstantIndex

Source

pub fn add_constant_boolean(&mut self, value: bool) -> ConstantIndex

Source

pub fn add_constant_number(&mut self, value: f64) -> ConstantIndex

Source

pub fn add_constant_integer(&mut self, value: i64) -> ConstantIndex

Source

pub fn add_constant_string( &mut self, value: impl Into<BytecodeStringRef<'src>>, ) -> ConstantIndex

Source

pub fn add_import(&mut self, import_id: BytecodeImportId) -> ConstantIndex

Source

pub fn add_constant_closure(&mut self, function_id: u32) -> ConstantIndex

Source

pub fn add_constant_table(&mut self, shape: &TableShape) -> ConstantIndex

Source

pub fn add_constant_vector( &mut self, x: f32, y: f32, z: f32, w: f32, ) -> ConstantIndex

Source

pub fn add_constant_vector_double( &mut self, x: f64, y: f64, z: f64, w: f64, ) -> ConstantIndex

Source

pub fn add_class_shape(&mut self, shape: BytecodeClass) -> ConstantIndex

Source

pub fn add_fb_slot(&mut self, ty: BytecodeFeedbackType) -> u32

Source

pub fn set_function_type_info(&mut self, value: Vec<u8>)

Source

pub fn push_local_type_info( &mut self, ty: u8, register: Register, start_pc: u32, end_pc: u32, )

Source

pub fn push_upvalue_type_info(&mut self, ty: u8)

Source

pub fn add_userdata_type(&mut self, name: impl Into<BytecodeString>) -> u32

Source

pub fn use_userdata_type(&mut self, index: u32)

Source

pub fn finalize(&mut self)

Source

pub fn get_bytecode(&self) -> &[u8]

Source

pub fn get_error(message: impl AsRef<[u8]>) -> Vec<u8>

Encodes a compiler diagnostic as a bytecode blob that the VM loader can report using the requested chunk name.

Source

pub fn get_string_table(&self) -> BytecodeStringTable<'_>

Source

pub fn get_function_data(&self, id: usize) -> Vec<u8>

Source

pub fn get_string_hash(key: impl AsRef<[u8]>) -> u32

Source§

impl<'src> BytecodeBuilder<'src>

Source

pub fn new() -> Self

Source

pub fn with_encoder(encoder: impl BytecodeEncoder + 'static) -> Self

Source

pub fn begin_function(&mut self, num_params: u8, is_vararg: bool) -> usize

Source

pub fn function_count(&self) -> usize

Source

pub fn clear_string_table(&mut self)

Source

pub fn end_function( &mut self, max_stack_size: u8, upvalue_count: u8, flags: u8, cost: u64, ) -> usize

Source

pub fn add_child_function(&mut self, id: u32) -> Option<i16>

Source

pub fn set_main_function(&mut self, id: usize)

Trait Implementations§

Source§

impl<'src> Default for BytecodeBuilder<'src>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'src> !RefUnwindSafe for BytecodeBuilder<'src>

§

impl<'src> !Send for BytecodeBuilder<'src>

§

impl<'src> !Sync for BytecodeBuilder<'src>

§

impl<'src> !UnwindSafe for BytecodeBuilder<'src>

§

impl<'src> Freeze for BytecodeBuilder<'src>

§

impl<'src> Unpin for BytecodeBuilder<'src>

§

impl<'src> UnsafeUnpin for BytecodeBuilder<'src>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.