Class: SyntaxTree::YARV::Legacy::OptGetInlineCache

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(label, cache) ⇒ OptGetInlineCache

Returns a new instance of OptGetInlineCache.



77
78
79
80
# File 'lib/syntax_tree/yarv/legacy.rb', line 77

def initialize(label, cache)
  @label = label
  @cache = cache
end

Instance Attribute Details

#cacheObject (readonly)

Returns the value of attribute cache.



75
76
77
# File 'lib/syntax_tree/yarv/legacy.rb', line 75

def cache
  @cache
end

#labelObject (readonly)

Returns the value of attribute label.



75
76
77
# File 'lib/syntax_tree/yarv/legacy.rb', line 75

def label
  @label
end

Instance Method Details

#call(vm) ⇒ Object



109
110
111
# File 'lib/syntax_tree/yarv/legacy.rb', line 109

def call(vm)
  vm.push(nil)
end

#canonicalObject



105
106
107
# File 'lib/syntax_tree/yarv/legacy.rb', line 105

def canonical
  self
end

#disasm(fmt) ⇒ Object



82
83
84
85
86
87
# File 'lib/syntax_tree/yarv/legacy.rb', line 82

def disasm(fmt)
  fmt.instruction(
    "opt_getinlinecache",
    [fmt.label(label), fmt.inline_storage(cache)]
  )
end

#lengthObject



93
94
95
# File 'lib/syntax_tree/yarv/legacy.rb', line 93

def length
  3
end

#popsObject



97
98
99
# File 'lib/syntax_tree/yarv/legacy.rb', line 97

def pops
  0
end

#pushesObject



101
102
103
# File 'lib/syntax_tree/yarv/legacy.rb', line 101

def pushes
  1
end

#to_a(_iseq) ⇒ Object



89
90
91
# File 'lib/syntax_tree/yarv/legacy.rb', line 89

def to_a(_iseq)
  [:opt_getinlinecache, label.name, cache]
end