Ameba::AST::LivenessAnalyzer - ameba 1.7.0

# class Ameba::AST::LivenessAnalyzer

- Ameba::AST::LivenessAnalyzer
- Reference
- Object

##
Overview

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.

##
Included Modules

- Ameba::AST::Dataflow

##
Defined in:

ameba/ast/liveness_analyzer.cr

##
Constructors

- .new(scope : Scope)

##
Instance Method Summary

- #analyze : Result

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

- #dead_stores : Array(Assignment)

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

- #entry_live_set : LiveSet

  Returns the set of variable names that are live at scope entry.

### Instance methods inherited from module `Ameba::AST::Dataflow`

scope_body(node) scope_body

##
Constructor Detail

def self.new(scope : Scope) #

##
Instance Method Detail

def analyze : Result #

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

def dead_stores : Array(Assignment) #

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

def entry_live_set : LiveSet #

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.