Minor changes for components related to wit-bindgen support (#5053)
* Plumb type exports in components around more This commit adds some more plumbing for type exports to ensure that they show up in the final compiled representation of a component. For now they continued to be ignored for all purposes in the embedding API itself but I found this useful to explore in `wit-bindgen` based tooling which is leveraging the component parsing in Wasmtime. * Add a field to `ModuleTranslation` to store the original wasm This commit adds a field to be able to refer back to the original wasm binary for a `ModuleTranslation`. This field is used in the upcoming support for host generation in `wit-component` to "decompile" a component into core wasm modules to get instantiated. This is used to extract a core wasm module from the original component. * FIx a build warning
This commit is contained in:
@@ -40,6 +40,13 @@ pub struct ModuleTranslation<'data> {
|
||||
/// Module information.
|
||||
pub module: Module,
|
||||
|
||||
/// The input wasm binary.
|
||||
///
|
||||
/// This can be useful, for example, when modules are parsed from a
|
||||
/// component and the embedder wants access to the raw wasm modules
|
||||
/// themselves.
|
||||
pub wasm: &'data [u8],
|
||||
|
||||
/// References to the function bodies.
|
||||
pub function_body_inputs: PrimaryMap<DefinedFuncIndex, FunctionBodyData<'data>>,
|
||||
|
||||
@@ -162,6 +169,8 @@ impl<'a, 'data> ModuleEnvironment<'a, 'data> {
|
||||
parser: Parser,
|
||||
data: &'data [u8],
|
||||
) -> WasmResult<ModuleTranslation<'data>> {
|
||||
self.result.wasm = data;
|
||||
|
||||
for payload in parser.parse_all(data) {
|
||||
self.translate_payload(payload?)?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user