wasm/core/
indices.rs

1// /// This macro defines index types. Currently (2024-06-10) all indices are [`u32`].
2// /// See <https://webassembly.github.io/spec/core/binary/modules.html#indices> for more information.
3// macro_rules! def_idx_types {
4//     ($($name:ident),*) => {
5//         $(
6//             /// <https://webassembly.github.io/spec/core/binary/modules.html#indices>
7//             pub type $name = usize;
8//         )*
9//     };
10// }
11
12// // #[allow(dead_code)]
13// def_idx_types!(TypeIdx, FuncIdx, TableIdx, MemIdx, GlobalIdx, /* ElemIdx, DataIdx, */ LocalIdx/* , LabelIdx */);
14
15// TODO check whether is is clever to internally use usize instead of u32; potential problems are:
16// - unsound on architectures where `usize` < `u32`
17// - wasteful in memory on architectures where `usize` > `u32`
18pub type TypeIdx = usize;
19pub type FuncIdx = usize;
20pub type TableIdx = usize;
21pub type MemIdx = usize;
22pub type GlobalIdx = usize;
23#[allow(dead_code)]
24pub type ElemIdx = usize;
25pub type DataIdx = usize;
26pub type LocalIdx = usize;
27#[allow(dead_code)]
28pub type LabelIdx = usize;