pub enum Type {
Void,
Boolean,
Char,
Byte,
Short,
Int,
Float,
Long,
Double,
Array(Box<Type>),
Object(String),
Method {
argument_types: Vec<Type>,
return_type: Box<Type>,
},
}Variants§
Void
Boolean
Char
Byte
Short
Int
Float
Long
Double
Array(Box<Type>)
Array type, with the element type (which may itself be an array).
Object(String)
Object type, storing the internal name (e.g. "java/lang/Object").
Method
Method type, storing argument types and return type.
Implementations§
Source§impl Type
impl Type
pub const VOID_TYPE: Type = Type::Void
pub const BOOLEAN_TYPE: Type = Type::Boolean
pub const CHAR_TYPE: Type = Type::Char
pub const BYTE_TYPE: Type = Type::Byte
pub const SHORT_TYPE: Type = Type::Short
pub const INT_TYPE: Type = Type::Int
pub const FLOAT_TYPE: Type = Type::Float
pub const LONG_TYPE: Type = Type::Long
pub const DOUBLE_TYPE: Type = Type::Double
Sourcepub fn get_type(descriptor: &str) -> Self
pub fn get_type(descriptor: &str) -> Self
Returns the Type corresponding to the given field or method descriptor.
§Panics
Panics if the descriptor is invalid.
Sourcepub fn get_object_type(internal_name: &str) -> Self
pub fn get_object_type(internal_name: &str) -> Self
Returns the Type corresponding to the given internal name.
If the name starts with '[', it is treated as an array descriptor.
Sourcepub fn get_method_type(descriptor: &str) -> Self
pub fn get_method_type(descriptor: &str) -> Self
Returns the method Type corresponding to the given method descriptor.
§Panics
Panics if the descriptor is not a valid method descriptor.
Sourcepub fn get_method_type_from_parts(
return_type: Type,
argument_types: Vec<Type>,
) -> Self
pub fn get_method_type_from_parts( return_type: Type, argument_types: Vec<Type>, ) -> Self
Creates a method type from its return type and argument types.
Sourcepub fn get_sort(&self) -> u8
pub fn get_sort(&self) -> u8
Returns the sort of this type (as an integer, compatible with ASM constants).
Sourcepub fn get_descriptor(&self) -> String
pub fn get_descriptor(&self) -> String
Returns the descriptor of this type.
Sourcepub fn get_class_name(&self) -> String
pub fn get_class_name(&self) -> String
Returns the Java class name corresponding to this type (e.g. “int”, “java.lang.Object[]”).
Sourcepub fn internal_name(&self) -> Option<String>
pub fn internal_name(&self) -> Option<String>
Returns the internal name of this type.
For object types, this is the internal name (e.g. "java/lang/Object").
For array types, this is the descriptor itself (e.g. "[I").
For other types, returns None.
Sourcepub fn get_dimensions(&self) -> usize
pub fn get_dimensions(&self) -> usize
If this is an array type, returns the number of dimensions. Otherwise returns 0.
Sourcepub fn get_element_type(&self) -> Option<&Type>
pub fn get_element_type(&self) -> Option<&Type>
If this is an array type, returns the element type (which may itself be an array).
Otherwise returns None.
Sourcepub fn get_argument_types(&self) -> Option<&[Type]>
pub fn get_argument_types(&self) -> Option<&[Type]>
If this is a method type, returns the argument types.
Sourcepub fn get_return_type(&self) -> Option<&Type>
pub fn get_return_type(&self) -> Option<&Type>
If this is a method type, returns the return type.
Sourcepub fn get_size(&self) -> usize
pub fn get_size(&self) -> usize
Returns the size of values of this type (1 for most, 2 for long/double, 0 for void).
Sourcepub fn get_argument_count(&self) -> usize
pub fn get_argument_count(&self) -> usize
Returns the number of arguments of this method type. Panics if called on a non-method type.