Skip to content

Commit

Permalink
Added parameter parsing for only dumping one IR pass
Browse files Browse the repository at this point in the history
  • Loading branch information
komax committed Jul 10, 2013
1 parent 372abfd commit fbc8878
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions bin/ast
@@ -1,16 +1,27 @@
#!/usr/bin/env jruby #!/usr/bin/env jruby


require 'optparse' require 'optparse'
require 'jruby'


opts = {} opts = {}
options = { options = {
:print_source => false, :print_source => false,
:print_sexp => false, :print_sexp => false,
:print_ast => true, :print_ast => true,
:print_ir => false, :print_ir => false,
:print_pass => nil,
:dot_format => false :dot_format => false
} }


def get_ir_passes
ir_manager = org.jruby.ir.IRManager
ir_manager.DEFAULT_COMPILER_PASSES.split(',').map do |pass|
pass.to_sym
end
end

ir_passes = get_ir_passes

OptionParser.new do |opts| OptionParser.new do |opts|
opts.banner = "Usage: #{$0} [options]" opts.banner = "Usage: #{$0} [options]"


Expand All @@ -26,6 +37,10 @@ OptionParser.new do |opts|
opts.on('-i', '--ir', 'Dump all IR passes without executing') do |h| opts.on('-i', '--ir', 'Dump all IR passes without executing') do |h|
options[:print_ir] = true options[:print_ir] = true
end end

opts.on('-p', '--pass NAME', ir_passes, 'Dump IR after running NAME pass') do |pass|
options[:print_pass] = pass
end


opts.on('-s', '--sexp', 'Display the S-Expression for the AST') do |t| opts.on('-s', '--sexp', 'Display the S-Expression for the AST') do |t|
options[:print_sexp] = true options[:print_sexp] = true
Expand Down

0 comments on commit fbc8878

Please sign in to comment.