1#![no_std]
2extern crate alloc;
3use alloc::{
4 collections::{BTreeMap, BTreeSet}, vec::Vec,
5
6};
7
8use anyhow::Context;
9use pit_core::{Arg, Interface, Sig};
10use portal_pc_waffle::{
12 util::new_sig, ExportKind, FuncDecl, FunctionBody, ImportKind, Module, SignatureData,
13 TableData, Type,
14};
15use crate::util::add_op;
16
17pub mod util;
18pub mod canon;
19pub mod lower;
20pub mod tpit;
21pub mod tutils;
22pub fn get_interfaces(m: &Module) -> anyhow::Result<Vec<Interface>> {
23 let c = m
24 .custom_sections
25 .get(".pit-types")
26 .context("in getting type section")?;
27 let mut is = alloc::vec![];
28 for b in c.split(|a| *a == 0) {
29 let s = core::str::from_utf8(b)?;
30 let (s, i) = pit_core::parse_interface(s)
31 .map_err(|e: nom::Err<nom::error::Error<&str>>| anyhow::anyhow!("invalid pit"))?;
32 is.push(i);
33 }
34
35 return Ok(is);
36}