Implemented a lot of opcodes and some native methods

This commit is contained in:
vegowotenks 2024-11-03 17:42:04 +01:00
parent 4c43e9290f
commit 272a34b7cd
5 changed files with 394 additions and 101 deletions

View file

@ -6,6 +6,7 @@ use core::str::Utf8Error;
use crate::accessmasks::*;
use crate::bytecode::Bytecode;
use crate::constantpool::{ ConstantFieldRefInfo, ConstantPoolInfo, ConstantUtf8Info, ConstantInterfaceMethodRefInfo, ConstantStringInfo, ConstantMethodRefInfo, ConstantFloatInfo, ConstantClassInfo, ConstantNameAndTypeInfo, ConstantIntegerInfo, ConstantLongInfo };
use crate::constantpool::ConstantDoubleInfo;
#[derive(Debug)]
pub enum Error {
@ -266,6 +267,15 @@ impl JavaClassFile {
};
}
pub fn pool_double_entry(&self, index: u16) -> Result<&ConstantDoubleInfo, Error> {
let pool_entry = self.pool_entry(index)?;
return match pool_entry {
ConstantPoolInfo::Double(data) => Ok(data),
_ => Err(Error::BadFileError(format!("Expected constant pool entry {} in class {} to be of type Double but found {:?}", index, self.get_classname()?, pool_entry)))
};
}
pub fn pool_long_entry(&self, index: u16) -> Result<&ConstantLongInfo, Error> {
let pool_entry = self.pool_entry(index)?;