mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
wasm_interp: use Result instead of panic. Focus debug info on *Wasm app*, not interp.
This commit is contained in:
parent
284dc6fa51
commit
5bdd1b5628
5 changed files with 358 additions and 323 deletions
|
@ -7,7 +7,7 @@ pub mod wasi;
|
|||
// Main external interface
|
||||
pub use instance::Instance;
|
||||
|
||||
use roc_wasm_module::Value;
|
||||
use roc_wasm_module::{Value, ValueType};
|
||||
use value_stack::ValueStack;
|
||||
use wasi::WasiDispatcher;
|
||||
|
||||
|
@ -56,3 +56,21 @@ impl<'a> ImportDispatcher for DefaultImportDispatcher<'a> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub(crate) enum Error {
|
||||
ValueStackType(ValueType, ValueType),
|
||||
ValueStackEmpty,
|
||||
}
|
||||
|
||||
impl Error {
|
||||
fn value_stack_type(expected: ValueType, is_float: bool, is_64: bool) -> Self {
|
||||
let ty = match (is_float, is_64) {
|
||||
(false, false) => ValueType::I32,
|
||||
(false, true) => ValueType::I64,
|
||||
(true, false) => ValueType::F32,
|
||||
(true, true) => ValueType::F64,
|
||||
};
|
||||
Error::ValueStackType(expected, ty)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue