I can't even describe my disappointment at interfaces
This commit is contained in:
parent
d7d159d115
commit
9190d3f7e7
4 changed files with 116 additions and 15 deletions
|
@ -5,7 +5,7 @@ use core::str::Utf8Error;
|
|||
|
||||
use crate::accessmasks::*;
|
||||
use crate::bytecode::Bytecode;
|
||||
use crate::constantpool::{ ConstantFieldRefInfo, ConstantPoolInfo, ConstantUtf8Info, ConstantStringInfo, ConstantMethodRefInfo, ConstantFloatInfo, ConstantClassInfo, ConstantNameAndTypeInfo, ConstantIntegerInfo, ConstantLongInfo };
|
||||
use crate::constantpool::{ ConstantFieldRefInfo, ConstantPoolInfo, ConstantUtf8Info, ConstantInterfaceMethodRefInfo, ConstantStringInfo, ConstantMethodRefInfo, ConstantFloatInfo, ConstantClassInfo, ConstantNameAndTypeInfo, ConstantIntegerInfo, ConstantLongInfo };
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
|
@ -206,6 +206,17 @@ impl JavaClassFile {
|
|||
return pool_entry(&self.constant_pool, index);
|
||||
}
|
||||
|
||||
pub fn pool_interfacemethodref_entry(&self, index: u16) -> Result<&ConstantInterfaceMethodRefInfo, Error> {
|
||||
let pool_entry = self.pool_entry(index)?;
|
||||
|
||||
let methodref_entry = match pool_entry {
|
||||
ConstantPoolInfo::InterfaceMethodRef(data) => data,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
return Ok(methodref_entry);
|
||||
}
|
||||
|
||||
pub fn pool_methodref_entry(&self, index: u16) -> Result<&ConstantMethodRefInfo, Error> {
|
||||
let pool_entry = self.pool_entry(index)?;
|
||||
|
||||
|
@ -329,6 +340,19 @@ impl JavaClassFile {
|
|||
Ok(class_name)
|
||||
}
|
||||
|
||||
pub fn gather_interfacemethodref(&self, index: u16) -> Result<(&String, &String, &String), Error> {
|
||||
let methodref = self.pool_interfacemethodref_entry(index)?;
|
||||
let class_entry = self.pool_class_entry(methodref.class_index)?;
|
||||
let class_name_entry = self.pool_utf8_entry(class_entry.name_index)?;
|
||||
let name_and_type_entry = self.pool_nameandtype_entry(methodref.name_and_type_index)?;
|
||||
|
||||
let class_name = &class_name_entry.utf8;
|
||||
let method_name = &self.pool_utf8_entry(name_and_type_entry.name_index)?.utf8;
|
||||
let method_descriptor = &self.pool_utf8_entry(name_and_type_entry.descriptor_index)?.utf8;
|
||||
|
||||
return Ok((class_name, method_name, method_descriptor));
|
||||
}
|
||||
|
||||
pub fn gather_methodref(&self, index: u16) -> Result<(&String, &String, &String), Error> {
|
||||
let methodref = self.pool_methodref_entry(index)?;
|
||||
let class_entry = self.pool_class_entry(methodref.class_index)?;
|
||||
|
@ -886,6 +910,13 @@ impl AbstractTypeDescription {
|
|||
|
||||
return Ok((offset, AbstractTypeDescription { array_level, kind }))
|
||||
}
|
||||
|
||||
pub fn for_class_name(name: &str) -> Self {
|
||||
AbstractTypeDescription {
|
||||
array_level: 0,
|
||||
kind: AbstractTypeKind::Classname(name.to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue