module AdLint::Cc1::DebugUtil

Public Class Methods

dump_syntax_tree(phase_ctxt) click to toggle source
# File lib/adlint/cc1/util.rb, line 69
def dump_syntax_tree(phase_ctxt)
  if $DEBUG
    ast_fname = phase_ctxt[:sources].first.fpath.basename.add_ext(".ast")
    ast_fpath = ast_fname.expand_path(phase_ctxt.msg_fpath.dirname)

    File.open(ast_fpath, "w") do |io|
      if phase_ctxt[:cc1_ast]
        PP.pp(phase_ctxt[:cc1_ast], io)
      end
    end
  end
end
dump_token_array(phase_ctxt) click to toggle source
# File lib/adlint/cc1/util.rb, line 83
def dump_token_array(phase_ctxt)
  if $DEBUG
    tok_fname = phase_ctxt[:sources].first.fpath.basename.add_ext(".tok")
    tok_fpath = tok_fname.expand_path(phase_ctxt.msg_fpath.dirname)

    File.open(tok_fpath, "w") do |io|
      if phase_ctxt[:cc1_tokens]
        phase_ctxt[:cc1_tokens].each { |tok| io.puts(tok.inspect) }
      end
    end
  end
end

Private Instance Methods

dump_syntax_tree(phase_ctxt) click to toggle source
# File lib/adlint/cc1/util.rb, line 69
def dump_syntax_tree(phase_ctxt)
  if $DEBUG
    ast_fname = phase_ctxt[:sources].first.fpath.basename.add_ext(".ast")
    ast_fpath = ast_fname.expand_path(phase_ctxt.msg_fpath.dirname)

    File.open(ast_fpath, "w") do |io|
      if phase_ctxt[:cc1_ast]
        PP.pp(phase_ctxt[:cc1_ast], io)
      end
    end
  end
end
dump_token_array(phase_ctxt) click to toggle source
# File lib/adlint/cc1/util.rb, line 83
def dump_token_array(phase_ctxt)
  if $DEBUG
    tok_fname = phase_ctxt[:sources].first.fpath.basename.add_ext(".tok")
    tok_fpath = tok_fname.expand_path(phase_ctxt.msg_fpath.dirname)

    File.open(tok_fpath, "w") do |io|
      if phase_ctxt[:cc1_tokens]
        phase_ctxt[:cc1_tokens].each { |tok| io.puts(tok.inspect) }
      end
    end
  end
end