class

Ameba::AST::LivenessAnalyzer

Inherits Ameba::AST::Dataflow < Reference < Object

Performs backward dataflow liveness analysis on a scope's AST to detect dead stores (assignments whose values are never read before being overwritten or the scope ends).

The algorithm walks the AST in reverse execution order, maintaining a set of variable names that are currently "live" (will be read in the future). When an assignment is encountered and its target variable is not in the live set, the assignment is marked as a dead store.

Constructors

new(scope : Scope)
Source

Instance methods

analyze

Performs liveness analysis in a single pass, returning both the dead stores and the entry live set.

Source
dead_stores

Returns assignments where the value is never read before being overwritten or the scope ends.

Source
entry_live_set

Returns the set of variable names that are live at scope entry. A variable live at entry means its value (e.g. from a method argument) will be read before being overwritten.

Source

Nested types