Class: SyntaxTree::YARV::DataFlowGraph::Compiler
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::DataFlowGraph::Compiler
- Defined in:
- lib/syntax_tree/yarv/data_flow_graph.rb
Overview
This class is responsible for creating a data flow graph from the given control flow graph.
Instance Attribute Summary collapse
-
#block_flows ⇒ Object
readonly
This data structure will hold the data flow between basic blocks.
-
#cfg ⇒ Object
readonly
This is the control flow graph that is being compiled.
-
#insn_flows ⇒ Object
readonly
This data structure will hold the data flow between instructions within individual basic blocks.
Instance Method Summary collapse
- #compile ⇒ Object
-
#initialize(cfg) ⇒ Compiler
constructor
A new instance of Compiler.
Constructor Details
#initialize(cfg) ⇒ Compiler
Returns a new instance of Compiler.
221 222 223 224 225 |
# File 'lib/syntax_tree/yarv/data_flow_graph.rb', line 221 def initialize(cfg) @cfg = cfg @insn_flows = cfg.insns.to_h { |length, _| [length, DataFlow.new] } @block_flows = cfg.blocks.to_h { |block| [block.id, DataFlow.new] } end |
Instance Attribute Details
#block_flows ⇒ Object (readonly)
This data structure will hold the data flow between basic blocks.
219 220 221 |
# File 'lib/syntax_tree/yarv/data_flow_graph.rb', line 219 def block_flows @block_flows end |
#cfg ⇒ Object (readonly)
This is the control flow graph that is being compiled.
212 213 214 |
# File 'lib/syntax_tree/yarv/data_flow_graph.rb', line 212 def cfg @cfg end |
#insn_flows ⇒ Object (readonly)
This data structure will hold the data flow between instructions within individual basic blocks.
216 217 218 |
# File 'lib/syntax_tree/yarv/data_flow_graph.rb', line 216 def insn_flows @insn_flows end |
Instance Method Details
#compile ⇒ Object
227 228 229 230 231 |
# File 'lib/syntax_tree/yarv/data_flow_graph.rb', line 227 def compile find_internal_flow find_external_flow DataFlowGraph.new(cfg, insn_flows, block_flows).tap(&:verify) end |