vyre_libs/parsing/c/preprocess/gpu_pipeline/
conditional_events.rs1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum ConditionalEventKind {
6 Ifdef,
8 Ifndef,
10 If,
12 Elif,
14 Else,
16 Endif,
18}
19
20#[derive(Debug, Clone, Copy, PartialEq, Eq)]
22pub enum ConditionalEventResidency {
23 GpuResidentDirective,
25 GpuResidentTruth,
27 HostLiveMacroTable,
30 HostStackThreading,
32}
33
34#[derive(Debug, Clone, PartialEq, Eq)]
36pub struct ConditionalEvent {
37 pub file: std::path::PathBuf,
39 pub kind: ConditionalEventKind,
41 pub directive_row: u32,
43 pub directive_byte_offset: u32,
45 pub depth_before: u32,
47 pub depth_after: u32,
49 pub parent_active: bool,
51 pub truth: Option<bool>,
53 pub current_active: bool,
55 pub branch_taken: bool,
57 pub directive_residency: ConditionalEventResidency,
59 pub state_residency: ConditionalEventResidency,
61}
62
63#[allow(clippy::too_many_arguments)]
65pub(super) fn push_conditional_event(
66 events: &mut Vec<ConditionalEvent>,
67 file_path: &std::path::Path,
68 kind: ConditionalEventKind,
69 directive_row: usize,
70 directive_byte_offset: usize,
71 depth_before: usize,
72 depth_after: usize,
73 parent_active: bool,
74 truth: Option<bool>,
75 current_active: bool,
76 branch_taken: bool,
77 state_residency: ConditionalEventResidency,
78) -> Result<(), String> {
79 events.push(ConditionalEvent {
80 file: file_path.to_path_buf(),
81 kind,
82 directive_row: u32::try_from(directive_row).map_err(|_| {
83 "vyre-libs::gpu_pipeline: conditional directive row exceeds u32. Fix: shard preprocessing before conditional-event evidence export.".to_string()
84 })?,
85 directive_byte_offset: u32::try_from(directive_byte_offset).map_err(|_| {
86 "vyre-libs::gpu_pipeline: conditional directive byte offset exceeds u32. Fix: shard preprocessing before conditional-event evidence export.".to_string()
87 })?,
88 depth_before: u32::try_from(depth_before).map_err(|_| {
89 "vyre-libs::gpu_pipeline: conditional depth exceeds u32. Fix: reject pathological conditional nesting before evidence export.".to_string()
90 })?,
91 depth_after: u32::try_from(depth_after).map_err(|_| {
92 "vyre-libs::gpu_pipeline: conditional depth exceeds u32. Fix: reject pathological conditional nesting before evidence export.".to_string()
93 })?,
94 parent_active,
95 truth,
96 current_active,
97 branch_taken,
98 directive_residency: ConditionalEventResidency::GpuResidentDirective,
99 state_residency,
100 });
101 Ok(())
102}