Skip to main content

CodeWriter

Struct CodeWriter 

Source
pub struct CodeWriter {
    pub max_stack: u16,
    pub max_locals: u16,
    pub bytecode: Vec<u8>,
    pub exception_table: Vec<ExceptionHandler>,
    /* private fields */
}

Fields§

§max_stack: u16§max_locals: u16§bytecode: Vec<u8>§exception_table: Vec<ExceptionHandler>

Implementations§

Source§

impl CodeWriter

Source

pub fn new(max_stack: u16, max_locals: u16) -> Self

Source

pub fn current_pc(&self) -> u16

Source

pub fn new_label(&mut self) -> LabelId

Source

pub fn bind_label(&mut self, label: LabelId)

Source

pub fn bind_label_with_frame( &mut self, label: LabelId, locals: Vec<VerificationType>, stack: Vec<VerificationType>, )

Binds a label and records an explicit StackMapTable FullFrame at this PC.

Source

pub fn emit_u8(&mut self, b: u8)

Source

pub fn emit_u16(&mut self, val: u16)

Source

pub fn emit_i16(&mut self, val: i16)

Source

pub fn emit_jump(&mut self, opcode: u8, target: LabelId)

Source

pub fn emit_int_const(&mut self, value: i32)

Source

pub fn emit_ldc(&mut self, cp_idx: u16)

Source

pub fn emit_load(&mut self, ty: &JvmType, slot: u16)

Source

pub fn emit_aload(&mut self, slot: u16)

Source

pub fn emit_astore(&mut self, slot: u16)

Source

pub fn emit_return(&mut self, ty: &JvmType)

Source

pub fn emit_box_if_primitive(&mut self, cp: &mut ConstantPool, ty: &JvmType)

Boxes a primitive value on the top of the operand stack into its java.lang.* wrapper.

Source

pub fn emit_unbox_or_cast(&mut self, cp: &mut ConstantPool, ty: &JvmType)

Casts or unboxes java/lang/Object on top of the stack to the expected JvmType.

Source

pub fn finalize_jumps(&mut self) -> Result<(), String>

Trait Implementations§

Source§

impl Clone for CodeWriter

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CodeWriter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.