def do_call(aargs, caller_ep, caller_env, scratch, replace_recv_ty,, &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
nctx = Context.new(@iseq, @outer_ep.ctx.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