wasmtime_environ/
stack_map.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Serialize, Deserialize)]
9pub struct StackMap {
10 bits: Box<[u32]>,
11 mapped_words: u32,
12}
13
14impl StackMap {
15 pub fn new(mapped_words: u32, bits: impl Iterator<Item = u32>) -> StackMap {
18 StackMap {
19 bits: bits.collect(),
20 mapped_words,
21 }
22 }
23
24 pub fn get_bit(&self, bit_index: usize) -> bool {
26 assert!(bit_index < 32 * self.bits.len());
27 let word_index = bit_index / 32;
28 let word_offset = bit_index % 32;
29 (self.bits[word_index] & (1 << word_offset)) != 0
30 }
31
32 pub fn mapped_words(&self) -> u32 {
34 self.mapped_words
35 }
36}