class AdLint::SingleModuleAnalyzer

Single module analysis driver.

Public Class Methods

new(traits, msg_catalog, src_fpath, strip_num, output_dpath, verbose) click to toggle source
Calls superclass method AdLint::Analyzer::new
# File lib/adlint/analyzer.rb, line 113
def initialize(traits, msg_catalog, src_fpath, strip_num, output_dpath,
               verbose)
  super("SMA-#{SHORT_VERSION}", traits, msg_catalog, src_fpath.to_s,
        output_dpath, src_fpath.strip(strip_num), verbose)
  @src_fpath = src_fpath
  @strip_num = strip_num
end

Private Instance Methods

execute(monitor) click to toggle source
# File lib/adlint/analyzer.rb, line 122
def execute(monitor)
  Report.new(msg_fpath, met_fpath, log_fpath, @verbose) do |report|
    src = Source.new(@src_fpath, @traits.of_project.file_encoding)

    phase_ctxt = PhaseContext.new(self, report, monitor)
    phase_ctxt[:sources]      = [src]
    phase_ctxt[:annotations]  = []
    phase_ctxt[:suppressors]  = MessageSuppressorSet.new
    phase_ctxt[:symbol_table] = SymbolTable.new

    begin
      phases.each { |phase| phase.new(phase_ctxt).execute }
      phase_ctxt.flush_deferred_report!
    ensure
      File.open(i_fpath, "w") do |io|
        io.set_encoding(Encoding.default_external)
        io.puts(phase_ctxt[:cc1_source].to_s)
      end
    end
  end
rescue
  if @verbose
    $stderr.puts "An error was occurred while processing `#{@src_fpath}'."
    $stderr.puts "See `#{msg_fpath}' and `#{log_fpath}' for more details."
  end
  raise
end
i_fpath() click to toggle source
# File lib/adlint/analyzer.rb, line 164
def i_fpath
  i_fname = @src_fpath.strip(@strip_num).sub_ext(".i")
  @output_dpath ? @output_dpath.join(i_fname) : i_fname
end
met_fpath() click to toggle source
# File lib/adlint/analyzer.rb, line 159
def met_fpath
  met_fname = @src_fpath.strip(@strip_num).add_ext(".met.csv")
  @output_dpath ? @output_dpath.join(met_fname) : met_fname
end
msg_fpath() click to toggle source
# File lib/adlint/analyzer.rb, line 154
def msg_fpath
  msg_fname = @src_fpath.strip(@strip_num).add_ext(".msg.csv")
  @output_dpath ? @output_dpath.join(msg_fname) : msg_fname
end
phases() click to toggle source
# File lib/adlint/analyzer.rb, line 150
def phases
  (lang = Language.of(@src_fpath)) ? lang.single_module_phases : []
end