class AdLint::Ld::ObjectXRefGraphBuilder
Attributes
graph[R]
Public Class Methods
new(var_map, fun_map, funcall_graph)
click to toggle source
# File lib/adlint/ld/object.rb, line 485 def initialize(var_map, fun_map, funcall_graph) @var_map, @fun_map = var_map, fun_map @graph = ObjectXRefGraph.new(funcall_graph) end
Public Instance Methods
execute(met_fpath)
click to toggle source
# File lib/adlint/ld/object.rb, line 492 def execute(met_fpath) sma_wd = Pathname.pwd CSV.foreach(met_fpath) do |csv_row| if rec = MetricRecord.of(csv_row, sma_wd) case when rec.version? sma_wd = Pathname.new(rec.exec_working_directory) when rec.variable_xref? if var = @var_map.lookup_variables(rec.accessee_variable).first fun_id = rec.accessor_function if fun_id.named? fun = @fun_map.lookup_functions(fun_id.name).first ref = ObjectReferrer.of_function(fun) else ref = ObjectReferrer.of_ctors_section(rec.location) end @graph.add(ObjectReference.new(ref, var, rec.location)) end when rec.function_xref? ref, fun = lookup_referrer_and_function_by_xref(rec) if ref && fun @graph.add(ObjectReference.new(ref, fun, rec.location)) end end end end end
Private Instance Methods
lookup_referrer_and_function_by_xref(fun_xref)
click to toggle source
# File lib/adlint/ld/object.rb, line 521 def lookup_referrer_and_function_by_xref(fun_xref) caller_id = fun_xref.accessor_function if caller_id.named? caller_fun = @fun_map.lookup_functions(caller_id.name).find { |fun| fun.location.fpath == fun_xref.location.fpath } return nil, nil unless caller_fun ref = ObjectReferrer.of_function(caller_fun) else ref = ObjectReferrer.of_ctors_section(fun_xref.location) end callee_funs = @fun_map.lookup_functions(fun_xref.accessee_function.name) callee_fun = callee_funs.find { |fun| fun.location.fpath == ref.location.fpath } || callee_funs.first return ref, callee_fun end