Skip to main content

wowlab_engine_domain/rotation/lower/action/
lists.rs

1use wowlab_types::sim::Condition;
2
3use super::{
4    super::super::backend::RotationBackend, LowerCtx, failing_condition, lower_actions,
5    lower_optional_guard,
6};
7
8pub(super) fn lower_call<B>(
9    ctx: &mut LowerCtx<'_, '_, '_, B>,
10    list: &str,
11    condition: Option<&Condition>,
12) where
13    B: RotationBackend,
14{
15    let guard = lower_optional_guard(ctx.lo, ctx.b, condition);
16
17    ctx.b.record_action_guarded(
18        ctx.action.list_id,
19        ctx.action.action_index,
20        ctx.action.action,
21        ctx.action.is_term,
22        guard.bool_val,
23        failing_condition(condition),
24    );
25
26    if let Some(list_actions) = ctx.lo.lists.get(list).cloned() {
27        lower_actions(ctx.lo, ctx.b, list, &list_actions);
28    }
29}
30
31pub(super) fn lower_run<B>(
32    ctx: &mut LowerCtx<'_, '_, '_, B>,
33    list: &str,
34    condition: Option<&Condition>,
35) where
36    B: RotationBackend,
37{
38    let guard = lower_optional_guard(ctx.lo, ctx.b, condition);
39
40    ctx.b.record_action_guarded(
41        ctx.action.list_id,
42        ctx.action.action_index,
43        ctx.action.action,
44        ctx.action.is_term,
45        guard.bool_val,
46        failing_condition(condition),
47    );
48
49    if let Some(list_actions) = ctx.lo.lists.get(list).cloned() {
50        ctx.lo.run_depth += 1;
51        let saved_terminator = ctx.lo.unconditionally_returned;
52
53        ctx.lo.unconditionally_returned = false;
54        lower_actions(ctx.lo, ctx.b, list, &list_actions);
55        ctx.lo.unconditionally_returned = saved_terminator;
56        ctx.lo.run_depth -= 1;
57    }
58}