class SyntaxTree::YARV::GetClassVariable
### Summary
‘getclassvariable` looks for a class variable in the current class and pushes its value onto the stack. It uses an inline cache to reduce the need to lookup the class variable in the class hierarchy every time.
### Usage
~~~ruby @@class_variable ~~~
Attributes
Public Class Methods
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1652 def initialize(name, cache) @name = name @cache = cache end
Public Instance Methods
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1672 def ==(other) other.is_a?(GetClassVariable) && other.name == name && other.cache == cache end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1685 def call(vm) clazz = vm.frame._self clazz = clazz.class unless clazz.is_a?(Class) vm.push(clazz.class_variable_get(name)) end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1668 def deconstruct_keys(_keys) { name: name, cache: cache } end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1657 def disasm(fmt) fmt.instruction( "getclassvariable", [fmt.object(name), fmt.inline_storage(cache)] ) end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1664 def to_a(_iseq) [:getclassvariable, name, cache] end