2024-12-17 07:10:47 -05:00
|
|
|
use std::{ops::Range, panic};
|
2024-12-10 01:34:53 -05:00
|
|
|
|
2025-01-08 23:02:08 -05:00
|
|
|
use crate::vm::ThreadData;
|
2024-12-10 01:34:53 -05:00
|
|
|
|
2025-01-09 19:56:36 -05:00
|
|
|
pub fn panic(data: &mut ThreadData, _: u8, argument_range: Range<u8>) -> bool {
|
2025-01-09 05:31:45 -05:00
|
|
|
let position = data.current_position();
|
2024-12-17 07:10:47 -05:00
|
|
|
let mut message = format!("Dust panic at {position}!");
|
2024-12-10 01:34:53 -05:00
|
|
|
|
2024-12-17 07:10:47 -05:00
|
|
|
for register_index in argument_range {
|
2025-01-09 05:31:45 -05:00
|
|
|
let value_option = data.open_register_allow_empty_unchecked(register_index);
|
|
|
|
let value = match value_option {
|
|
|
|
Some(value) => value,
|
|
|
|
None => continue,
|
|
|
|
};
|
|
|
|
let string = value.display(data);
|
2024-12-10 01:34:53 -05:00
|
|
|
|
2025-01-09 05:31:45 -05:00
|
|
|
message.push_str(&string);
|
|
|
|
message.push('\n');
|
2024-12-10 01:34:53 -05:00
|
|
|
}
|
|
|
|
|
2024-12-17 07:10:47 -05:00
|
|
|
panic!("{}", message)
|
2024-12-10 01:34:53 -05:00
|
|
|
}
|