Class: SyntaxTree::YARV::SeaOfNodes::Compiler
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::SeaOfNodes::Compiler
- Defined in:
- lib/syntax_tree/yarv/sea_of_nodes.rb
Overview
The compiler is responsible for taking a data flow graph and turning it into a sea of nodes.
Instance Attribute Summary collapse
-
#dfg ⇒ Object
readonly
Returns the value of attribute dfg.
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
Instance Method Summary collapse
- #compile ⇒ Object
-
#initialize(dfg) ⇒ Compiler
constructor
A new instance of Compiler.
Constructor Details
#initialize(dfg) ⇒ Compiler
Returns a new instance of Compiler.
103 104 105 106 107 108 109 110 111 |
# 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 |
Instance Attribute Details
#dfg ⇒ Object (readonly)
Returns the value of attribute dfg.
101 102 103 |
# File 'lib/syntax_tree/yarv/sea_of_nodes.rb', line 101 def dfg @dfg end |
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
101 102 103 |
# File 'lib/syntax_tree/yarv/sea_of_nodes.rb', line 101 def nodes @nodes end |
Instance Method Details
#compile ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 |
# 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 |