mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
wasm_interp: Don't panic while pushing a stack frame
This commit is contained in:
parent
4cf5d19ace
commit
2abae1b5e1
4 changed files with 127 additions and 89 deletions
|
@ -67,6 +67,29 @@ pub(crate) enum Error {
|
|||
}
|
||||
|
||||
impl Error {
|
||||
pub fn to_string_at(&self, file_offset: usize) -> String {
|
||||
match self {
|
||||
Error::ValueStackType(expected, actual) => {
|
||||
format!(
|
||||
"ERROR: I found a type mismatch in the Value Stack at file offset {:#x}. Expected {:?}, but found {:?}.\n",
|
||||
file_offset, expected, actual
|
||||
)
|
||||
}
|
||||
Error::ValueStackEmpty => {
|
||||
format!(
|
||||
"ERROR: I tried to pop a value from the Value Stack at file offset {:#x}, but it was empty.\n",
|
||||
file_offset
|
||||
)
|
||||
}
|
||||
Error::UnreachableOp => {
|
||||
format!(
|
||||
"WebAssembly `unreachable` instruction at file offset {:#x}.\n",
|
||||
file_offset
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn value_stack_type(expected: ValueType, is_float: bool, is_64: bool) -> Self {
|
||||
let ty = type_from_flags_f_64(is_float, is_64);
|
||||
Error::ValueStackType(expected, ty)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue