Class: SyntaxTree::YARV::Legacy::SetClassVariable
- Inherits:
-
Object
- Object
- 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
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(name) ⇒ SetClassVariable
constructor
A new instance of SetClassVariable.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(name) ⇒ SetClassVariable
Returns a new instance of SetClassVariable.
181 182 183 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 181 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
179 180 181 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 179 def name @name end |
Instance Method Details
#call(vm) ⇒ Object
209 210 211 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 209 def call(vm) canonical.call(vm) end |
#canonical ⇒ Object
205 206 207 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 205 def canonical YARV::SetClassVariable.new(name, nil) end |
#disasm(fmt) ⇒ Object
185 186 187 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 185 def disasm(fmt) fmt.instruction("setclassvariable", [fmt.object(name)]) end |
#length ⇒ Object
193 194 195 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 193 def length 2 end |
#pops ⇒ Object
197 198 199 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 197 def pops 1 end |
#pushes ⇒ Object
201 202 203 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 201 def pushes 0 end |
#to_a(_iseq) ⇒ Object
189 190 191 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 189 def to_a(_iseq) [:setclassvariable, name] end |