Class: TypeProf::Core::Block

Inherits:
Object
  • Object
show all
Defined in:
lib/typeprof/core/env/method.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node, f_ary_arg, f_args, next_boxes) ⇒ Block

Returns a new instance of Block.



85
86
87
88
89
90
# File 'lib/typeprof/core/env/method.rb', line 85

def initialize(node, f_ary_arg, f_args, next_boxes)
  @node = node
  @f_ary_arg = f_ary_arg
  @f_args = f_args
  @next_boxes = next_boxes
end

Instance Attribute Details

#f_argsObject (readonly)

Returns the value of attribute f_args.



92
93
94
# File 'lib/typeprof/core/env/method.rb', line 92

def f_args
  @f_args
end

#nodeObject (readonly)

Returns the value of attribute node.



92
93
94
# File 'lib/typeprof/core/env/method.rb', line 92

def node
  @node
end

#retObject (readonly)

Returns the value of attribute ret.



92
93
94
# File 'lib/typeprof/core/env/method.rb', line 92

def ret
  @ret
end

Instance Method Details

#accept_args(genv, changes, caller_positionals, caller_ret, ret_check) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/typeprof/core/env/method.rb', line 94

def accept_args(genv, changes, caller_positionals, caller_ret, ret_check)
  if caller_positionals.size == 1 && @f_args.size >= 2
    # TODO: support splat "do |a, *b, c|"
    changes.add_edge(genv, caller_positionals[0].new_vertex(genv, @node), @f_ary_arg)
  else
    caller_positionals.zip(@f_args) do |a_arg, f_arg|
      changes.add_edge(genv, a_arg, f_arg) if f_arg
    end
  end
  if ret_check
    @next_boxes.each do |box|
      changes.add_edge(genv, caller_ret, box.f_ret)
    end
  else
    @next_boxes.each do |box|
      changes.add_edge(genv, box.a_ret, caller_ret)
    end
  end
end