Class: MilkTea::ControlFlow::Reachability
- Inherits:
-
Object
- Object
- MilkTea::ControlFlow::Reachability
- Defined in:
- lib/milk_tea/core/control_flow/reachability.rb
Defined Under Namespace
Classes: Result
Class Method Summary collapse
Class Method Details
.solve(graph) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/milk_tea/core/control_flow/reachability.rb', line 8 def self.solve(graph) reachable = Set.new queue = [graph.entry_id] until queue.empty? id = queue.shift next if reachable.include?(id) reachable << id (graph.nodes[id]&.succs || []).each { |succ| queue << succ } end Result.new(reachable_ids: reachable) end |