mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +00:00
update zig and rust platforms to have correct roc_panic and roc_dbg
This commit is contained in:
parent
1f14aa84a2
commit
3e66254b25
43 changed files with 475 additions and 201 deletions
|
@ -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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue