2021-11-13 00:16:54 -06:00
|
|
|
//! Intermediate representation for Wasm.
|
|
|
|
|
|
|
|
use wasmparser::{FuncType, Type};
|
|
|
|
|
|
|
|
pub type SignatureId = usize;
|
|
|
|
pub type FuncId = usize;
|
2021-11-13 02:20:02 -06:00
|
|
|
pub type BlockId = usize;
|
|
|
|
pub type InstId = usize;
|
2021-11-13 00:16:54 -06:00
|
|
|
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
pub struct Module {
|
|
|
|
pub funcs: Vec<FuncDecl>,
|
|
|
|
pub signatures: Vec<FuncType>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
pub enum FuncDecl {
|
|
|
|
Import(SignatureId),
|
2021-11-13 02:20:02 -06:00
|
|
|
Body(SignatureId, FunctionBody),
|
2021-11-13 00:16:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug)]
|
2021-11-13 02:20:02 -06:00
|
|
|
pub struct FunctionBody {
|
2021-11-13 00:16:54 -06:00
|
|
|
pub locals: Vec<Type>,
|
2021-11-13 02:20:02 -06:00
|
|
|
pub blocks: Vec<Block>,
|
2021-11-13 00:16:54 -06:00
|
|
|
}
|