Class: AdLint::Ld::FunctionCallGraph
- Inherits:
-
Object
- Object
- AdLint::Ld::FunctionCallGraph
- Defined in:
- lib/adlint/ld/object.rb
Instance Method Summary collapse
- #add(funcall) ⇒ Object
- #all_callers_of(fun) ⇒ Object
- #direct_callers_of(fun) ⇒ Object
- #indirect_callers_of(fun) ⇒ Object
-
#initialize ⇒ FunctionCallGraph
constructor
A new instance of FunctionCallGraph.
Constructor Details
#initialize ⇒ FunctionCallGraph
Returns a new instance of FunctionCallGraph.
561 562 563 |
# File 'lib/adlint/ld/object.rb', line 561 def initialize @callee_index = Hash.new { |hash, key| hash[key] = Set.new } end |
Instance Method Details
#add(funcall) ⇒ Object
565 566 567 |
# File 'lib/adlint/ld/object.rb', line 565 def add(funcall) @callee_index[funcall.callee].add(funcall) end |
#all_callers_of(fun) ⇒ Object
569 570 571 |
# File 'lib/adlint/ld/object.rb', line 569 def all_callers_of(fun) direct_callers_of(fun) + indirect_callers_of(fun) end |
#direct_callers_of(fun) ⇒ Object
574 575 576 |
# File 'lib/adlint/ld/object.rb', line 574 def direct_callers_of(fun) @callee_index[fun].map { |funcall| funcall.caller }.to_set end |
#indirect_callers_of(fun) ⇒ Object
579 580 581 582 583 584 585 586 587 |
# File 'lib/adlint/ld/object.rb', line 579 def indirect_callers_of(fun) direct_callers_of(fun).reduce(Set.new) do |res, ref| if fun = ref.function res + collect_callers_of(fun, res) else res end end end |