Module: AdLint::Cc1::DebugUtil

Defined in:
lib/adlint/cc1/util.rb

Class Method Summary collapse

Class Method Details

.dump_syntax_tree(phase_ctxt) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
# 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) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
# 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