123456789_123456789_123456789_123456789_123456789_

Class: TypeProf::AttrMethodDef

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, MethodDef
Instance Chain:
Inherits: TypeProf::MethodDef
Defined in: lib/typeprof/method.rb

Class Method Summary

Instance Attribute Summary

MethodDef - Inherited

Instance Method Summary

Constructor Details

.new(ivar, kind, pub_meth, def_ep) ⇒ AttrMethodDef

[ GitHub ]

  
# File 'lib/typeprof/method.rb', line 176

def initialize(ivar, kind, pub_meth, def_ep)
  @ivar = ivar
  @kind = kind # :reader | :writer
  @pub_meth = pub_meth
  @def_ep = def_ep
end

Instance Attribute Details

#def_ep (readonly)

[ GitHub ]

  
# File 'lib/typeprof/method.rb', line 183

attr_reader :ivar, :kind, :def_ep

#ivar (readonly)

[ GitHub ]

  
# File 'lib/typeprof/method.rb', line 183

attr_reader :ivar, :kind, :def_ep

#kind (readonly)

[ GitHub ]

  
# File 'lib/typeprof/method.rb', line 183

attr_reader :ivar, :kind, :def_ep

Instance Method Details

#do_send(recv, mid, aargs, caller_ep, caller_env, scratch, &ctn)

[ GitHub ]

  
# File 'lib/typeprof/method.rb', line 185

def do_send(recv, mid, aargs, caller_ep, caller_env, scratch, &ctn)
  case @kind
  when :reader
    if aargs.lead_tys.size == 0
      scratch.add_ivar_read!(recv, @ivar, caller_ep) do |ty, _ep|
        ctn[ty, caller_ep, caller_env]
      end
    else
      ctn[Type.any, caller_ep, caller_env]
    end
  when :writer
    if aargs.lead_tys.size == 1
      ty = aargs.lead_tys[0]
      scratch.set_instance_variable(recv, @ivar, ty, caller_ep, caller_env)
      ctn[ty, caller_ep, caller_env]
    else
      ctn[Type.any, caller_ep, caller_env]
    end
  end
end