class SyntaxTree::YARV::SeaOfNodes::Compiler

The compiler is responsible for taking a data flow graph and turning it into a sea of nodes.

Attributes

dfg[R]
nodes[R]

Public Class Methods

new(dfg) click to toggle source
# File lib/syntax_tree/yarv/sea_of_nodes.rb, line 103
def initialize(dfg)
  @dfg = dfg
  @nodes = []

  # We need to put a unique ID on the synthetic nodes in the graph, so
  # we keep a counter that we increment any time we create a new
  # synthetic node.
  @id_counter = 999
end

Public Instance Methods

compile() click to toggle source
# File lib/syntax_tree/yarv/sea_of_nodes.rb, line 113
def compile
  local_graphs = {}
  dfg.blocks.each do |block|
    local_graphs[block.id] = create_local_graph(block)
  end

  connect_local_graphs_control(local_graphs)
  connect_local_graphs_data(local_graphs)
  cleanup_phi_nodes
  cleanup_insn_nodes

  SeaOfNodes.new(dfg, nodes, local_graphs).tap(&:verify)
end