Class: TypeTracer::MethodAnalyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/type_tracer/method_analyzer.rb

Instance Method Summary collapse

Constructor Details

#initialize(method_def:) ⇒ MethodAnalyzer

Returns a new instance of MethodAnalyzer.



4
5
6
# File 'lib/type_tracer/method_analyzer.rb', line 4

def initialize(method_def:)
  @method_def = method_def
end

Instance Method Details

#arg_namesObject



8
9
10
# File 'lib/type_tracer/method_analyzer.rb', line 8

def arg_names
  @arg_names ||= args.children.map { |arg_node| arg_node.children.first }
end

#arg_sendsObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/type_tracer/method_analyzer.rb', line 12

def arg_sends
  return @arg_sends if @arg_sends
  # For the simple version, just assume we don't know what will happen if
  # there are branches in the method, so assume that no args definitely get
  # called (as there could be conditioning on arg type).
  @arg_sends =
    if branches?
      empty_arg_sends
    else
      Hash[arg_names.map { |arg| [arg, sends_for_arg(arg)] }]
    end
end