mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Implement crash in gen-wasm
This commit is contained in:
parent
a8122662c2
commit
32400e37e1
4 changed files with 32 additions and 14 deletions
|
@ -718,7 +718,7 @@ impl<'a> WasmBackend<'a> {
|
|||
Stmt::ExpectFx { .. } => todo!("expect-fx is not implemented in the wasm backend"),
|
||||
|
||||
Stmt::RuntimeError(msg) => self.stmt_runtime_error(msg),
|
||||
Stmt::Crash(_, _) => todo!(),
|
||||
Stmt::Crash(sym, _) => self.stmt_crash(*sym),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1016,6 +1016,16 @@ impl<'a> WasmBackend<'a> {
|
|||
self.code_builder.unreachable_();
|
||||
}
|
||||
|
||||
pub fn stmt_crash(&mut self, msg: Symbol) {
|
||||
let tag_id = 1;
|
||||
// load the pointer
|
||||
self.storage.load_symbols(&mut self.code_builder, &[msg]);
|
||||
self.code_builder.i32_const(tag_id);
|
||||
self.call_host_fn_after_loading_args("roc_panic", 2, false);
|
||||
|
||||
self.code_builder.unreachable_();
|
||||
}
|
||||
|
||||
/**********************************************************
|
||||
|
||||
EXPRESSIONS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue