mirror of
https://github.com/Noratrieb/coldsquare.git
synced 2026-01-16 09:25:08 +01:00
Merge remote-tracking branch 'origin/master' into master
This commit is contained in:
commit
6dd9a0df68
6 changed files with 320 additions and 28 deletions
|
|
@ -165,7 +165,6 @@ impl Parse for ClassFile {
|
|||
impl Parse for CpInfo {
|
||||
fn parse(data: &mut Data, cp: &[CpInfo]) -> Result<Self> {
|
||||
let tag = data.u1()?;
|
||||
dbg!(tag);
|
||||
|
||||
Ok(match tag {
|
||||
7 => Self {
|
||||
|
|
@ -261,6 +260,13 @@ impl Parse for CpInfo {
|
|||
descriptor_index: data.cp(cp)?,
|
||||
}),
|
||||
},
|
||||
17 => Self {
|
||||
tag,
|
||||
inner: CpInfoInner::Dynamic(cp_info::Dynamic {
|
||||
bootstrap_method_attr_index: data.u2()?,
|
||||
name_and_type_index: data.cp(cp)?,
|
||||
}),
|
||||
},
|
||||
18 => Self {
|
||||
tag,
|
||||
inner: CpInfoInner::InvokeDynamic(cp_info::InvokeDynamic {
|
||||
|
|
@ -268,6 +274,18 @@ impl Parse for CpInfo {
|
|||
name_and_type_index: data.cp(cp)?,
|
||||
}),
|
||||
},
|
||||
19 => Self {
|
||||
tag,
|
||||
inner: CpInfoInner::Module(cp_info::Module {
|
||||
name_index: data.cp(cp)?,
|
||||
}),
|
||||
},
|
||||
20 => Self {
|
||||
tag,
|
||||
inner: CpInfoInner::Package(cp_info::Package {
|
||||
name_index: data.cp(cp)?,
|
||||
}),
|
||||
},
|
||||
_ => return Err(ParseErr(format!("Invalid CPInfo tag: {}", tag))),
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -159,7 +159,6 @@ impl ValidateCpInfo for CpInfoInner {
|
|||
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
pub struct Class {
|
||||
/// Entry must be `Utf8`
|
||||
pub name_index: FromPool<Utf8>,
|
||||
}
|
||||
|
||||
|
|
@ -167,7 +166,6 @@ pub struct Class {
|
|||
pub struct Fieldref {
|
||||
/// May be a class or interface type
|
||||
pub class_index: FromPool<Class>,
|
||||
/// Entry must be `NameAndType`
|
||||
pub name_and_type_index: FromPool<NameAndType>,
|
||||
}
|
||||
|
||||
|
|
@ -175,7 +173,6 @@ pub struct Fieldref {
|
|||
pub struct MethodRef {
|
||||
/// Must be a class type
|
||||
pub class_index: FromPool<Class>,
|
||||
/// Entry must be `NameAndType`
|
||||
pub name_and_type_index: FromPool<NameAndType>,
|
||||
}
|
||||
|
||||
|
|
@ -183,13 +180,11 @@ pub struct MethodRef {
|
|||
pub struct InterfaceMethodref {
|
||||
/// Must be an interface type
|
||||
pub class_index: FromPool<Class>,
|
||||
/// Entry must be `NameAndType`
|
||||
pub name_and_type_index: FromPool<NameAndType>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
pub struct String {
|
||||
/// Entry must be `Utf8`
|
||||
pub string_index: FromPool<Utf8>,
|
||||
}
|
||||
|
||||
|
|
@ -226,9 +221,7 @@ pub struct Double {
|
|||
/// Any field or method, without the class it belongs to
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
pub struct NameAndType {
|
||||
/// Entry must be `Utf8`
|
||||
pub name_index: FromPool<Utf8>,
|
||||
/// Entry must be `Utf8`
|
||||
pub descriptor_index: FromPool<Utf8>,
|
||||
}
|
||||
|
||||
|
|
@ -256,18 +249,33 @@ pub enum MethodHandleIndex {
|
|||
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
pub struct MethodType {
|
||||
/// Entry must be `Utf8`
|
||||
pub descriptor_index: FromPool<Utf8>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
pub struct Dynamic {
|
||||
/// Must be a valid index into the `bootstrap_methods` array of the bootstrap method table of this class field
|
||||
pub bootstrap_method_attr_index: u2,
|
||||
pub name_and_type_index: FromPool<NameAndType>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
pub struct InvokeDynamic {
|
||||
/// Must be a valid index into the `bootstrap_methods` array of the bootstrap method table of this class field
|
||||
pub bootstrap_method_attr_index: u2,
|
||||
/// Entry must `NameAndType`
|
||||
pub name_and_type_index: FromPool<NameAndType>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
pub struct Module {
|
||||
pub name_index: FromPool<Utf8>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
pub struct Package {
|
||||
pub name_index: FromPool<Utf8>,
|
||||
}
|
||||
|
||||
// default implementations
|
||||
|
||||
impl_try_from_cp!(
|
||||
|
|
@ -283,7 +291,10 @@ impl_try_from_cp!(
|
|||
NameAndType,
|
||||
MethodHandle,
|
||||
MethodType,
|
||||
InvokeDynamic
|
||||
Dynamic,
|
||||
InvokeDynamic,
|
||||
Module,
|
||||
Package
|
||||
);
|
||||
|
||||
impl ValidateCpInfo for Utf8 {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
//! The models for a .class file
|
||||
//!
|
||||
//! [The .class specs](https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html)
|
||||
//!
|
||||
//! todo poart to [SE16](https://docs.oracle.com/javase/specs/jvms/se16/html/jvms-4.html)
|
||||
#![allow(dead_code)]
|
||||
|
||||
/// All of the Constants in the Constant Pool
|
||||
|
|
@ -74,7 +76,10 @@ pub enum CpInfoInner {
|
|||
Utf8(cp_info::Utf8),
|
||||
MethodHandle(cp_info::MethodHandle),
|
||||
MethodType(cp_info::MethodType),
|
||||
Dynamic(cp_info::Dynamic),
|
||||
InvokeDynamic(cp_info::InvokeDynamic),
|
||||
Module(cp_info::Module),
|
||||
Package(cp_info::Package),
|
||||
}
|
||||
|
||||
/// Information about a field
|
||||
|
|
@ -222,6 +227,14 @@ pub enum AttributeInfoInner {
|
|||
BootstrapMethods {
|
||||
bootstrap_methods: Vec<BootstrapMethod>,
|
||||
},
|
||||
// todo
|
||||
MethodParameters,
|
||||
Module,
|
||||
ModulePackages,
|
||||
ModuleMainClass,
|
||||
NestHost,
|
||||
NestMembers,
|
||||
Record,
|
||||
}
|
||||
|
||||
/// An exception handler in the JVM bytecode array
|
||||
|
|
@ -450,6 +463,8 @@ pub enum ClassAccessFlag {
|
|||
Annotation = 0x2000,
|
||||
/// Declared as an enum type.
|
||||
Enum = 0x4000,
|
||||
/// Is a module, not a class or interface.
|
||||
MODULE = 0x8000,
|
||||
}
|
||||
|
||||
/// Access Flags of a method
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue