mirror of
https://github.com/Noratrieb/coldsquare.git
synced 2026-01-16 17:35:10 +01:00
moving to Java SE16
everything should be done except the attributes
This commit is contained in:
parent
456087553a
commit
8376d22aa6
2 changed files with 40 additions and 11 deletions
|
|
@ -165,7 +165,6 @@ impl Parse for ClassFile {
|
||||||
impl Parse for CpInfo {
|
impl Parse for CpInfo {
|
||||||
fn parse(data: &mut Data, cp: &[CpInfo]) -> Result<Self> {
|
fn parse(data: &mut Data, cp: &[CpInfo]) -> Result<Self> {
|
||||||
let tag = data.u1()?;
|
let tag = data.u1()?;
|
||||||
dbg!(tag);
|
|
||||||
|
|
||||||
Ok(match tag {
|
Ok(match tag {
|
||||||
7 => Self {
|
7 => Self {
|
||||||
|
|
@ -261,6 +260,13 @@ impl Parse for CpInfo {
|
||||||
descriptor_index: data.cp(cp)?,
|
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 {
|
18 => Self {
|
||||||
tag,
|
tag,
|
||||||
inner: CpInfoInner::InvokeDynamic(cp_info::InvokeDynamic {
|
inner: CpInfoInner::InvokeDynamic(cp_info::InvokeDynamic {
|
||||||
|
|
@ -268,6 +274,18 @@ impl Parse for CpInfo {
|
||||||
name_and_type_index: data.cp(cp)?,
|
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))),
|
_ => return Err(ParseErr(format!("Invalid CPInfo tag: {}", tag))),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,6 @@ impl ValidateCpInfo for CpInfoInner {
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||||
pub struct Class {
|
pub struct Class {
|
||||||
/// Entry must be `Utf8`
|
|
||||||
pub name_index: FromPool<Utf8>,
|
pub name_index: FromPool<Utf8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -167,7 +166,6 @@ pub struct Class {
|
||||||
pub struct Fieldref {
|
pub struct Fieldref {
|
||||||
/// May be a class or interface type
|
/// May be a class or interface type
|
||||||
pub class_index: FromPool<Class>,
|
pub class_index: FromPool<Class>,
|
||||||
/// Entry must be `NameAndType`
|
|
||||||
pub name_and_type_index: FromPool<NameAndType>,
|
pub name_and_type_index: FromPool<NameAndType>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -175,7 +173,6 @@ pub struct Fieldref {
|
||||||
pub struct MethodRef {
|
pub struct MethodRef {
|
||||||
/// Must be a class type
|
/// Must be a class type
|
||||||
pub class_index: FromPool<Class>,
|
pub class_index: FromPool<Class>,
|
||||||
/// Entry must be `NameAndType`
|
|
||||||
pub name_and_type_index: FromPool<NameAndType>,
|
pub name_and_type_index: FromPool<NameAndType>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -183,13 +180,11 @@ pub struct MethodRef {
|
||||||
pub struct InterfaceMethodref {
|
pub struct InterfaceMethodref {
|
||||||
/// Must be an interface type
|
/// Must be an interface type
|
||||||
pub class_index: FromPool<Class>,
|
pub class_index: FromPool<Class>,
|
||||||
/// Entry must be `NameAndType`
|
|
||||||
pub name_and_type_index: FromPool<NameAndType>,
|
pub name_and_type_index: FromPool<NameAndType>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||||
pub struct String {
|
pub struct String {
|
||||||
/// Entry must be `Utf8`
|
|
||||||
pub string_index: FromPool<Utf8>,
|
pub string_index: FromPool<Utf8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -226,9 +221,7 @@ pub struct Double {
|
||||||
/// Any field or method, without the class it belongs to
|
/// Any field or method, without the class it belongs to
|
||||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||||
pub struct NameAndType {
|
pub struct NameAndType {
|
||||||
/// Entry must be `Utf8`
|
|
||||||
pub name_index: FromPool<Utf8>,
|
pub name_index: FromPool<Utf8>,
|
||||||
/// Entry must be `Utf8`
|
|
||||||
pub descriptor_index: FromPool<Utf8>,
|
pub descriptor_index: FromPool<Utf8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -256,18 +249,33 @@ pub enum MethodHandleIndex {
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||||
pub struct MethodType {
|
pub struct MethodType {
|
||||||
/// Entry must be `Utf8`
|
|
||||||
pub descriptor_index: FromPool<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)]
|
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||||
pub struct InvokeDynamic {
|
pub struct InvokeDynamic {
|
||||||
/// Must be a valid index into the `bootstrap_methods` array of the bootstrap method table of this class field
|
/// 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 bootstrap_method_attr_index: u2,
|
||||||
/// Entry must `NameAndType`
|
|
||||||
pub name_and_type_index: FromPool<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
|
// default implementations
|
||||||
|
|
||||||
impl_try_from_cp!(
|
impl_try_from_cp!(
|
||||||
|
|
@ -283,7 +291,10 @@ impl_try_from_cp!(
|
||||||
NameAndType,
|
NameAndType,
|
||||||
MethodHandle,
|
MethodHandle,
|
||||||
MethodType,
|
MethodType,
|
||||||
InvokeDynamic
|
Dynamic,
|
||||||
|
InvokeDynamic,
|
||||||
|
Module,
|
||||||
|
Package
|
||||||
);
|
);
|
||||||
|
|
||||||
impl ValidateCpInfo for Utf8 {
|
impl ValidateCpInfo for Utf8 {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue