Skeleton of IR.

This commit is contained in:
Chris Fallin 2021-11-12 22:16:54 -08:00
parent d9eeaaa819
commit 6bb4f42f6d
3 changed files with 44 additions and 0 deletions

11
Cargo.toml Normal file
View file

@ -0,0 +1,11 @@
[package]
name = "waffle"
version = "0.0.1"
description = "Wasm Analysis Framework For Lightweight Experiments"
author = ["Chris Fallin <chris@cfallin.org>"]
license = "Apache-2.0 WITH LLVM-exception"
edition = "2018"
[dependencies]
wasmparser = "0.81"
wasm-encoder = "0.3"

25
src/ir.rs Normal file
View file

@ -0,0 +1,25 @@
//! Intermediate representation for Wasm.
use wasmparser::{FuncType, Type};
pub type SignatureId = usize;
pub type FuncId = usize;
#[derive(Clone, Debug)]
pub struct Module {
pub funcs: Vec<FuncDecl>,
pub signatures: Vec<FuncType>,
}
#[derive(Clone, Debug)]
pub enum FuncDecl {
Import(SignatureId),
Body(SignatureId, Function),
}
#[derive(Clone, Debug)]
pub struct Function {
pub id: FuncId,
pub signature: SignatureId,
pub locals: Vec<Type>,
}

8
src/lib.rs Normal file
View file

@ -0,0 +1,8 @@
//! WAFFLE Wasm analysis framework.
// Re-export wasmparser and wasmencoder for easier use of the right
// version by our embedders.
pub use wasmparser;
pub use wasm_encoder;
pub mod ir;