cairo_lang_lowering::optimizations::gas_redeposit

Function gas_redeposit

source
pub fn gas_redeposit(
    db: &dyn LoweringGroup,
    function_id: ConcreteFunctionWithBodyId,
    lowered: &mut FlatLowered,
)
Expand description

Adds redeposit gas actions.

The algorithm is as follows: Check if the function will have the GasBuiltin implicit after the lower_implicits stage. If so, add a redeposit_gas call at the beginning of every branch in the code. Otherwise, do nothing.

Note that for implementation simplicity this stage must be applied before LowerImplicits stage.