Use types to distinguish between wasm function body indices and wasm function indices.

This commit is contained in:
Maddy
2018-08-02 01:29:47 +00:00
committed by Dan Gohman
parent f7e481d9ac
commit f5d46cabe7
12 changed files with 71 additions and 53 deletions

View File

@@ -3,8 +3,16 @@ use cranelift_codegen::ir;
use std::u32;
use wasmparser;
/// Index of a function (imported or defined) inside the WebAssembly module.
pub type FunctionIndex = usize;
/// Index type of a function (imported or defined) inside the WebAssembly module.
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct FuncIndex(u32);
entity_impl!(FuncIndex);
/// Index type of a defined function inside the WebAssembly module.
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct DefinedFuncIndex(u32);
entity_impl!(DefinedFuncIndex);
/// Index of a table (imported or defined) inside the WebAssembly module.
pub type TableIndex = usize;
/// Index of a global variable (imported or defined) inside the WebAssembly module.