use crate::{
CompiledModuleInfo, FunctionLoc, PrimaryMap, StaticModuleIndex,
component::{Component, ComponentTypes, TrampolineIndex, TypeComponentIndex},
};
use serde_derive::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct ComponentArtifacts {
pub ty: TypeComponentIndex,
pub info: CompiledComponentInfo,
pub types: ComponentTypes,
pub static_modules: PrimaryMap<StaticModuleIndex, CompiledModuleInfo>,
}
#[derive(Serialize, Deserialize)]
pub struct CompiledComponentInfo {
pub component: Component,
pub trampolines: PrimaryMap<TrampolineIndex, AllCallFunc<FunctionLoc>>,
pub resource_drop_wasm_to_array_trampoline: Option<FunctionLoc>,
}
#[derive(Clone, Copy, Default, Serialize, Deserialize)]
pub struct AllCallFunc<T> {
pub wasm_call: T,
pub array_call: T,
}
impl<T> AllCallFunc<T> {
pub fn map<U>(self, mut f: impl FnMut(T) -> U) -> AllCallFunc<U> {
AllCallFunc {
wasm_call: f(self.wasm_call),
array_call: f(self.array_call),
}
}
}