Remove some dead code in the cranelift-wasm crate (#5290)
* Remove some dead code in the cranelift-wasm crate * Remove some more dead code
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
use crate::{SignatureIndex, WasmError, WasmResult};
|
||||
use cranelift_codegen::ir::{types, Type};
|
||||
use crate::SignatureIndex;
|
||||
use cranelift_entity::PrimaryMap;
|
||||
use std::boxed::Box;
|
||||
use std::vec::Vec;
|
||||
|
||||
/// Map of signatures to a function's parameter and return types.
|
||||
pub(crate) type WasmTypes =
|
||||
@@ -23,22 +21,6 @@ pub struct ModuleTranslationState {
|
||||
pub(crate) wasm_types: WasmTypes,
|
||||
}
|
||||
|
||||
fn cranelift_to_wasmparser_type(ty: Type) -> WasmResult<wasmparser::ValType> {
|
||||
Ok(match ty {
|
||||
types::I32 => wasmparser::ValType::I32,
|
||||
types::I64 => wasmparser::ValType::I64,
|
||||
types::F32 => wasmparser::ValType::F32,
|
||||
types::F64 => wasmparser::ValType::F64,
|
||||
types::R32 | types::R64 => wasmparser::ValType::ExternRef,
|
||||
_ => {
|
||||
return Err(WasmError::Unsupported(format!(
|
||||
"Cannot convert Cranelift type to Wasm signature: {:?}",
|
||||
ty
|
||||
)));
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
impl ModuleTranslationState {
|
||||
/// Creates a new empty ModuleTranslationState.
|
||||
pub fn new() -> Self {
|
||||
@@ -46,24 +28,4 @@ impl ModuleTranslationState {
|
||||
wasm_types: PrimaryMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new ModuleTranslationState with the given function signatures,
|
||||
/// provided in terms of Cranelift types. The provided slice of signatures
|
||||
/// is indexed by signature number, and contains pairs of (args, results)
|
||||
/// slices.
|
||||
pub fn from_func_sigs(sigs: &[(&[Type], &[Type])]) -> WasmResult<Self> {
|
||||
let mut wasm_types = PrimaryMap::with_capacity(sigs.len());
|
||||
for &(ref args, ref results) in sigs {
|
||||
let args: Vec<wasmparser::ValType> = args
|
||||
.iter()
|
||||
.map(|&ty| cranelift_to_wasmparser_type(ty))
|
||||
.collect::<Result<_, _>>()?;
|
||||
let results: Vec<wasmparser::ValType> = results
|
||||
.iter()
|
||||
.map(|&ty| cranelift_to_wasmparser_type(ty))
|
||||
.collect::<Result<_, _>>()?;
|
||||
wasm_types.push((args.into_boxed_slice(), results.into_boxed_slice()));
|
||||
}
|
||||
Ok(Self { wasm_types })
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user