class AdLint::Exam::CBuiltin::FN_CYCM

Public Class Methods

new(phase_ctxt) click to toggle source
Calls superclass method AdLint::Examination::new
# File lib/adlint/exam/c_builtin/cc1_metric.rb, line 725
def initialize(phase_ctxt)
  super
  @fpath = phase_ctxt[:sources].first.fpath
  trav = phase_ctxt[:cc1_ast_traversal]
  trav.enter_ansi_function_definition  += T(:enter_function)
  trav.leave_ansi_function_definition  += T(:leave_function)
  trav.enter_kandr_function_definition += T(:enter_function)
  trav.leave_kandr_function_definition += T(:leave_function)
  trav.enter_if_statement              += T(:enter_selection)
  trav.enter_if_else_statement         += T(:enter_selection)
  trav.enter_case_labeled_statement    += T(:enter_selection)
  @cur_fun = nil
  @cycl_compl = 0
end

Private Instance Methods

do_execute(*) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_metric.rb, line 742
def do_execute(*) end
do_prepare(*) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_metric.rb, line 741
def do_prepare(*) end
enter_function(fun_def) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_metric.rb, line 744
def enter_function(fun_def)
  @cur_fun = fun_def
  @cycl_compl = 0
end
enter_selection(*) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_metric.rb, line 758
def enter_selection(*)
  @cycl_compl += 1 if @cur_fun
end
leave_function(*) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_metric.rb, line 749
def leave_function(*)
  if @cur_fun
    FN_CYCM(FunctionId.new(@cur_fun.identifier.value,
                           @cur_fun.signature.to_s),
            @cur_fun.location, @cycl_compl + 1)
    @cur_fun = nil
  end
end