Skip to main content

Module events

Module events 

Source
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’s T::MethodRef so each event can name the method it occurred in.
  • EventListener<T> — sink trait; push accepts a fully-formed event. The default record method returns an EventBuilder for the fluent events.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§

DerivedStats
Statistics derived from an EventLog. Counts are by EventKind and independent of T, so this struct is not generic.
Event
A single logged event.
EventBuilder
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.
EventLog
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 to boxcar::Vec.
EventLogIter
Iterator wrapper for EventLog that yields &Event<T>.
NullListener
No-op listener: every event is silently discarded.

Enums§

EventKind
Categories of events that can be logged. Target-agnostic — labels are purely descriptive and carry no host types.

Traits§

EventListener
Sink for events recorded by passes. The push method accepts a fully-formed event; the default record method opens a fluent EventBuilder that calls push on drop.

Functions§

truncate_string
Truncates a string for display, adding ellipsis if needed.