plotnik_lib/ir/
effect.rs

1//! Effect operations for the query IR.
2//!
3//! Effects are recorded during transition execution and replayed
4//! during materialization to construct the output value.
5
6use super::ids::{DataFieldId, VariantTagId};
7
8/// Effect operation in the IR effect stream.
9///
10/// Effects are executed sequentially after a successful match.
11/// They manipulate a value stack to construct structured output.
12#[derive(Debug, Clone, Copy, PartialEq, Eq)]
13#[repr(C, u16)]
14pub enum EffectOp {
15    /// Store matched node as current value.
16    /// Only valid on transitions with Node/Anonymous/Wildcard matcher.
17    CaptureNode,
18
19    /// Clear current value (set to None).
20    /// Used on skip paths for optional captures.
21    ClearCurrent,
22
23    /// Push empty array onto stack.
24    StartArray,
25
26    /// Move current value into top array.
27    PushElement,
28
29    /// Pop array from stack into current.
30    EndArray,
31
32    /// Push empty object onto stack.
33    StartObject,
34
35    /// Pop object from stack into current.
36    EndObject,
37
38    /// Move current value into top object at field.
39    Field(DataFieldId),
40
41    /// Push variant container with tag onto stack.
42    StartVariant(VariantTagId),
43
44    /// Pop variant, wrap current, set as current.
45    EndVariant,
46
47    /// Replace current Node with its source text.
48    ToString,
49}