From 3ca0886fbb27cdb7b5116c081a5c038c29bb561c Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Sat, 13 Nov 2021 00:59:15 -0800 Subject: [PATCH] WIP. --- src/frontend.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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)); + } + _ => {} + } + } + } _ => {} }