Skip to main content

fic/
middle.rs

1//! The middle end ([`middle`]): the typed AST lowered to every program's
2//! graphs, and the checks and passes over them. The backends read what it
3//! returns.
4
5use anyhow::Result;
6
7use crate::ccfg::{build, System};
8use crate::error::Diagnostics;
9use crate::tast::Tast;
10use crate::wfcheck::{check_graphs, check_protected};
11
12/// Every program's graphs, with the notified ones checked.
13///
14/// # Errors
15///
16/// A program that does not bind both Microkit entry points (the front end
17/// rejects it first); a `Sync` channel received outside a run-to-completion
18/// `protected` head.
19pub fn middle(tast: &Tast) -> Result<System> {
20    let system = build(tast)?;
21    check_protected(tast, &system)?;
22    Diagnostics::warn(check_graphs(tast, &system));
23    eprintln!("  \u{2713} Built the graphs and checked them (notified: receive-headed, receives at the head only; notified and protected: guarded choices)");
24    Ok(system)
25}