Skip to main content

hydro_lang/compile/
compiled.rs

1use dfir_lang::graph::DfirGraph;
2use slotmap::{SecondaryMap, SparseSecondaryMap};
3use syn::Stmt;
4
5use crate::location::{Location, LocationKey};
6use crate::staging_util::Invariant;
7
8pub struct CompiledFlow<'a> {
9    /// The DFIR graph for each location.
10    pub(super) dfir: SecondaryMap<LocationKey, DfirGraph>,
11
12    /// Extra statements to be added above the DFIR graph code, for each location.
13    pub(super) extra_stmts: SparseSecondaryMap<LocationKey, Vec<Stmt>>,
14
15    /// `Future` expressions to be run alongside the DFIR graph execution, per-location. See [`crate::telemetry::Sidecar`].
16    pub(super) sidecars: SparseSecondaryMap<LocationKey, Vec<syn::Expr>>,
17
18    pub(super) _phantom: Invariant<'a>,
19}
20
21impl<'a> CompiledFlow<'a> {
22    pub fn dfir_for(&self, location: &impl Location<'a>) -> &DfirGraph {
23        self.dfir.get(Location::id(location).key()).unwrap()
24    }
25
26    pub fn all_dfir(&self) -> &SecondaryMap<LocationKey, DfirGraph> {
27        &self.dfir
28    }
29}