class SyntaxTree::YARV::SetLocal
### Summary
‘setlocal` sets the value of a 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 value = 5 tap { tap { value = 10 } } ~~~
Attributes
Public Class Methods
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5320 def initialize(index, level) @index = index @level = level end
Public Instance Methods
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5339 def ==(other) other.is_a?(SetLocal) && other.index == index && other.level == level end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5351 def call(vm) vm.local_set(index, level, vm.pop) end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5335 def deconstruct_keys(_keys) { index: index, level: level } end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5325 def disasm(fmt) fmt.instruction("setlocal", [fmt.local(index, explicit: level)]) end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5329 def to_a(iseq) current = iseq level.times { current = current.parent_iseq } [:setlocal, current.local_table.offset(index), level] end