wasmer/lib/llvm-backend/src/read_info.rs

37 lines
1.2 KiB
Rust
Raw Normal View History

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