Skip to main content

vyre_libs/parsing/c/preprocess/gpu_pipeline/
preprocessed_source.rs

1//! The preprocessor driver's output value and the macro table it carries.
2
3use super::{
4    ConditionalEvent, HeaderReuseEvent, IncludeAccelerationEvent, IncludeByteCacheStats,
5    IncludeEvent, MacroEvent, MacroExpansionEvent, TokenProvenanceEvent,
6};
7
8/// Output of the driver.
9#[derive(Debug, Clone, PartialEq, Eq)]
10pub struct PreprocessedSource {
11    /// Concatenated active bytes  -  line-spliced, comment-stripped,
12    /// conditional-masked, include-expanded. Macro expansion is
13    /// deliberately NOT performed here (mirrors the v0.4
14    /// `prepare_resident_translation_unit_source` contract).
15    pub bytes: Vec<u8>,
16    /// Macros accumulated during the walk (CLI macros + every
17    /// `#define` in active branches). Downstream macro-expansion
18    /// kernels consume this.
19    pub macros: Vec<MacroDef>,
20    /// Include graph events whose requests were extracted by GPU directive
21    /// payload kernels. Resolution/read remains host filesystem metadata.
22    pub include_events: Vec<IncludeEvent>,
23    /// Per-run include byte-cache counters for loader avoidance evidence.
24    pub include_byte_cache_stats: IncludeByteCacheStats,
25    /// Conditional stack events whose directive payloads are GPU-derived.
26    pub conditional_events: Vec<ConditionalEvent>,
27    /// Macro definition-table events whose directive payloads are GPU-derived.
28    pub macro_events: Vec<MacroEvent>,
29    /// Macro expansion origin events.
30    pub macro_expansion_events: Vec<MacroExpansionEvent>,
31    /// Token-level spelling and expansion provenance for the preprocessed output.
32    pub token_provenance_events: Vec<TokenProvenanceEvent>,
33    /// Include guard / pragma-once acceleration evidence.
34    pub include_acceleration_events: Vec<IncludeAccelerationEvent>,
35    /// Header-analysis cache reuse evidence.
36    pub header_reuse_events: Vec<HeaderReuseEvent>,
37}
38
39/// A `#define`'d macro encountered during preprocessing.
40#[derive(Debug, Clone, PartialEq, Eq)]
41pub struct MacroDef {
42    /// Macro identifier bytes.
43    pub name: Vec<u8>,
44    /// Comma-separated argument-list bytes for function-like macros;
45    /// empty for object-like.
46    pub args: Vec<u8>,
47    /// Replacement body bytes.
48    pub body: Vec<u8>,
49    /// `true` for function-like (`#define M(a) …`).
50    pub is_function_like: bool,
51}