This commit is contained in:
Chris Fallin 2021-11-13 00:59:15 -08:00
parent 44c2c8dc17
commit 3ca0886fbb

View file

@ -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<Module> {
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));
}
_ => {}
}
}
}
_ => {}
}