Class: AdLint::Ld::ObjectXRefGraphBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/adlint/ld/object.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(var_map, fun_map, funcall_graph) ⇒ ObjectXRefGraphBuilder

Returns a new instance of ObjectXRefGraphBuilder.



483
484
485
486
# File 'lib/adlint/ld/object.rb', line 483

def initialize(var_map, fun_map, funcall_graph)
  @var_map, @fun_map = var_map, fun_map
  @graph = ObjectXRefGraph.new(funcall_graph)
end

Instance Attribute Details

#graphObject (readonly)

Returns the value of attribute graph.



488
489
490
# File 'lib/adlint/ld/object.rb', line 488

def graph
  @graph
end

Instance Method Details

#execute(met_fpath) ⇒ Object



490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
# File 'lib/adlint/ld/object.rb', line 490

def execute(met_fpath)
  sma_wd = Pathname.pwd
  CSV.foreach(met_fpath) do |csv_row|
    rec = MetricRecord.of(csv_row, sma_wd)
    case
    when rec.version?
      sma_wd = Pathname.new(rec.exec_working_directory)
    when rec.variable_xref?
      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)) if var
    when rec.function_xref?
      ref, fun = lookup_referrer_and_function_by_xref(rec)
      @graph.add(ObjectReference.new(ref, fun, rec.location)) if ref && fun
    end
  end
end