mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-01 10:52:18 +00:00
Dont remove stmt_error
This commit is contained in:
parent
ce5636d94f
commit
ea386bf0af
2 changed files with 25 additions and 4 deletions
|
@ -987,6 +987,27 @@ impl<'a> WasmBackend<'a> {
|
|||
self.stmt(rc_stmt);
|
||||
}
|
||||
|
||||
pub fn stmt_internal_error(&mut self, msg: &'a str) {
|
||||
let msg_sym = self.create_symbol("panic_str");
|
||||
let msg_storage = self.storage.allocate_var(
|
||||
self.env.layout_interner,
|
||||
Layout::Builtin(Builtin::Str),
|
||||
msg_sym,
|
||||
StoredVarKind::Variable,
|
||||
);
|
||||
|
||||
// Store the message as a RocStr on the stack
|
||||
let (local_id, offset) = match msg_storage {
|
||||
StoredValue::StackMemory { location, .. } => {
|
||||
location.local_and_offset(self.storage.stack_frame_pointer)
|
||||
}
|
||||
_ => internal_error!("String must always have stack memory"),
|
||||
};
|
||||
self.expr_string_literal(msg, local_id, offset);
|
||||
|
||||
self.stmt_crash(msg_sym, CrashTag::Roc);
|
||||
}
|
||||
|
||||
pub fn stmt_crash(&mut self, msg: Symbol, tag: CrashTag) {
|
||||
// load the pointer
|
||||
self.storage.load_symbols(&mut self.code_builder, &[msg]);
|
||||
|
|
|
@ -1362,7 +1362,7 @@ impl<'a> LowLevelCall<'a> {
|
|||
backend.code_builder.i32_const(i32::MIN);
|
||||
backend.code_builder.i32_eq();
|
||||
backend.code_builder.if_();
|
||||
backend.stmt_runtime_error(PANIC_MSG);
|
||||
backend.stmt_internal_error(PANIC_MSG);
|
||||
backend.code_builder.end();
|
||||
|
||||
// x
|
||||
|
@ -1388,7 +1388,7 @@ impl<'a> LowLevelCall<'a> {
|
|||
backend.code_builder.i64_const(i64::MIN);
|
||||
backend.code_builder.i64_eq();
|
||||
backend.code_builder.if_();
|
||||
backend.stmt_runtime_error(PANIC_MSG);
|
||||
backend.stmt_internal_error(PANIC_MSG);
|
||||
backend.code_builder.end();
|
||||
|
||||
// x
|
||||
|
@ -1422,7 +1422,7 @@ impl<'a> LowLevelCall<'a> {
|
|||
backend.code_builder.i32_const(i32::MIN);
|
||||
backend.code_builder.i32_eq();
|
||||
backend.code_builder.if_();
|
||||
backend.stmt_runtime_error(PANIC_MSG);
|
||||
backend.stmt_internal_error(PANIC_MSG);
|
||||
backend.code_builder.end();
|
||||
|
||||
backend.code_builder.i32_const(0);
|
||||
|
@ -1433,7 +1433,7 @@ impl<'a> LowLevelCall<'a> {
|
|||
backend.code_builder.i64_const(i64::MIN);
|
||||
backend.code_builder.i64_eq();
|
||||
backend.code_builder.if_();
|
||||
backend.stmt_runtime_error(PANIC_MSG);
|
||||
backend.stmt_internal_error(PANIC_MSG);
|
||||
backend.code_builder.end();
|
||||
|
||||
backend.code_builder.i64_const(0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue