class AdLint::Exam::CBuiltin::XRefExtraction
Public Class Methods
new(phase_ctxt)
click to toggle source
Calls superclass method
AdLint::Examination::new
# File lib/adlint/exam/c_builtin/cc1_code.rb, line 347 def initialize(phase_ctxt) super interp = phase_ctxt[:cc1_interpreter] interp.on_function_started += T(:update_accessor) interp.on_function_ended += T(:clear_accessor) interp.on_variable_value_referred += T(:extract_variable_read) interp.on_variable_value_updated += T(:extract_variable_write) interp.on_function_referred += T(:extract_function_reference) @accessor = nil end
Private Instance Methods
clear_accessor(*)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_code.rb, line 366 def clear_accessor(*) @accessor = nil end
do_execute(*)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_code.rb, line 360 def do_execute(*) end
do_prepare(*)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_code.rb, line 359 def do_prepare(*) end
extract_function_reference(expr, fun)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_code.rb, line 403 def extract_function_reference(expr, fun) if fun.named? if @accessor referrer = FunctionId.new(@accessor.name, @accessor.signature.to_s) else referrer = FunctionId.of_ctors_section end XREF_FUN(expr.location, referrer, "R", FunctionId.new(fun.name, fun.signature.to_s)) end end
extract_variable_read(expr, var)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_code.rb, line 370 def extract_variable_read(expr, var) if var.scope.global? && var.named? # NOTE: When a value of the inner-variable of array or composite object # is referred, dependency record of only outmost-variable access # should be output. var = var.owner while var.inner? if @accessor referrer = FunctionId.new(@accessor.name, @accessor.signature.to_s) else referrer = FunctionId.of_ctors_section end XREF_VAR(expr.location, referrer, "R", var.name) end end
extract_variable_write(expr, var)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_code.rb, line 386 def extract_variable_write(expr, var) # NOTE: When a value of the inner-variable of array or composite # object is updated, dependency record of the inner-variable # access should not be output and the outer variable's value # will also be notified later. return if var.inner? if var.scope.global? && var.named? if @accessor referrer = FunctionId.new(@accessor.name, @accessor.signature.to_s) else referrer = FunctionId.of_ctors_section end XREF_VAR(expr.location, referrer, "W", var.name) end end
update_accessor(*, fun)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_code.rb, line 362 def update_accessor(*, fun) @accessor = fun end