diff --git a/src/frontend.rs b/src/frontend.rs index 86dec60..b5f1790 100644 --- a/src/frontend.rs +++ b/src/frontend.rs @@ -3,7 +3,7 @@ use crate::ir::*; use anyhow::Result; use log::trace; -use wasmparser::{Parser, Payload, TypeDef}; +use wasmparser::{ImportSectionEntryType, Parser, Payload, TypeDef}; pub fn wasm_to_ir(bytes: &[u8]) -> Result { let mut module = Module::default(); @@ -30,6 +30,16 @@ fn handle_payload<'a>(module: &mut Module, payload: Payload<'a>) -> Result<()> { } } } + Payload::ImportSection(mut reader) => { + for _ in 0..reader.get_count() { + match reader.read()?.ty { + ImportSectionEntryType::Function(sig_idx) => { + module.funcs.push(FuncDecl::Import(sig_idx as SignatureId)); + } + _ => {} + } + } + } _ => {} }