Lines
100 %
Functions
Branches
//! The homes of assigned binders (plan 0014 stage F2a): one per binder site,
//! typed like a global's home. A binder's local is allocated at the join of its
//! init and the fact, the stores of the previous attempt that did not fit.
use super::{Home, HomeKey, locked};
use crate::ast::{Expr, WasmType};
use crate::compiler::join::Arm;
use crate::runtime::SymbolTable;
impl SymbolTable {
/// Opens the home of the binder `key` for the local this attempt allocated
/// at `ty` from an `init` arm, a constant init keeping its `datum`; the
/// first instance of the site decides it.
pub(crate) fn open_binder(&self, key: &HomeKey, init: Arm, datum: Option<Expr>, ty: WasmType) {
let mut book = locked(&self.homes);
let base: Vec<Arm> = std::iter::once(init)
.chain(book.hints.get(key).copied().map(Arm::Value))
.collect();
book.homes
.entry(key.clone())
.or_insert_with(|| Home::typed(base, datum, ty));
}