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