class SyntaxTree::YARV::SetBlockParam

### Summary

‘setblockparam` sets the value of a block local variable on a frame determined by the level and index arguments. The level is the number of frames back to look and the index is the index in the local table. It pops the value it is setting off the stack.

### Usage

~~~ruby def foo(&bar)

bar = baz

end ~~~

Attributes

index[R]
level[R]

Public Class Methods

new(index, level) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 4908
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 4927
def ==(other)
  other.is_a?(SetBlockParam) && other.index == index &&
    other.level == level
end
call(vm) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 4940
def call(vm)
  vm.local_set(index, level, vm.pop)
end
deconstruct_keys(_keys) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 4923
def deconstruct_keys(_keys)
  { index: index, level: level }
end
disasm(fmt) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 4913
def disasm(fmt)
  fmt.instruction("setblockparam", [fmt.local(index, explicit: level)])
end
length() click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 4932
def length
  3
end
pops() click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 4936
def pops
  1
end
to_a(iseq) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 4917
def to_a(iseq)
  current = iseq
  level.times { current = current.parent_iseq }
  [:setblockparam, current.local_table.offset(index), level]
end