Class: SyntaxTree::YARV::Legacy::SetClassVariable
- Inherits:
-
Instruction
- Object
- Instruction
- SyntaxTree::YARV::Legacy::SetClassVariable
- Defined in:
- lib/syntax_tree/yarv/legacy.rb
Overview
### 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 ~~~
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(name) ⇒ SetClassVariable
constructor
A new instance of SetClassVariable.
- #length ⇒ Object
- #pops ⇒ Object
- #to_a(_iseq) ⇒ Object
Methods inherited from Instruction
#branch_targets, #falls_through?, #leaves?, #pushes, #side_effects?
Constructor Details
#initialize(name) ⇒ SetClassVariable
Returns a new instance of SetClassVariable.
302 303 304 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 302 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
300 301 302 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 300 def name @name end |
Instance Method Details
#==(other) ⇒ Object
318 319 320 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 318 def ==(other) other.is_a?(SetClassVariable) && other.name == name end |
#call(vm) ⇒ Object
334 335 336 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 334 def call(vm) canonical.call(vm) end |
#canonical ⇒ Object
330 331 332 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 330 def canonical YARV::SetClassVariable.new(name, nil) end |
#deconstruct_keys(_keys) ⇒ Object
314 315 316 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 314 def deconstruct_keys(_keys) { name: name } end |
#disasm(fmt) ⇒ Object
306 307 308 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 306 def disasm(fmt) fmt.instruction("setclassvariable", [fmt.object(name)]) end |
#length ⇒ Object
322 323 324 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 322 def length 2 end |
#pops ⇒ Object
326 327 328 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 326 def pops 1 end |
#to_a(_iseq) ⇒ Object
310 311 312 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 310 def to_a(_iseq) [:setclassvariable, name] end |