class TypeProf::ISeqBlock

Attributes

iseq[R]
outer_ep[R]

Public Class Methods

new(iseq, ep) click to toggle source
# File typeprof-0.21.8/lib/typeprof/block.rb, line 7
def initialize(iseq, ep)
  @iseq = iseq
  @outer_ep = ep
end

Public Instance Methods

consistent?(other) click to toggle source
# File typeprof-0.21.8/lib/typeprof/block.rb, line 18
def consistent?(other)
  if other.is_a?(ISeqBlock)
    self == other
  else
    true # XXX
  end
end
do_call(aargs, caller_ep, caller_env, scratch, replace_recv_ty:, replace_cref:, &ctn) click to toggle source
# File typeprof-0.21.8/lib/typeprof/block.rb, line 30
def do_call(aargs, caller_ep, caller_env, scratch, replace_recv_ty:, replace_cref:, &ctn)
  blk_env = scratch.return_envs[@outer_ep]
  if replace_recv_ty
    replace_recv_ty = scratch.globalize_type(replace_recv_ty, caller_env, caller_ep)
    blk_env = blk_env.replace_recv_ty(replace_recv_ty)
  end
  aargs = scratch.globalize_type(aargs, caller_env, caller_ep)

  scratch.add_block_signature!(self, aargs.to_block_signature)

  locals = [Type.nil] * @iseq.locals.size

  blk_ty, start_pcs = aargs.setup_formal_arguments(:block, locals, @iseq.fargs_format)
  if blk_ty.is_a?(String)
    scratch.error(caller_ep, blk_ty)
    ctn[Type.any, caller_ep, caller_env]
    return
  end

  cref = replace_cref || @outer_ep.ctx.cref
  nctx = Context.new(@iseq, cref, nil)
  callee_ep = ExecutionPoint.new(nctx, 0, @outer_ep)
  nenv = Env.new(blk_env.static_env, locals, [], nil)
  alloc_site = AllocationSite.new(callee_ep)
  locals.each_with_index do |ty, i|
    alloc_site2 = alloc_site.add_id(i)
    nenv, ty = scratch.localize_type(ty, nenv, callee_ep, alloc_site2)
    nenv = nenv.local_update(i, ty)
  end

  start_pcs.each do |start_pc|
    scratch.merge_env(ExecutionPoint.new(nctx, start_pc, @outer_ep), nenv)
  end

  scratch.add_block_to_ctx!(self, callee_ep.ctx)
  scratch.add_callsite!(callee_ep.ctx, caller_ep, caller_env, &ctn)
end
inspect() click to toggle source
# File typeprof-0.21.8/lib/typeprof/block.rb, line 14
def inspect
  "#<ISeqBlock: #{ @outer_ep.source_location }>"
end
substitute(_subst, _depth) click to toggle source
# File typeprof-0.21.8/lib/typeprof/block.rb, line 26
def substitute(_subst, _depth)
  self
end