1
//! What a unit that rebinds a special keeps so a host can tell, after a trap,
2
//! which value the global holds outside every binding (plan 0014 PERSIST P11).
3

            
4
use super::homes::locked;
5
use super::table::SymbolTable;
6

            
7
/// Exported i32 `depth` counts the dynamic bindings of a special in force;
8
/// entering the outermost one stores the special's value in `outer` and its
9
/// bound flag in `outer_bound`.
10
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
11
pub struct Rebind {
12
    pub depth: u32,
13
    pub outer: u32,
14
    pub outer_bound: u32,
15
}
16

            
17
impl SymbolTable {
18
    /// The rebind globals of the special held in global `global`.
19
19848
    pub(crate) fn rebind_of(&self, global: u32) -> Option<Rebind> {
20
19848
        locked(&self.homes).rebinds.get(&global).copied()
21
19848
    }
22

            
23
18407
    pub(crate) fn note_rebind(&self, global: u32, rebind: Rebind) {
24
18407
        locked(&self.homes).rebinds.insert(global, rebind);
25
18407
    }
26
}