class SyntaxTree::YARV::InvokeSuper
### Summary
‘invokesuper` is similar to the `send` instruction, except that it calls the super method. It pops the receiver and arguments off the stack and pushes the return value onto the stack.
### Usage
~~~ruby def foo
super
end ~~~
Attributes
block_iseq[R]
calldata[R]
Public Class Methods
new(calldata, block_iseq)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 2143 def initialize(calldata, block_iseq) @calldata = calldata @block_iseq = block_iseq end
Public Instance Methods
==(other)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 2164 def ==(other) other.is_a?(InvokeSuper) && other.calldata == calldata && other.block_iseq == block_iseq end
call(vm)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 2178 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 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 method = receiver.method(vm.frame.name).super_method vm.push(method.call(*arguments, **keywords, &block)) end
deconstruct_keys(_keys)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 2160 def deconstruct_keys(_keys) { calldata: calldata, block_iseq: block_iseq } end
disasm(fmt)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 2148 def disasm(fmt) fmt.enqueue(block_iseq) if block_iseq fmt.instruction( "invokesuper", [fmt.calldata(calldata), block_iseq&.name || "nil"] ) end
pops()
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 2169 def pops argb = (calldata.flag?(CallData::CALL_ARGS_BLOCKARG) ? 1 : 0) argb + calldata.argc + 1 end
pushes()
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 2174 def pushes 1 end
to_a(_iseq)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 2156 def to_a(_iseq) [:invokesuper, calldata.to_h, block_iseq&.to_a] end