1
0

21 lines
598 B
Rust
Raw Normal View History

2024-12-17 07:10:47 -05:00
use std::{ops::Range, panic};
2025-01-08 23:02:08 -05:00
use crate::vm::ThreadData;
2025-01-08 23:02:08 -05:00
pub fn panic(data: &mut ThreadData, _: Option<u8>, argument_range: Range<u8>) -> bool {
let record = &mut data.call_stack.last_mut_unchecked().record;
2024-12-17 07:10:47 -05:00
let position = record.current_position();
let mut message = format!("Dust panic at {position}!");
2024-12-17 07:10:47 -05:00
for register_index in argument_range {
2025-01-08 10:29:53 -05:00
let value = record.open_register_unchecked(register_index);
2024-12-17 07:10:47 -05:00
if let Some(string) = value.as_string() {
message.push_str(string);
2024-12-17 07:10:47 -05:00
message.push('\n');
}
}
2024-12-17 07:10:47 -05:00
panic!("{}", message)
}