class

Ameba::AST::ReachingDefinitionAnalyzer

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

Performs forward dataflow reaching-definition analysis on a scope's AST, the forward complement of LivenessAnalyzer: it answers "which variables already hold a definition that reaches a given program point?".

The reaching set is snapshotted at every inner scope node (block, proc, def, ...), following execution order. At conditional joins the branches are merged by union, but a branch that ends in a flow command (return, next, break, raise, ...) cannot fall through, so its definitions are excluded from the merge.

Constructors

new(scope : Scope, entry : DefinedSet)

Creates a new analyzer for scope. entry is the set of variable names already defined when the scope is entered (its arguments plus any captured outer definitions).

Source

Instance methods

inner_scope_definitions

Returns a mapping of each inner-scope node's object_id to the set of variable names that reach the point where that scope is introduced.

Source

Nested types