update zig and rust platforms to have correct roc_panic and roc_dbg

This commit is contained in:
Brendan Hansknecht 2023-11-29 21:49:34 -08:00
parent 1f14aa84a2
commit 3e66254b25
No known key found for this signature in database
GPG key ID: 0EA784685083E75B
43 changed files with 475 additions and 201 deletions

View file

@ -49,16 +49,22 @@ pub unsafe extern "C" fn roc_dealloc(c_ptr: *mut c_void, _alignment: u32) {
}
#[no_mangle]
pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
pub unsafe extern "C" fn roc_panic(msg: *mut RocStr, tag_id: u32) {
match tag_id {
0 => {
let slice = CStr::from_ptr(c_ptr as *const c_char);
let string = slice.to_str().unwrap();
eprintln!("Roc hit a panic: {}", string);
std::process::exit(1);
eprintln!("Roc standard library hit a panic: {}", &*msg);
}
_ => todo!(),
1 => {
eprintln!("Application hit a panic: {}", &*msg);
}
_ => unreachable!(),
}
std::process::exit(1);
}
#[no_mangle]
pub unsafe extern "C" fn roc_dbg(loc: *mut RocStr, msg: *mut RocStr) {
eprintln!("[{}] {}", &*loc, &*msg);
}
#[no_mangle]