class SyntaxTree::YARV::GetBlockParam
### Summary
‘getblockparam` is a similar instruction to `getlocal` in that it looks for a local variable in the current instruction sequence’s local table and walks recursively up the parent instruction sequences until it finds it. The local it retrieves, however, is a special block local that was passed to the current method. It pushes the value of the block local onto the stack.
### Usage
~~~ruby def foo(&block)
block
end ~~~
Attributes
Public Class Methods
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1542 def initialize(index, level) @index = index @level = level end
Public Instance Methods
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1561 def ==(other) other.is_a?(GetBlockParam) && other.index == index && other.level == level end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1574 def call(vm) vm.push(vm.local_get(index, level)) end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1557 def deconstruct_keys(_keys) { index: index, level: level } end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1547 def disasm(fmt) fmt.instruction("getblockparam", [fmt.local(index, explicit: level)]) end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1551 def to_a(iseq) current = iseq level.times { current = iseq.parent_iseq } [:getblockparam, current.local_table.offset(index), level] end