Skip to main content

rapx/vm/
mir_rules.rs

1use rustc_middle::mir::{BasicBlock, Place, Rvalue, Statement, Terminator};
2
3use super::state::{VmExecutor, VmValue};
4
5#[must_use]
6#[derive(Clone, Copy, PartialEq, Eq)]
7pub(crate) enum RuleFlow {
8    Continue,
9    Pruned,
10}
11
12impl RuleFlow {
13    pub(crate) fn continues(self) -> bool {
14        self == Self::Continue
15    }
16}
17
18mod call;
19mod dispatch;
20mod rvalue;
21mod statement;
22mod terminator;
23
24pub(crate) use terminator::forced_inline_switch_target;
25
26pub(crate) fn eval_rvalue<'z3, 'tcx>(
27    state: &mut VmExecutor<'z3, 'tcx>,
28    place: &Place<'tcx>,
29    rvalue: &Rvalue<'tcx>,
30) -> VmValue<'z3, 'tcx> {
31    dispatch::eval_rvalue(state, place, rvalue)
32}
33
34/// Execute a terminator and report whether the selected successor remains possible.
35pub(crate) fn exec_terminator<'z3, 'tcx>(
36    state: &mut VmExecutor<'z3, 'tcx>,
37    terminator: &Terminator<'tcx>,
38    switch_succ: Option<BasicBlock>,
39) -> RuleFlow {
40    dispatch::exec_terminator(state, terminator, switch_succ)
41}
42
43pub(crate) fn exec_statement<'z3, 'tcx>(
44    state: &mut VmExecutor<'z3, 'tcx>,
45    statement: &Statement<'tcx>,
46) {
47    dispatch::exec_statement(state, statement);
48}
49
50pub(crate) fn exec_contract_method_statement<'z3, 'tcx>(
51    state: &mut VmExecutor<'z3, 'tcx>,
52    statement: &Statement<'tcx>,
53) {
54    dispatch::exec_statement(state, statement);
55    statement::refine_contract_method_const(state, statement);
56}