Skip to main content

lower_commit_shape_ir

Function lower_commit_shape_ir 

Source
pub fn lower_commit_shape_ir(
    body: &Block,
    invariants: &[IrPredicate],
    transitions: &[IrPredicate],
    emits: bool,
    program: &CheckedProgram,
) -> CommitShape
Expand description

P6.8 ([DECISION B]/[DECISION D]/[DECISION F], #1165): decide a handler body’s own one-of-three CommitShape from resolved data — body_writes_state’s own write-detection walk, plus emits ([DECISION D]: the caller’s own bynk_emit::emitter::block_uses_emit(body) call, not re-derived here — no Callee classification exists for Events.emit to consume instead, see that decision’s own grounding). Does not lower body into an IrExpr tree first ([DECISION B]) — deciding the shape only needs the two booleans, and lowering the whole body just to throw the result away would be pure waste; a real IrHandler.body lowering is a separate, not-yet-commissioned step (see bynk_ir::IrItem’s own doc comment).

Shape-agnostic between an agent and a service handler ([DECISION F]) — no is_store_agent flag: a service handler’s own call site simply passes empty invariants/transitions slices (a service has no store block to declare them against), and body_writes_state naturally finds neither a mutating Callee::Store nor a bare := in a service body (no store fields to write), so Transactional is never constructed for one — matching the shipped emitter’s own emit_service, which already only ever produces the other two shapes.