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
index[R]
level[R]
Public Class Methods
new(index, level)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1489 def initialize(index, level) @index = index @level = level end
Public Instance Methods
==(other)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1508 def ==(other) other.is_a?(GetBlockParam) && other.index == index && other.level == level end
call(vm)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1521 def call(vm) vm.push(vm.local_get(index, level)) end
deconstruct_keys(_keys)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1504 def deconstruct_keys(_keys) { index: index, level: level } end
disasm(fmt)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1494 def disasm(fmt) fmt.instruction("getblockparam", [fmt.local(index, explicit: level)]) end
length()
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1513 def length 3 end
pushes()
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1517 def pushes 1 end
to_a(iseq)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1498 def to_a(iseq) current = iseq level.times { current = iseq.parent_iseq } [:getblockparam, current.local_table.offset(index), level] end