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

: (AST::CallBaseNode, Vertex, Array, Array) -> void



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

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.



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

def f_args
  @f_args
end

#next_boxesObject (readonly)

Returns the value of attribute next_boxes.



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

def next_boxes
  @next_boxes
end

#nodeObject (readonly)

Returns the value of attribute node.



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

def node
  @node
end

Instance Method Details

#accept_args(genv, changes, caller_positionals) ⇒ Object



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

def accept_args(genv, changes, caller_positionals)
  if caller_positionals.size == 1 && @f_args.size >= 2
    single_arg = caller_positionals[0]

    @f_args.each_with_index do |f_arg, i|
      elem_vtx = changes.add_splat_box(genv, single_arg, i).ret
      changes.add_edge(genv, elem_vtx, f_arg)
    end
  else
    caller_positionals.zip(@f_args) do |a_arg, f_arg|
      changes.add_edge(genv, a_arg, f_arg) if f_arg
    end
  end
end

#add_ret(genv, changes, ret) ⇒ Object



110
111
112
113
114
# File 'lib/typeprof/core/env/method.rb', line 110

def add_ret(genv, changes, ret)
  @next_boxes.each do |box|
    changes.add_edge(genv, box.a_ret, ret)
  end
end