Closed C0D3-M4513R closed 3 months ago
I'm trying to fix this currently, but I'm getting a curious error:
here are the changes I have made:
Index: src/descriptor.rs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/descriptor.rs b/src/descriptor.rs
--- a/src/descriptor.rs (revision 0526664fc2e0f4166025531885c0ace48d223288)
+++ b/src/descriptor.rs (date 1722371851835)
@@ -82,6 +82,7 @@
impl<'a> FieldType<'a> {
pub(crate) fn parse(chars: &Cow<'a, str>) -> Result<Self, ParseError> {
+ println!("Parsing type: {chars}");
let mut chars_idx = chars.char_indices();
Self::parse_from_chars_idx(chars, &mut chars_idx)
}
Index: src/bytecode.rs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/bytecode.rs b/src/bytecode.rs
--- a/src/bytecode.rs (revision 0526664fc2e0f4166025531885c0ace48d223288)
+++ b/src/bytecode.rs (date 1722377856081)
@@ -9,6 +9,7 @@
ConstantPoolEntry, ConstantPoolEntryTypes, InvokeDynamic, Loadable, MemberRef,
};
use crate::{read_u1, read_u2, read_u4, ParseError};
+use crate::descriptor::FieldType;
pub type JumpOffset = i32;
@@ -44,7 +45,7 @@
Aastore,
AconstNull,
Aload(u16), // both wide and narrow
- Anewarray(Cow<'a, str>),
+ Anewarray(FieldType<'a>),
Areturn,
Arraylength,
Astore(u16), // both wide and narrow
@@ -55,7 +56,7 @@
Breakpoint,
Caload,
Castore,
- Checkcast(Cow<'a, str>),
+ Checkcast(FieldType<'a>),
D2f,
D2i,
D2l,
@@ -142,7 +143,7 @@
Impdep2,
Imul,
Ineg,
- Instanceof(Cow<'a, str>),
+ Instanceof(FieldType<'a>),
Invokedynamic(InvokeDynamic<'a>),
Invokeinterface(MemberRef<'a>, u8),
Invokespecial(MemberRef<'a>),
@@ -187,7 +188,7 @@
Lxor,
Monitorenter,
Monitorexit,
- Multianewarray(Cow<'a, str>, u8),
+ Multianewarray(FieldType<'a>, u8),
New(Cow<'a, str>),
Newarray(PrimitiveArrayType),
Nop,
@@ -633,11 +634,11 @@
};
Opcode::Newarray(primitive_type)
}
- 0xbd => Opcode::Anewarray(read_cp_classinfo(code, &mut ix, pool)?),
+ 0xbd => Opcode::Anewarray(FieldType::parse(&read_cp_classinfo(code, &mut ix, pool)?)?),
0xbe => Opcode::Arraylength,
0xbf => Opcode::Athrow,
- 0xc0 => Opcode::Checkcast(read_cp_classinfo(code, &mut ix, pool)?),
- 0xc1 => Opcode::Instanceof(read_cp_classinfo(code, &mut ix, pool)?),
+ 0xc0 => Opcode::Checkcast(FieldType::parse(&read_cp_classinfo(code, &mut ix, pool)?)?),
+ 0xc1 => Opcode::Instanceof(FieldType::parse(&read_cp_classinfo(code, &mut ix, pool)?)?),
0xc2 => Opcode::Monitorenter,
0xc3 => Opcode::Monitorexit,
0xc4 => {
@@ -663,7 +664,7 @@
}
}
0xc5 => Opcode::Multianewarray(
- read_cp_classinfo(code, &mut ix, pool)?,
+ FieldType::parse(&read_cp_classinfo(code, &mut ix, pool)?)?,
read_u1(code, &mut ix)?,
),
0xc6 => Opcode::Ifnull((read_u2(code, &mut ix)? as i16).into()),
Ah. I realize, I am being stupid here.
The contained str
is only ever a Ty::Object
, hence it is chosen like this.
see: https://asmsupport.github.io/jvmref/ref-anewarray.html