Skip to content

Commit

Permalink
Slight adjustment in how the next instruction number is calculated. T…
Browse files Browse the repository at this point in the history
…his is to prepare to move to a recursive (and not explicitly-stack-based) method for dealing with branches.
  • Loading branch information
Michael Edgar committed Apr 1, 2010
1 parent 4e55585 commit 1b5bc96
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/reversal/reverser.rb
Expand Up @@ -121,7 +121,15 @@ def forward_jump?(current, label)
def backward_jump?(current, label)
!forward_jump?(current, label)
end


def next_instruction_number(cur_inst, cur_line)
if cur_inst.is_a?(Array) && (cur_inst[0] == :branchif || cur_inst[0] == :branchunless)
return cur_line + 1
else
return cur_line + 1
end
end

def decompile_body(instruction = 0, stop = @iseq.body.size)
# for now, using non-idiomatic while loop bc of a chance we might need to
# loop back
Expand All @@ -145,7 +153,7 @@ def decompile_body(instruction = 0, stop = @iseq.body.size)
# call "decompile_#{instruction}"
send("decompile_#{inst.first}".to_sym, inst, instruction) if respond_to?("decompile_#{inst.first}".to_sym)
end
instruction += 1
instruction = next_instruction_number(inst, instruction)
end
r(:list, *@stack)
end
Expand Down

0 comments on commit 1b5bc96

Please sign in to comment.