@@ -38,19 +38,19 @@ def self.compile(cfg)
3838 # blocks.
3939 block_flows = { }
4040 cfg . blocks . each do |block |
41- block_flows [ block . block_start ] = DataFlow . new
41+ block_flows [ block . id ] = DataFlow . new
4242 end
4343
4444 # Now, discover the data flow within each basic block. Using an abstract
4545 # stack, connect from consumers of data to the producers of that data.
4646 cfg . blocks . each do |block |
47- block_flow = block_flows . fetch ( block . block_start )
47+ block_flow = block_flows . fetch ( block . id )
4848
4949 stack = [ ]
5050 stack_initial_depth = 0
5151
5252 # Go through each instruction in the block...
53- block . insns . each . with_index ( block . block_start ) do |insn , index |
53+ block . each_with_index do |insn , index |
5454 insn_flow = insn_flows [ index ]
5555
5656 # How many values will be missing from the local stack to run this
@@ -107,9 +107,9 @@ def self.compile(cfg)
107107 stack = [ *cfg . blocks ]
108108 until stack . empty?
109109 succ = stack . pop
110- succ_flow = block_flows . fetch ( succ . block_start )
110+ succ_flow = block_flows . fetch ( succ . id )
111111 succ . predecessors . each do |pred |
112- pred_flow = block_flows . fetch ( pred . block_start )
112+ pred_flow = block_flows . fetch ( pred . id )
113113
114114 # Does a predecessor block have fewer outputs than the successor
115115 # has inputs?
@@ -132,20 +132,20 @@ def self.compile(cfg)
132132
133133 # Verify that we constructed the data flow graph correctly. Check that
134134 # the first block has no arguments.
135- raise unless block_flows . fetch ( cfg . blocks . first . block_start ) . in . empty?
135+ raise unless block_flows . fetch ( cfg . blocks . first . id ) . in . empty?
136136
137137 # Check all control flow edges between blocks pass the right number of
138138 # arguments.
139139 cfg . blocks . each do |pred |
140- pred_flow = block_flows . fetch ( pred . block_start )
140+ pred_flow = block_flows . fetch ( pred . id )
141141
142142 if pred . successors . empty?
143143 # With no successors, there should be no output arguments.
144144 raise unless pred_flow . out . empty?
145145 else
146146 # Check with successor...
147147 pred . successors . each do |succ |
148- succ_flow = block_flows . fetch ( succ . block_start )
148+ succ_flow = block_flows . fetch ( succ . id )
149149
150150 # The predecessor should have as many output arguments as the
151151 # success has input arguments.
@@ -170,12 +170,12 @@ def disasm
170170 end
171171 output . puts
172172
173- block_flow = block_flows . fetch ( block . block_start )
173+ block_flow = block_flows . fetch ( block . id )
174174 unless block_flow . in . empty?
175175 output . puts " # in: #{ block_flow . in . join ( ", " ) } "
176176 end
177177
178- block . insns . each . with_index ( block . block_start ) do |insn , index |
178+ block . each_with_index do |insn , index |
179179 output . print ( " " )
180180 output . print ( insn . disasm ( fmt ) )
181181
0 commit comments