Skip to main content

JvmProgram

Struct JvmProgram 

Source
pub struct JvmProgram {
    pub name: String,
    pub access_flags: JvmAccessFlags,
    pub super_class: Option<String>,
    pub interfaces: Vec<String>,
    pub fields: Vec<JvmField>,
    pub methods: Vec<JvmMethod>,
    pub attributes: Vec<JvmAttribute>,
    pub constant_pool: JvmConstantPool,
    pub version: JvmVersion,
    pub source_file: Option<String>,
    pub inner_classes: Vec<JvmInnerClass>,
    pub enclosing_method: Option<(String, Option<String>, Option<String>)>,
}
Expand description

High-level representation of a JVM program

Fields§

§name: String

Program name (class name)

§access_flags: JvmAccessFlags

Access flags

§super_class: Option<String>

Super class name

§interfaces: Vec<String>

List of implemented interfaces

§fields: Vec<JvmField>

List of fields

§methods: Vec<JvmMethod>

List of methods

§attributes: Vec<JvmAttribute>

List of attributes

§constant_pool: JvmConstantPool

Constant pool (high-level representation)

§version: JvmVersion

Version information

§source_file: Option<String>

Source file information

§inner_classes: Vec<JvmInnerClass>

List of inner classes

§enclosing_method: Option<(String, Option<String>, Option<String>)>

Enclosing method information

Implementations§

Source§

impl JvmProgram

Source

pub fn new(name: String) -> Self

Creates a new JVM program with given name

Source

pub fn set_version(&mut self, major: u16, minor: u16)

Sets JVM version

Source

pub fn set_super_class(&mut self, super_class: String)

Sets super class name

Source

pub fn add_interface(&mut self, interface: String)

Adds an interface to the program

Source

pub fn add_method(&mut self, method: JvmMethod)

Adds a method to the program

Source

pub fn add_field(&mut self, field: JvmField)

Adds a field to the program

Source

pub fn add_attribute(&mut self, attribute: JvmAttribute)

Adds an attribute to the program

Source

pub fn set_source_file(&mut self, filename: String)

Sets source file name and adds SourceFile attribute

Source

pub fn validate(&self) -> bool

Validates the program

Source

pub fn add_bootstrap_method(&mut self, method_ref: u16, arguments: Vec<u16>)

Adds a bootstrap method to the program

Source

pub fn create_lambda_method( &mut self, name: String, descriptor: String, instructions: Vec<JvmInstruction>, ) -> JvmMethod

Creates a synthetic method for lambda expression

Source

pub fn create_method_reference_bootstrap( &mut self, method_ref: u16, method_type: u16, )

Creates a method reference bootstrap method

Source

pub fn add_inner_class(&mut self, inner_class: JvmInnerClass)

Adds an inner class to the program

Source

pub fn add_inner_classes_attribute(&mut self)

Adds InnerClasses attribute to the program

Source

pub fn set_enclosing_method( &mut self, class_name: String, method_name: Option<String>, method_descriptor: Option<String>, )

Sets enclosing method information

Source

pub fn add_enclosing_method_attribute(&mut self)

Adds EnclosingMethod attribute to the program

Trait Implementations§

Source§

impl Clone for JvmProgram

Source§

fn clone(&self) -> JvmProgram

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for JvmProgram

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more