Class: TypeProf::Core::SplatBox

Inherits:
Box
  • Object
show all
Defined in:
lib/typeprof/core/graph/box.rb

Instance Attribute Summary collapse

Attributes inherited from Box

#changes, #destroyed, #node

Instance Method Summary collapse

Methods inherited from Box

#destroy, #on_type_added, #on_type_removed, #reuse, #run, #to_s

Constructor Details

#initialize(node, genv, ary, idx) ⇒ SplatBox

Returns a new instance of SplatBox.



334
335
336
337
338
339
340
# File 'lib/typeprof/core/graph/box.rb', line 334

def initialize(node, genv, ary, idx)
  super(node)
  @ary = ary
  @idx = idx
  @ary.add_edge(genv, self)
  @ret = Vertex.new(node)
end

Instance Attribute Details

#aryObject (readonly)

Returns the value of attribute ary.



342
343
344
# File 'lib/typeprof/core/graph/box.rb', line 342

def ary
  @ary
end

#idxObject (readonly)

Returns the value of attribute idx.



342
343
344
# File 'lib/typeprof/core/graph/box.rb', line 342

def idx
  @idx
end

#retObject (readonly)

Returns the value of attribute ret.



342
343
344
# File 'lib/typeprof/core/graph/box.rb', line 342

def ret
  @ret
end

Instance Method Details

#run0(genv, changes) ⇒ Object



344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
# File 'lib/typeprof/core/graph/box.rb', line 344

def run0(genv, changes)
  @ary.each_type do |ty|
    case ty
    when Type::Instance
      if ty.mod == genv.mod_ary
        changes.add_edge(genv, ty.args[0], @ret)
      else
        "???"
      end
    when Type::Array
      if @idx && @idx < ty.elems.size
        changes.add_edge(genv, ty.elems[@idx], @ret)
      else
        changes.add_edge(genv, ty.get_elem(genv, @idx), @ret)
      end
    else
      "???"
    end
  end
end