Parses a JVM method descriptor and returns the parameter types as a vector of strings.
(descriptor: &str)
| 625 | }), |
| 626 | }; |
| 627 | } |
| 628 | |
| 629 | if matches!(src, Type::F32 | Type::F64) && matches!(dest, Type::F32 | Type::F64) { |
| 630 | return Ok(match (src, dest) { |
| 631 | (Type::F32, Type::F64) => vec![JI::F2d], |
| 632 | (Type::F64, Type::F32) => vec![JI::D2f], |
| 633 | _ => Vec::new(), |
| 634 | }); |
| 635 | } |
| 636 | |
| 637 | if matches!(src, Type::F32 | Type::F64) && int_width(dest).is_some() { |
| 638 | let prefix = if src == &Type::F32 { "f32" } else { "f64" }; |
| 639 | let source_descriptor = if src == &Type::F32 { "F" } else { "D" }; |
| 640 | let (suffix, return_descriptor, direct) = match dest { |
| 641 | Type::I8 => ("ToI8", "B", None), |
| 642 | Type::I16 => ("ToI16", "S", None), |
| 643 | Type::I32 => ( |
| 644 | "", |
| 645 | "", |
| 646 | Some(if src == &Type::F32 { JI::F2i } else { JI::D2i }), |
| 647 | ), |
| 648 | Type::I64 => ( |
| 649 | "", |
| 650 | "", |
| 651 | Some(if src == &Type::F32 { JI::F2l } else { JI::D2l }), |
| 652 | ), |
| 653 | Type::U8 | Type::Boolean => ("ToU8", "B", None), |
| 654 | Type::U16 | Type::Char => ("ToU16", "C", None), |
| 655 | Type::U32 => ("ToU32", "I", None), |
| 656 | Type::U64 => ("ToU64", "J", None), |
| 657 | _ => unreachable!(), |
| 658 | }; |
| 659 | if let Some(op) = direct { |
| 660 | return Ok(vec![op]); |
| 661 | } |
| 662 | return Ok(vec![numbers_call( |
| 663 | cp, |
| 664 | &format!("{prefix}{suffix}"), |
| 665 | &format!("({source_descriptor}){return_descriptor}"), |
| 666 | )?]); |
| 667 | } |
| 668 | |
| 669 | if int_width(src).is_some() && matches!(dest, Type::F32 | Type::F64) { |
| 670 | let to_f32 = dest == &Type::F32; |
| 671 | return Ok(match src { |
| 672 | Type::U32 => vec![numbers_call( |
| 673 | cp, |
| 674 | if to_f32 { "u32ToF32" } else { "u32ToF64" }, |
| 675 | if to_f32 { "(I)F" } else { "(I)D" }, |
| 676 | )?], |
| 677 | Type::U64 => vec![numbers_call( |
| 678 | cp, |
| 679 | if to_f32 { "u64ToF32" } else { "u64ToF64" }, |
| 680 | if to_f32 { "(J)F" } else { "(J)D" }, |
| 681 | )?], |
| 682 | Type::I64 => vec![if to_f32 { JI::L2f } else { JI::L2d }], |
| 683 | Type::U8 => vec![ |
| 684 | get_int_const_instr(cp, 0xff), |
no test coverage detected