class AdLint::Exam::CBuiltin::FN_CSUB

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 350
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_function_call_expression  += T(:count_function_call)
  @cur_fun = nil
  @funcall_cnt = 0
end

Private Instance Methods

count_function_call(*) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_metric.rb, line 382
def count_function_call(*)
  if @cur_fun
    @funcall_cnt += 1
  end
end
do_execute(*) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_metric.rb, line 365
def do_execute(*) end
do_prepare(*) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_metric.rb, line 364
def do_prepare(*) end
enter_function(fun_def) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_metric.rb, line 367
def enter_function(fun_def)
  @cur_fun = fun_def
  @funcall_cnt = 0
end
leave_function(*) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_metric.rb, line 372
def leave_function(*)
  if @cur_fun
    FN_CSUB(FunctionId.new(@cur_fun.identifier.value,
                           @cur_fun.signature.to_s),
            @cur_fun.location, @funcall_cnt)
    @cur_fun = nil
    @funcall_cnt = 0
  end
end