class
Ameba::AST::ReachingDefinitionAnalyzer
- Ameba::AST::ReachingDefinitionAnalyzer
- Reference
- Object
Overview
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.
Included Modules
Defined in:
ameba/ast/reaching_definition_analyzer.crConstructors
-
.new(scope : Scope, entry : DefinedSet)
Creates a new analyzer for scope.
Instance Method Summary
-
#inner_scope_definitions : Hash(UInt64, DefinedSet)
Returns a mapping of each inner-scope node's
object_idto the set of variable names that reach the point where that scope is introduced.
Instance methods inherited from module Ameba::AST::Dataflow
scope_body(node)
scope_body
Instance methods inherited from module Ameba::AST::Util
abort?(node)
abort?,
control_exp_code(node : Crystal::ControlExpression, code_lines)
control_exp_code,
dynamic_literal?(node) : Bool
dynamic_literal?,
each_inline_directive(source, &block : Crystal::Token, String, Array(String) -> _)
each_inline_directive,
exit?(node)
exit?,
flow_command?(node, in_loop)
flow_command?,
flow_expression?(node, in_loop = false)
flow_expression?,
has_arguments?(node) : Bool
has_arguments?,
has_block?(node) : Bool
has_block?,
has_short_block?(node, code_lines)
has_short_block?,
heredoc?(node : Crystal::ASTNode, source : Source)
heredoc?,
literal?(node) : Bool
literal?,
loop?(node)
loop?,
name_end_location(node)
name_end_location,
name_location(node)
name_location,
name_location_or(token : Crystal::Token, name, *, adjust_location_column_number = nil)name_location_or(node : Crystal::ASTNode, *, adjust_location_column_number = nil) name_location_or, name_size(node) name_size, node_source(node, code_lines) node_source, nodoc?(node) nodoc?, operator_method?(node) operator_method?, operator_method_name?(name : String) operator_method_name?, path_name(node : Crystal::Path, *, include_global = true) : String path_name, path_named?(node, *names : String) : Bool path_named?, raise?(node) raise?, setter_method?(node) setter_method?, setter_method_name?(name : String) setter_method_name?, short_block?(node, code_lines) short_block?, source_between(loc, end_loc, code_lines) : String | Nil source_between, static_literal?(node) : Bool static_literal?, suffix?(node) suffix?, takes_arguments?(node) : Bool takes_arguments?
Constructor Detail
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).
Instance Method Detail
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.