1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//! Tables.

use ir::immediates::Imm64;
use ir::GlobalValue;
use std::fmt;

/// Information about a table declaration.
#[derive(Clone)]
pub struct TableData {
    /// Global value giving the address of the start of the table.
    pub base_gv: GlobalValue,

    /// Guaranteed minimum table size in elements. Table accesses before `min_size` don't need
    /// bounds checking.
    pub min_size: Imm64,

    /// Global value giving the current bound of the table, in elements.
    pub bound_gv: GlobalValue,

    /// The size of a table element, in bytes.
    pub element_size: Imm64,
}

impl fmt::Display for TableData {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "{}, min {}, bound {}, element_size {}",
            self.base_gv, self.min_size, self.bound_gv, self.element_size
        )
    }
}