frames: JDK hierarchy fallback, array-operand rewrite, aaload fixes; LoVisual 131 to 0 FAIL
This commit is contained in:
parent
1c417f596c
commit
63630dd223
14 changed files with 562 additions and 116 deletions
|
|
@ -191,3 +191,77 @@ fn subclass_gets_alias_for_inherited_member() {
|
|||
// Чужого члена не выдумываем.
|
||||
assert_eq!(maps.method("p/Sub", "other", "()V"), None);
|
||||
}
|
||||
|
||||
/// Array type operands (`checkcast`, `instanceof`, `anewarray`,
|
||||
/// `multianewarray`) carry descriptors, not plain names: the element class
|
||||
/// inside must follow the mapping, or the reference silently goes stale
|
||||
/// (and the next frame computation merges against a ghost type).
|
||||
#[test]
|
||||
fn array_type_operands_follow_their_element() {
|
||||
let mut program = sample();
|
||||
let main = program
|
||||
.classes
|
||||
.iter_mut()
|
||||
.find(|c| c.this_class == "app/Main")
|
||||
.expect("main");
|
||||
let probe = main
|
||||
.methods
|
||||
.iter_mut()
|
||||
.find(|m| m.name == "main")
|
||||
.expect("main method");
|
||||
let code = probe.code.as_mut().expect("code");
|
||||
code.insns.extend([
|
||||
Insn::CheckCast("[Lapp/Helper;".to_string()),
|
||||
Insn::Pop,
|
||||
Insn::InstanceOf("[Lapp/Helper;".to_string()),
|
||||
Insn::Pop,
|
||||
Insn::ANewArray("app/Helper".to_string()),
|
||||
Insn::Pop,
|
||||
Insn::MultiANewArray {
|
||||
descriptor: "[[Lapp/Helper;".to_string(),
|
||||
dims: 2,
|
||||
},
|
||||
Insn::Pop,
|
||||
]);
|
||||
let ctx = run_rename(&mut program);
|
||||
let helper = ctx.mapping.class("app/Helper").expect("renamed");
|
||||
let main = program.class("app/Main").expect("kept");
|
||||
let method = main
|
||||
.methods
|
||||
.iter()
|
||||
.find(|m| m.name == "main")
|
||||
.expect("main");
|
||||
let insns = &method.code.as_ref().expect("code").insns;
|
||||
let cast = insns
|
||||
.iter()
|
||||
.find_map(|i| match i {
|
||||
Insn::CheckCast(name) => Some(name),
|
||||
_ => None,
|
||||
})
|
||||
.expect("checkcast");
|
||||
assert_eq!(cast, &format!("[L{helper};"));
|
||||
let inst = insns
|
||||
.iter()
|
||||
.find_map(|i| match i {
|
||||
Insn::InstanceOf(name) => Some(name),
|
||||
_ => None,
|
||||
})
|
||||
.expect("instanceof");
|
||||
assert_eq!(inst, &format!("[L{helper};"));
|
||||
let anew = insns
|
||||
.iter()
|
||||
.find_map(|i| match i {
|
||||
Insn::ANewArray(name) => Some(name),
|
||||
_ => None,
|
||||
})
|
||||
.expect("anewarray");
|
||||
assert_eq!(anew, helper);
|
||||
let multi = insns
|
||||
.iter()
|
||||
.find_map(|i| match i {
|
||||
Insn::MultiANewArray { descriptor, .. } => Some(descriptor),
|
||||
_ => None,
|
||||
})
|
||||
.expect("multianewarray");
|
||||
assert_eq!(multi, &format!("[[L{helper};"));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue