Helper for shift amount conversion (must be usize for BigInt shifts)
(op2: &Constant)
| 655 | match array { |
| 656 | Constant::Array(_, elems) => Some(Constant::I32( |
| 657 | elems.len().try_into().ok().unwrap_or(i32::MAX), // Handle potential overflow |
| 658 | )), |
| 659 | _ => None, // Not an array |
| 660 | } |
| 661 | } |
| 662 | |
| 663 | pub fn get_field_constant(instance: Constant, field_name: String) -> Option<Constant> { |
| 664 | match instance { |
| 665 | Constant::Instance { fields, .. } => fields.get(&field_name).cloned(), |
| 666 | _ => None, // Not an instance or doesn't have fields map |
| 667 | } |
| 668 | } |
| 669 | |
| 670 | impl Constant { |
| 671 | fn as_i8(&self) -> Option<i8> { |
no test coverage detected