Skip to content

Commit

Permalink
Removed silly indentation methods. Getting really clean now!
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Edgar committed Mar 30, 2010
1 parent 8b79df7 commit 1422ab0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 37 deletions.
4 changes: 0 additions & 4 deletions lib/reversal/instructions.rb
Expand Up @@ -284,7 +284,6 @@ def decompile_branchunless(inst, line_no)
else
push "if (#{predicate})"
end
indent!
@else_stack.push target
end
end
Expand All @@ -297,7 +296,6 @@ def decompile_branchif(inst, line_no)
# no elsif check
predicate = pop
push "unless (#{predicate})"
indent!
@else_stack.push target
end
end
Expand All @@ -311,9 +309,7 @@ def decompile_jump(inst, line_no)
if @iseq.body[line_no + 1] == @else_stack.last
# we're an else!
@end_stack.push target # that's when the else ends
outdent!
push "else"
indent!
@else_stack.pop
end
end
Expand Down
34 changes: 1 addition & 33 deletions lib/reversal/reverser.rb
Expand Up @@ -30,21 +30,11 @@ def initialize(iseq, parent=nil)
end

def reset!
@indent ||= 0

@stack = []
@else_stack = []
@end_stack = []
end

def indent!
@indent += TAB_SIZE
end

def outdent!
@indent = [0, @indent - TAB_SIZE].max
end

##
# Gets a local variable at the given bytecode-style index
def get_local(idx)
Expand Down Expand Up @@ -93,27 +83,6 @@ def to_ir
self.__send__("decompile_#{@iseq.type}".to_sym, @iseq)
end

def indented
indent!
result = yield
outdent!
result
end

def indent_str(str)
begin
(" " * @indent) + str.to_s
rescue TypeError
require 'pp'
pp str
raise
end
end

def indent_array(arr)
arr.map {|x| indent_str x}
end

def decompile_block(iseq)
return r(:block, @iseq, IRList.new(decompile_body))
end
Expand All @@ -133,7 +102,7 @@ def decompile_top(iseq)
# If it's just top-level code, then there are no args - just decompile
# the body straight away
def decompile_class(iseq)
indent_array(IRList.new(decompile_body))
IRList.new(decompile_body)
end

def remove_useless_dup
Expand Down Expand Up @@ -167,7 +136,6 @@ def decompile_body(instruction = 0, stop = @iseq.body.size)
# :label_y
while inst == @end_stack.last do
@end_stack.pop
outdent!
push "end"
end
when Array
Expand Down

0 comments on commit 1422ab0

Please sign in to comment.