class SyntaxTree::YARV::SetInstanceVariable
### Summary
‘setinstancevariable` pops a value off the top of the stack and then sets the instance variable associated with the instruction to that value.
This instruction has two forms, but both have the same structure. Before Ruby 3.2, the inline cache corresponded to both the get and set instructions and could be shared. Since Ruby 3.2, it uses object shapes instead so the caches are unique per instruction.
### Usage
~~~ruby @instance_variable = 1 ~~~
Attributes
cache[R]
name[R]
Public Class Methods
new(name, cache)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5117 def initialize(name, cache) @name = name @cache = cache end
Public Instance Methods
==(other)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5137 def ==(other) other.is_a?(SetInstanceVariable) && other.name == name && other.cache == cache end
call(vm)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5150 def call(vm) method = Object.instance_method(:instance_variable_set) method.bind(vm.frame._self).call(name, vm.pop) end
deconstruct_keys(_keys)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5133 def deconstruct_keys(_keys) { name: name, cache: cache } end
disasm(fmt)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5122 def disasm(fmt) fmt.instruction( "setinstancevariable", [fmt.object(name), fmt.inline_storage(cache)] ) end
length()
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5142 def length 3 end
pops()
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5146 def pops 1 end
to_a(_iseq)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5129 def to_a(_iseq) [:setinstancevariable, name, cache] end