cairo_lang_lowering/analysis/
mod.rs1pub mod backward;
7pub use backward::{BackAnalysis, DataflowBackAnalysis};
8
9pub mod core;
10pub use core::{DataflowAnalyzer, Direction, Edge, StatementLocation};
11
12pub mod equality_analysis;
13pub mod forward;
14pub use forward::ForwardDataflowAnalysis;
15
16#[cfg(test)]
17mod equality_analysis_test;
18#[cfg(test)]
19mod test;
20
21use crate::{Block, BlockId, MatchInfo, Statement, VarRemapping, VarUsage};
22
23#[allow(unused_variables)]
25pub trait Analyzer<'db, 'a> {
26 type Info: Clone;
27 fn visit_block_start(&mut self, info: &mut Self::Info, block_id: BlockId, block: &Block<'db>) {}
28 fn visit_stmt(
29 &mut self,
30 info: &mut Self::Info,
31 statement_location: StatementLocation,
32 stmt: &'a Statement<'db>,
33 ) {
34 }
35 fn visit_goto(
36 &mut self,
37 info: &mut Self::Info,
38 statement_location: StatementLocation,
39 target_block_id: BlockId,
40 remapping: &'a VarRemapping<'db>,
41 ) {
42 }
43 fn merge_match(
44 &mut self,
45 statement_location: StatementLocation,
46 match_info: &'a MatchInfo<'db>,
47 infos: impl Iterator<Item = Self::Info>,
48 ) -> Self::Info;
49 fn info_from_return(
50 &mut self,
51 statement_location: StatementLocation,
52 vars: &'a [VarUsage<'db>],
53 ) -> Self::Info;
54
55 fn info_from_panic(
58 &mut self,
59 statement_location: StatementLocation,
60 var: &VarUsage<'db>,
61 ) -> Self::Info {
62 unreachable!("Panics should have been stripped in the `lower_panics` phase.");
63 }
64}