1
//! The homes of assigned binders (plan 0014 stage F2a): one per binder site,
2
//! typed like a global's home. A binder's local is allocated at the join of its
3
//! init and the fact, the stores of the previous attempt that did not fit.
4

            
5
use super::{Home, HomeKey, locked};
6
use crate::ast::{Expr, WasmType};
7
use crate::compiler::join::Arm;
8
use crate::runtime::SymbolTable;
9

            
10
impl SymbolTable {
11
    /// Opens the home of the binder `key` for the local this attempt allocated
12
    /// at `ty` from an `init` arm, a constant init keeping its `datum`; the
13
    /// first instance of the site decides it.
14
265362
    pub(crate) fn open_binder(&self, key: &HomeKey, init: Arm, datum: Option<Expr>, ty: WasmType) {
15
265362
        let mut book = locked(&self.homes);
16
265362
        let base: Vec<Arm> = std::iter::once(init)
17
265362
            .chain(book.hints.get(key).copied().map(Arm::Value))
18
265362
            .collect();
19
265362
        book.homes
20
265362
            .entry(key.clone())
21
219865
            .or_insert_with(|| Home::typed(base, datum, ty));
22
265362
    }
23
}