Class: SyntaxTree::YARV::Legacy::OptGetInlineCache
- Inherits:
-
Instruction
- Object
- Instruction
- SyntaxTree::YARV::Legacy::OptGetInlineCache
- Defined in:
- lib/syntax_tree/yarv/legacy.rb
Overview
### Summary
opt_getinlinecache is a wrapper around a series of putobject and getconstant instructions that allows skipping past them if the inline cache is currently set. It pushes the value of the cache onto the stack if it is set, otherwise it pushes nil.
This instruction is no longer used since in Ruby 3.2 it was replaced by the consolidated opt_getconstant_path instruction.
### Usage
~~~ruby Constant ~~~
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #branch_targets ⇒ Object
- #call(vm) ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
- #disasm(fmt) ⇒ Object
- #falls_through? ⇒ Boolean
-
#initialize(label, cache) ⇒ OptGetInlineCache
constructor
A new instance of OptGetInlineCache.
- #length ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Methods inherited from Instruction
#canonical, #leaves?, #pops, #side_effects?
Constructor Details
#initialize(label, cache) ⇒ OptGetInlineCache
Returns a new instance of OptGetInlineCache.
81 82 83 84 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 81 def initialize(label, cache) @label = label @cache = cache end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
79 80 81 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 79 def cache @cache end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
79 80 81 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 79 def label @label end |
Instance Method Details
#==(other) ⇒ Object
101 102 103 104 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 101 def ==(other) other.is_a?(OptGetInlineCache) && other.label == label && other.cache == cache end |
#branch_targets ⇒ Object
118 119 120 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 118 def branch_targets [label] end |
#call(vm) ⇒ Object
114 115 116 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 114 def call(vm) vm.push(nil) end |
#deconstruct_keys(_keys) ⇒ Object
97 98 99 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 97 def deconstruct_keys(_keys) { label: label, cache: cache } end |
#disasm(fmt) ⇒ Object
86 87 88 89 90 91 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 86 def disasm(fmt) fmt.instruction( "opt_getinlinecache", [fmt.label(label), fmt.inline_storage(cache)] ) end |
#falls_through? ⇒ Boolean
122 123 124 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 122 def falls_through? true end |
#length ⇒ Object
106 107 108 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 106 def length 3 end |
#pushes ⇒ Object
110 111 112 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 110 def pushes 1 end |
#to_a(_iseq) ⇒ Object
93 94 95 |
# File 'lib/syntax_tree/yarv/legacy.rb', line 93 def to_a(_iseq) [:opt_getinlinecache, label.name, cache] end |