class SyntaxTree::YARV::GetLocal
### Summary
‘getlocal` fetches the value of a local variable from 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 pushes the value it finds onto the stack.
### Usage
~~~ruby value = 5 tap { tap { value } } ~~~
Attributes
Public Class Methods
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1884 def initialize(index, level) @index = index @level = level end
Public Instance Methods
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1903 def ==(other) other.is_a?(GetLocal) && other.index == index && other.level == level end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1915 def call(vm) vm.push(vm.local_get(index, level)) end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1899 def deconstruct_keys(_keys) { index: index, level: level } end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1889 def disasm(fmt) fmt.instruction("getlocal", [fmt.local(index, explicit: level)]) end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1893 def to_a(iseq) current = iseq level.times { current = current.parent_iseq } [:getlocal, current.local_table.offset(index), level] end