Handles an exception raised at `pc`, corresponding to `pos`, with `message`. Returns true if the error was handled.
(
&mut self,
image: &Image,
pc: usize,
pos: LineCol,
message: String,
)
| 333 | |
| 334 | /// Handles an exception raised at `pc`, corresponding to `pos`, with `message`. Returns true if the error was handled. |
| 335 | fn handle_exception( |
| 336 | &mut self, |
| 337 | image: &Image, |
| 338 | pc: usize, |
| 339 | pos: LineCol, |
| 340 | message: String, |
| 341 | ) -> bool { |
| 342 | self.last_error = Some((pos, message)); |
| 343 | |
| 344 | match self.context.error_handler() { |
| 345 | ErrorHandler::None => false, |
| 346 | ErrorHandler::Jump { active: true, .. } => false, |
| 347 | ErrorHandler::Jump { active: false, addr } => { |
| 348 | self.context.set_error_handler_active(); |
| 349 | self.context.set_pc(addr); |
| 350 | true |
| 351 | } |
| 352 | ErrorHandler::ResumeNext => { |
| 353 | let mut next_pc = image.code.len(); |
| 354 | for (idx, meta) in image.debug_info.instrs.iter().enumerate().skip(pc + 1) { |
| 355 | if meta.is_stmt_start { |
| 356 | next_pc = idx; |
| 357 | break; |
| 358 | } |
| 359 | } |
| 360 | self.context.set_pc(next_pc); |
| 361 | true |
| 362 | } |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | /// Returns the value of the global scalar variable `key` as a `ConstantDatum`. |
| 367 | /// |
no test coverage detected