Class: AdLint::Ld::FunctionCallGraphBuilder

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fun_map) ⇒ FunctionCallGraphBuilder

Returns a new instance of FunctionCallGraphBuilder.



613
614
615
616
# File 'lib/adlint/ld/object.rb', line 613

def initialize(fun_map)
  @fun_map = fun_map
  @graph = FunctionCallGraph.new
end

Instance Attribute Details

#graphObject (readonly)

Returns the value of attribute graph.



618
619
620
# File 'lib/adlint/ld/object.rb', line 618

def graph
  @graph
end

Instance Method Details

#execute(met_fpath) ⇒ Object



620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
# File 'lib/adlint/ld/object.rb', line 620

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.function_call?
        caller_ref, callee_fun = lookup_functions_by_call(rec)
        if caller_ref && callee_fun
          @graph.add(FunctionCall.new(caller_ref, callee_fun))
        end
      end
    end
  end
end