Implements the `PowerInteger` opcode.
(&mut self, instr: u32)
| 1027 | |
| 1028 | /// Implements the `PowerInteger` opcode. |
| 1029 | pub(super) fn do_power_integer(&mut self, instr: u32) { |
| 1030 | let (dest, src1, src2) = bytecode::parse_power_integer(instr); |
| 1031 | let lhs = self.get_reg(src1) as i32; |
| 1032 | let rhs = self.get_reg(src2) as i32; |
| 1033 | let exp = match u32::try_from(rhs) { |
| 1034 | Ok(exp) => exp, |
| 1035 | Err(_) => { |
| 1036 | self.set_exception(format!("Exponent {} cannot be negative", rhs)); |
| 1037 | return; |
| 1038 | } |
| 1039 | }; |
| 1040 | match checked_pow_integer(lhs, exp) { |
| 1041 | Ok(result) => { |
| 1042 | self.set_reg(dest, result as u64); |
| 1043 | self.pc += 1; |
| 1044 | } |
| 1045 | Err(msg) => { |
| 1046 | self.set_exception(msg); |
| 1047 | } |
| 1048 | } |
| 1049 | } |
| 1050 | |
| 1051 | /// Implements the `Return` opcode. |
| 1052 | pub(super) fn do_return(&mut self, instr: u32) { |
no test coverage detected