(instruction: &Instruction)
| 1554 | } |
| 1555 | let absolute_target = absolute_target as usize; |
| 1556 | let mapped = old_to_new |
| 1557 | .get(absolute_target) |
| 1558 | .and_then(|mapped| *mapped) |
| 1559 | .ok_or_else(|| jvm::Error::VerificationError { |
| 1560 | context: "optimise2".to_string(), |
| 1561 | message: format!("Removed or invalid switch target {absolute_target}"), |
| 1562 | })?; |
| 1563 | i32::try_from(mapped as i64 - new_index as i64).map_err(|_| jvm::Error::VerificationError { |
| 1564 | context: "optimise2".to_string(), |
| 1565 | message: format!("Switch target delta overflow for target {absolute_target}"), |
| 1566 | }) |
| 1567 | }; |
| 1568 | |
| 1569 | Ok(match instruction { |
| 1570 | I::Ifeq(target) => I::Ifeq(map_u16(target)?), |
| 1571 | I::Ifne(target) => I::Ifne(map_u16(target)?), |
| 1572 | I::Iflt(target) => I::Iflt(map_u16(target)?), |
| 1573 | I::Ifge(target) => I::Ifge(map_u16(target)?), |
| 1574 | I::Ifgt(target) => I::Ifgt(map_u16(target)?), |
| 1575 | I::Ifle(target) => I::Ifle(map_u16(target)?), |
| 1576 | I::If_icmpeq(target) => I::If_icmpeq(map_u16(target)?), |
| 1577 | I::If_icmpne(target) => I::If_icmpne(map_u16(target)?), |
| 1578 | I::If_icmplt(target) => I::If_icmplt(map_u16(target)?), |
| 1579 | I::If_icmpge(target) => I::If_icmpge(map_u16(target)?), |
| 1580 | I::If_icmpgt(target) => I::If_icmpgt(map_u16(target)?), |
| 1581 | I::If_icmple(target) => I::If_icmple(map_u16(target)?), |
| 1582 | I::If_acmpeq(target) => I::If_acmpeq(map_u16(target)?), |
| 1583 | I::If_acmpne(target) => I::If_acmpne(map_u16(target)?), |
| 1584 | I::Goto(target) => I::Goto(map_u16(target)?), |
| 1585 | I::Jsr(target) => I::Jsr(map_u16(target)?), |
| 1586 | I::Ifnull(target) => I::Ifnull(map_u16(target)?), |
| 1587 | I::Ifnonnull(target) => I::Ifnonnull(map_u16(target)?), |
| 1588 | I::Goto_w(target) => I::Goto_w(map_i32(target)?), |
| 1589 | I::Jsr_w(target) => I::Jsr_w(map_i32(target)?), |
| 1590 | I::Tableswitch(mut table_switch) => { |
| 1591 | table_switch.default = map_switch_i32(table_switch.default)?; |
| 1592 | for target in &mut table_switch.offsets { |
| 1593 | *target = map_switch_i32(*target)?; |
| 1594 | } |
| 1595 | I::Tableswitch(table_switch) |
no test coverage detected