pub struct ConstantPoolBuilder { /* private fields */ }Expand description
A builder for the constant pool of a class.
This struct manages the deduplication of constant pool entries, ensuring that strings, classes, and member references are stored efficiently.
Implementations§
Source§impl ConstantPoolBuilder
impl ConstantPoolBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new, empty ConstantPoolBuilder.
The constant pool starts with a dummy entry at index 0, as per JVM spec.
Sourcepub fn into_pool(self) -> Vec<CpInfo>
pub fn into_pool(self) -> Vec<CpInfo>
Consumes the builder and returns the raw vector of CpInfo entries.
Sourcepub fn utf8(&mut self, value: &str) -> u16
pub fn utf8(&mut self, value: &str) -> u16
Adds a UTF-8 string to the constant pool if it doesn’t exist.
Returns the index of the entry.
Sourcepub fn class(&mut self, name: &str) -> u16
pub fn class(&mut self, name: &str) -> u16
Adds a Class constant to the pool.
This will recursively add the UTF-8 name of the class.
Sourcepub fn string(&mut self, value: &str) -> u16
pub fn string(&mut self, value: &str) -> u16
Adds a String constant to the pool.
This is for string literals (e.g., ldc "foo").
pub fn integer(&mut self, value: i32) -> u16
pub fn float(&mut self, value: f32) -> u16
pub fn long(&mut self, value: i64) -> u16
pub fn double(&mut self, value: f64) -> u16
Sourcepub fn name_and_type(&mut self, name: &str, descriptor: &str) -> u16
pub fn name_and_type(&mut self, name: &str, descriptor: &str) -> u16
Adds a NameAndType constant to the pool.
Used for field and method descriptors.
Trait Implementations§
Source§impl Debug for ConstantPoolBuilder
impl Debug for ConstantPoolBuilder
Source§impl Default for ConstantPoolBuilder
impl Default for ConstantPoolBuilder
Source§fn default() -> ConstantPoolBuilder
fn default() -> ConstantPoolBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ConstantPoolBuilder
impl RefUnwindSafe for ConstantPoolBuilder
impl Send for ConstantPoolBuilder
impl Sync for ConstantPoolBuilder
impl Unpin for ConstantPoolBuilder
impl UnsafeUnpin for ConstantPoolBuilder
impl UnwindSafe for ConstantPoolBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more