class SyntaxTree::YARV::Legacy::SetClassVariable
### Summary
‘setclassvariable` looks for a class variable in the current class and sets its value to the value it pops off the top of the stack.
This version of the ‘setclassvariable` instruction is no longer used since in Ruby 3.0 it gained an inline cache.
### Usage
~~~ruby @@class_variable = 1 ~~~
Attributes
name[R]
Public Class Methods
new(name)
click to toggle source
# File lib/syntax_tree/yarv/legacy.rb, line 302 def initialize(name) @name = name end
Public Instance Methods
==(other)
click to toggle source
# File lib/syntax_tree/yarv/legacy.rb, line 318 def ==(other) other.is_a?(SetClassVariable) && other.name == name end
call(vm)
click to toggle source
# File lib/syntax_tree/yarv/legacy.rb, line 334 def call(vm) canonical.call(vm) end
canonical()
click to toggle source
# File lib/syntax_tree/yarv/legacy.rb, line 330 def canonical YARV::SetClassVariable.new(name, nil) end
deconstruct_keys(_keys)
click to toggle source
# File lib/syntax_tree/yarv/legacy.rb, line 314 def deconstruct_keys(_keys) { name: name } end
disasm(fmt)
click to toggle source
# File lib/syntax_tree/yarv/legacy.rb, line 306 def disasm(fmt) fmt.instruction("setclassvariable", [fmt.object(name)]) end
length()
click to toggle source
# File lib/syntax_tree/yarv/legacy.rb, line 322 def length 2 end
pops()
click to toggle source
# File lib/syntax_tree/yarv/legacy.rb, line 326 def pops 1 end
to_a(_iseq)
click to toggle source
# File lib/syntax_tree/yarv/legacy.rb, line 310 def to_a(_iseq) [:setclassvariable, name] end