syn_sem/semantic/entry/
mod.rs1pub(crate) mod context;
2
3pub use context::{Config, ConfigLoad, GlobalCx};
4
5use crate::{
6 semantic::analyze::{Analyzer, Semantics},
7 Result,
8};
9use std::mem;
10
11#[derive(Debug, Default)]
12pub struct AnalysisSession<'gcx> {
13 gcx: GlobalCx<'gcx>,
14}
15
16impl<'gcx> AnalysisSession<'gcx> {
17 pub fn run<F>(self, f: F) -> Result<Analyzed<'gcx>>
18 where
19 F: FnOnce(Analyzer<'gcx>) -> Result<Semantics<'gcx>>,
20 {
21 let gcx: &'gcx GlobalCx<'gcx> = unsafe { mem::transmute(&self.gcx) };
23
24 let analyzer = Analyzer::new(gcx);
25 let sem = f(analyzer)?;
26 Ok(Analyzed { gcx: self.gcx, sem })
27 }
28}
29
30#[derive(Debug)]
31pub struct Analyzed<'gcx> {
32 pub gcx: GlobalCx<'gcx>,
33 pub sem: Semantics<'gcx>,
34}