Store WasmFuncType in FuncType (#2365)
This commit updates `wasmtime::FuncType` to exactly store an internal `WasmFuncType` from the cranelift crates. This allows us to remove a translation layer when we are given a `FuncType` and want to get an internal cranelift type out as a result. The other major change from this commit was changing the constructor and accessors of `FuncType` to be iterator-based instead of exposing implementation details.
This commit is contained in:
@@ -54,17 +54,9 @@ pub extern "C" fn wasm_functype_new(
|
||||
params: &mut wasm_valtype_vec_t,
|
||||
results: &mut wasm_valtype_vec_t,
|
||||
) -> Box<wasm_functype_t> {
|
||||
let params = params
|
||||
.take()
|
||||
.into_iter()
|
||||
.map(|vt| vt.unwrap().ty.clone())
|
||||
.collect::<Vec<_>>();
|
||||
let results = results
|
||||
.take()
|
||||
.into_iter()
|
||||
.map(|vt| vt.unwrap().ty.clone())
|
||||
.collect::<Vec<_>>();
|
||||
let functype = FuncType::new(params.into_boxed_slice(), results.into_boxed_slice());
|
||||
let params = params.take().into_iter().map(|vt| vt.unwrap().ty.clone());
|
||||
let results = results.take().into_iter().map(|vt| vt.unwrap().ty.clone());
|
||||
let functype = FuncType::new(params, results);
|
||||
Box::new(wasm_functype_t::new(functype))
|
||||
}
|
||||
|
||||
@@ -74,7 +66,6 @@ pub extern "C" fn wasm_functype_params(ft: &wasm_functype_t) -> &wasm_valtype_ve
|
||||
ft.params_cache.get_or_init(|| {
|
||||
ft.ty
|
||||
.params()
|
||||
.iter()
|
||||
.map(|p| Some(Box::new(wasm_valtype_t { ty: p.clone() })))
|
||||
.collect::<Vec<_>>()
|
||||
.into()
|
||||
@@ -87,7 +78,6 @@ pub extern "C" fn wasm_functype_results(ft: &wasm_functype_t) -> &wasm_valtype_v
|
||||
ft.returns_cache.get_or_init(|| {
|
||||
ft.ty
|
||||
.results()
|
||||
.iter()
|
||||
.map(|p| Some(Box::new(wasm_valtype_t { ty: p.clone() })))
|
||||
.collect::<Vec<_>>()
|
||||
.into()
|
||||
|
||||
Reference in New Issue
Block a user