Expand description
Event logging for the SSA optimization pipeline.
Passes record events through an EventListener<T>; hosts that don’t care
pass NullListener to opt out without changing the call site. Hosts that
do care use EventLog<T>, a thread-safe append-only collection that
itself impls EventListener<T>.
§Architecture
EventKind— non-generic enum of event categories.Event<T>— a recorded event, parameterized over the host’sT::MethodRefso each event can name the method it occurred in.EventListener<T>— sink trait;pushaccepts a fully-formed event. The defaultrecordmethod returns anEventBuilderfor the fluentevents.record(kind).at(...).message(...)API.NullListener— discards every event. Useful when running passes without observation (unit tests, CI, callers that don’t need an event trace).EventLog<T>— concrete listener storing events for later inspection, summary, and filtering.
§Example (analyssa-side, MockTarget)
use analyssa::{events::{EventKind, EventLog, EventListener}, MockTarget};
let log: EventLog<MockTarget> = EventLog::new();
let method: u32 = 0x06000001;
log.record(EventKind::ConstantFolded)
.at(method, 0x42)
.message("42 + 0 = 42");
assert!(log.has(EventKind::ConstantFolded));Structs§
- Derived
Stats - Statistics derived from an
EventLog. Counts are byEventKindand independent ofT, so this struct is not generic. - Event
- A single logged event.
- Event
Builder - Builder for creating events with a fluent API. Created via
EventListener::record. The event is automatically appended to the owning listener when the builder is dropped. - Event
Log - Concrete event sink storing events for later inspection, summary, and
filtering. Thread-safe append: events can be recorded concurrently from
multiple threads using shared references (
&self) thanks toboxcar::Vec. - Event
LogIter - Iterator wrapper for
EventLogthat yields&Event<T>. - Null
Listener - No-op listener: every event is silently discarded.
Enums§
- Event
Kind - Categories of events that can be logged. Target-agnostic — labels are purely descriptive and carry no host types.
Traits§
- Event
Listener - Sink for events recorded by passes. The
pushmethod accepts a fully-formed event; the defaultrecordmethod opens a fluentEventBuilderthat callspushon drop.
Functions§
- truncate_
string - Truncates a string for display, adding ellipsis if needed.