Class: SourceRoute::TpResultChain

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/source_route/tp_result_chain.rb

Instance Method Summary collapse

Constructor Details

#initializeTpResultChain

Returns a new instance of TpResultChain.



9
10
11
# File 'lib/source_route/tp_result_chain.rb', line 9

def initialize
  @chain = []
end

Instance Method Details

#call_chainObject



13
14
15
# File 'lib/source_route/tp_result_chain.rb', line 13

def call_chain
  select { |tpr| tpr[:event] == :call }
end

#import_return_value_to_call_chainObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/source_route/tp_result_chain.rb', line 21

def import_return_value_to_call_chain
  call_chain.each do |ctp|
    matched_return_tp = return_chain.detect do |rtp|
      rtp[:defined_class] == ctp[:defined_class] and rtp[:method_id] == ctp[:method_id] and
        rtp[:tp_self] == ctp[:tp_self]

    end
    ctp[:return_value] = matched_return_tp[:return_value]
    ctp[:local_var] = matched_return_tp[:local_var]
    ctp[:instance_var] = matched_return_tp[:instance_var]
  end
end

#order_call_chainObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/source_route/tp_result_chain.rb', line 34

def order_call_chain
  init_order_id_and_parent_ids
  call_chain.each do |tpr|
    return_tpr = return_chain.find do |rtpr|
      rtpr[:defined_class] == tpr[:defined_class] and rtpr[:method_id] == tpr[:method_id]
    end

    start_index, end_index = tpr[:order_id], return_tpr[:order_id]
    unless end_index == start_index + 1
      values_at(start_index+1 ... end_index).select { |tpr| tpr[:event] == :call }.each do |tpr|
        tpr[:parent_ids].push start_index
      end
    end
  end

  cal_parent_length
end

#return_chainObject



17
18
19
# File 'lib/source_route/tp_result_chain.rb', line 17

def return_chain
  select { |tpr| tpr[:event] == :return }
end