[][src]Enum jvm_class_file_parser::Bytecode

pub enum Bytecode {
    Aconst_null,
    Iconst_0,
    Iconst_1,
    Ldc(u8),
    Iload_1,
    Aload_0,
    Astore_1,
    Dup,
    Ifeq(u16),
    Ifne(u16),
    Goto(u16),
    Ireturn,
    Return,
    Getstatic(u16),
    Putstatic(u16),
    Getfield(u16),
    Putfield(u16),
    Invokevirtual(u16),
    Invokespecial(u16),
    New(u16),
    Athrow,
    Checkcast(u16),
}

A JVM bytecode instruction.

For more detailed information on the different types of bytecode instructions, see the following section of the Java Virtual Machine Specification.

https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-6.html

Variants

Aconst_nullIconst_0Iconst_1Ldc(u8)Iload_1Aload_0Astore_1DupIfeq(u16)Ifne(u16)Goto(u16)IreturnReturnGetstatic(u16)Putstatic(u16)Getfield(u16)Putfield(u16)Invokevirtual(u16)Invokespecial(u16)New(u16)AthrowCheckcast(u16)

Methods

impl Bytecode[src]

pub fn from_bytes(bytes: &[u8]) -> Vec<(usize, Bytecode)>[src]

Converts the given slice of bytes into the bytecode instructions that they represent.

let bytes = vec![
    42,
    183, 0, 1,
    177,
];

let bytecodes = vec![
    (0, Aload_0),
    (1, Invokespecial(1)),
    (4, Return),
];

assert_eq!(bytecodes, Bytecode::from_bytes(&bytes));

pub fn to_string(&self, index: u16) -> String[src]

Converts the bytecode into a String representation.

Takes in the index of the instruction so that it can be used to display bytecode instructions that contain an instruction offset.

assert_eq!("aconst_null", Aconst_null.to_string(2));
assert_eq!("ifeq          15", Ifeq(5).to_string(10));

Trait Implementations

impl PartialEq<Bytecode> for Bytecode[src]

impl Debug for Bytecode[src]

Auto Trait Implementations

impl Send for Bytecode

impl Sync for Bytecode

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.