1
0
mirror of https://github.com/fluencelabs/wasmer synced 2025-04-02 16:01:03 +00:00

32 lines
1022 B
Rust
Raw Normal View History

2019-05-06 23:41:31 -05:00
use wasmer_runtime_core::types::Type;
2019-07-01 16:11:38 -07:00
use wasmparser::{BinaryReaderError, Type as WpType, TypeOrFuncType as WpTypeOrFuncType};
2019-02-09 15:53:40 -08:00
pub fn type_to_type(ty: WpType) -> Result<Type, BinaryReaderError> {
Ok(match ty {
WpType::I32 => Type::I32,
WpType::I64 => Type::I64,
WpType::F32 => Type::F32,
WpType::F64 => Type::F64,
WpType::V128 => Type::V128,
_ => {
return Err(BinaryReaderError {
message: "that type is not supported as a wasmer type",
offset: -1isize as usize,
});
}
2019-02-09 15:53:40 -08:00
})
}
2019-07-01 16:11:38 -07:00
pub fn blocktype_to_type(ty: WpTypeOrFuncType) -> Result<Type, BinaryReaderError> {
match ty {
2019-07-01 16:15:13 -07:00
WpTypeOrFuncType::Type(inner_ty) => type_to_type(inner_ty),
2019-07-01 16:11:38 -07:00
_ => {
return Err(BinaryReaderError {
2019-07-01 16:15:13 -07:00
message:
"the wasmer llvm backend does not yet support the multi-value return extension",
2019-07-01 16:11:38 -07:00
offset: -1isize as usize,
});
}
}
}