Skip to content
Browse files

Fancy line numbers in IR pretty printer

  • Loading branch information...
1 parent 2e38fe3 commit 5258f81876c9d9c4beabbb38dd43ffcafe93296e @komax committed Jul 11, 2013
Showing with 7 additions and 5 deletions.
  1. +7 −5 bin/ast
View
12 bin/ast
@@ -210,14 +210,16 @@ end
module IRPrettyPrinter
def self.pretty_ir(scope, indent="")
- instrs = scope.instrs.map do |instr|
- indent + instr.to_s
+ i = 0
+ pretty_str = scope.instrs.map do |instr|
+ indent + "#{i}\s\s" + instr.to_s
+ i += 1
end
- instrs = [indent + scope.to_s] + instrs
+ pretty_str = [indent + scope.to_s] + pretty_str
scope.lexical_scopes.each do |lex_scope|
- instrs += pretty_ir(lex_scope, indent + "\s" * 4)
+ pretty_str += pretty_ir(lex_scope, indent + "\s" * 4)
end
- instrs
+ pretty_str
end
def self.print_ir(scope)

0 comments on commit 5258f81

Please sign in to comment.
Something went wrong with that request. Please try again.