1
0

27 lines
627 B
Rust
Raw Normal View History

2024-12-17 07:10:47 -05:00
use std::{ops::Range, panic};
2024-12-17 07:10:47 -05:00
use crate::{
vm::{Record, ThreadSignal},
NativeFunctionError,
};
pub fn panic(
2024-12-17 03:22:44 -05:00
record: &mut Record,
2024-12-17 07:10:47 -05:00
_: Option<u8>,
argument_range: Range<u8>,
) -> Result<ThreadSignal, NativeFunctionError> {
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)
}