//! Intermediate representation for Wasm. use wasmparser::{FuncType, Operator, Type}; pub type SignatureId = usize; pub type FuncId = usize; pub type BlockId = usize; pub type InstId = usize; pub type ValueId = usize; #[derive(Clone, Debug, Default)] pub struct Module { pub funcs: Vec, pub signatures: Vec, } #[derive(Clone, Debug)] pub enum FuncDecl { Import(SignatureId), Body(SignatureId, FunctionBody), } #[derive(Clone, Debug, Default)] pub struct FunctionBody { pub locals: Vec, pub blocks: Vec, pub values: Vec, } #[derive(Clone, Debug)] pub struct ValueDef { pub kind: ValueKind, pub ty: Type, } #[derive(Clone, Debug)] pub enum ValueKind { BlockParam(Block), Inst(Block, Inst), } #[derive(Clone, Debug, Default)] pub struct Block { pub params: Vec, pub insts: Vec, } #[derive(Clone, Debug)] pub struct Inst { pub operator: Operator<'static>, pub outputs: Vec, pub inputs: Vec, } #[derive(Clone, Debug)] pub enum Operand { Value(ValueId), Sub(Box), }