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.



607
608
609
610
# File 'lib/adlint/ld/object.rb', line 607

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

Instance Attribute Details

#graphObject (readonly)

Returns the value of attribute graph.



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

def graph
  @graph
end

Instance Method Details

#execute(met_fpath) ⇒ Object



614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
# File 'lib/adlint/ld/object.rb', line 614

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.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