class SyntaxTree::YARV::Send
~~~
“hello”.tap { |i| p i }
~~~ruby
### Usage
the optional block instruction sequence.
onto the stack. It has two arguments: the calldata for the call site and
the arguments for the method off the stack and pushes the return value
`send` invokes a method with an optional block. It pops its receiver and
### Summary
def ==(other)
def ==(other) other.is_a?(Send) && other.calldata == calldata && other.block_iseq == block_iseq end
def call(vm)
def call(vm) block = if (iseq = block_iseq) frame = vm.frame ->(*args, **kwargs, &blk) do vm.run_block_frame(iseq, frame, *args, **kwargs, &blk) end elsif calldata.flag?(CallData::CALL_ARGS_BLOCKARG) vm.pop end keywords = if calldata.kw_arg calldata.kw_arg.zip(vm.pop(calldata.kw_arg.length)).to_h else {} end arguments = vm.pop(calldata.argc) receiver = vm.pop vm.push( receiver.__send__(calldata.method, *arguments, **keywords, &block) ) end
def deconstruct_keys(_keys)
def deconstruct_keys(_keys) { calldata: calldata, block_iseq: block_iseq } end
def disasm(fmt)
def disasm(fmt) fmt.enqueue(block_iseq) if block_iseq fmt.instruction( "send", [fmt.calldata(calldata), block_iseq&.name || "nil"] ) end
def initialize(calldata, block_iseq)
def initialize(calldata, block_iseq) @calldata = calldata @block_iseq = block_iseq end
def length
def length 3 end
def pops
def pops argb = (calldata.flag?(CallData::CALL_ARGS_BLOCKARG) ? 1 : 0) argb + calldata.argc + 1 end
def pushes
def pushes 1 end
def to_a(_iseq)
def to_a(_iseq) [:send, calldata.to_h, block_iseq&.to_a] end