neo_solidity/solidity/analyse/modifiers/
apply.rs

1fn apply_modifiers_and_base_constructors(
2    contract: &mut ContractIR,
3    contract_map: &std::collections::HashMap<String, ContractIR>,
4) -> Result<(), SolidityError> {
5    let contract_snapshot = contract.clone();
6    let modifier_defs = build_modifier_definition_map(contract);
7
8    for func in contract.functions.iter_mut() {
9        let Some(body) = func.body.clone() else {
10            continue;
11        };
12
13        if matches!(func.ty, FunctionTy::Modifier) {
14            continue;
15        }
16
17        if matches!(func.ty, FunctionTy::Constructor) {
18            let constructor_snapshot = func.clone();
19            func.body = Some(apply_base_constructors_and_modifiers(
20                &contract_snapshot,
21                &constructor_snapshot,
22                &modifier_defs,
23                contract_map,
24            )?);
25            func.base_or_modifiers.clear();
26            continue;
27        }
28
29        if func.base_or_modifiers.is_empty() {
30            continue;
31        }
32
33        func.body = Some(apply_modifier_calls_to_body(
34            &body,
35            &func.base_or_modifiers,
36            &modifier_defs,
37        )?);
38        func.base_or_modifiers.clear();
39    }
40
41    Ok(())
42}
43