diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..a9c1fed --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "waffle" +version = "0.0.1" +description = "Wasm Analysis Framework For Lightweight Experiments" +author = ["Chris Fallin "] +license = "Apache-2.0 WITH LLVM-exception" +edition = "2018" + +[dependencies] +wasmparser = "0.81" +wasm-encoder = "0.3" diff --git a/src/ir.rs b/src/ir.rs new file mode 100644 index 0000000..556b0e0 --- /dev/null +++ b/src/ir.rs @@ -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, + pub signatures: Vec, +} + +#[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, +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..01e38da --- /dev/null +++ b/src/lib.rs @@ -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;