Class: TypeProf::Core::EscapeBox

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

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

Constructor Details

#initialize(node, genv, a_ret) ⇒ EscapeBox

Returns a new instance of EscapeBox.



612
613
614
615
# File 'lib/typeprof/core/graph/box.rb', line 612

def initialize(node, genv, a_ret)
  super(node)
  @a_ret = a_ret.new_vertex(genv, node)
end

Instance Attribute Details

#a_retObject (readonly)

Returns the value of attribute a_ret.



617
618
619
# File 'lib/typeprof/core/graph/box.rb', line 617

def a_ret
  @a_ret
end

Instance Method Details

#retObject



619
# File 'lib/typeprof/core/graph/box.rb', line 619

def ret = @a_ret

#run0(genv, changes) ⇒ Object



621
622
623
# File 'lib/typeprof/core/graph/box.rb', line 621

def run0(genv, changes)
  return
end

#wrong_return_type(f_ret_show, changes) ⇒ Object



625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
# File 'lib/typeprof/core/graph/box.rb', line 625

def wrong_return_type(f_ret_show, changes)
  actual_ty = @a_ret.show
  msg = "expected: #{ f_ret_show }; actual: #{ actual_ty }"
  case @node
  when AST::ReturnNode
    changes.add_diagnostic(:code_range, msg, @node)
  when AST::DefNode
    changes.add_diagnostic(:last_stmt_code_range, msg, @node)
  when AST::NextNode
    changes.add_diagnostic(:code_range, msg, @node)
  when AST::CallNode
    changes.add_diagnostic(:block_last_stmt_code_range, msg, @node)
  when AST::AttrReaderMetaNode, AST::AttrAccessorMetaNode
    changes.add_diagnostic(:code_range, msg, @node)
  else
    pp @node.class
  end
end