Class: SyntaxTree::YARV::Legacy::OptSetInlineCache

Inherits:
Instruction
  • Object
show all
Defined in:
lib/syntax_tree/yarv/legacy.rb

Overview

### Summary

‘opt_setinlinecache` sets an inline cache for a constant lookup. It pops the value it should set off the top of the stack. It uses this value to set the cache. It then pushes that value back onto the top of the stack.

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

Methods inherited from Instruction

#branch_targets, #canonical, #falls_through?, #leaves?, #side_effects?

Constructor Details

#initialize(cache) ⇒ OptSetInlineCache

Returns a new instance of OptSetInlineCache.



249
250
251
# File 'lib/syntax_tree/yarv/legacy.rb', line 249

def initialize(cache)
  @cache = cache
end

Instance Attribute Details

#cacheObject (readonly)

Returns the value of attribute cache.



247
248
249
# File 'lib/syntax_tree/yarv/legacy.rb', line 247

def cache
  @cache
end

Instance Method Details

#==(other) ⇒ Object



265
266
267
# File 'lib/syntax_tree/yarv/legacy.rb', line 265

def ==(other)
  other.is_a?(OptSetInlineCache) && other.cache == cache
end

#call(vm) ⇒ Object



281
282
# File 'lib/syntax_tree/yarv/legacy.rb', line 281

def call(vm)
end

#deconstruct_keys(_keys) ⇒ Object



261
262
263
# File 'lib/syntax_tree/yarv/legacy.rb', line 261

def deconstruct_keys(_keys)
  { cache: cache }
end

#disasm(fmt) ⇒ Object



253
254
255
# File 'lib/syntax_tree/yarv/legacy.rb', line 253

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

#lengthObject



269
270
271
# File 'lib/syntax_tree/yarv/legacy.rb', line 269

def length
  2
end

#popsObject



273
274
275
# File 'lib/syntax_tree/yarv/legacy.rb', line 273

def pops
  1
end

#pushesObject



277
278
279
# File 'lib/syntax_tree/yarv/legacy.rb', line 277

def pushes
  1
end

#to_a(_iseq) ⇒ Object



257
258
259
# File 'lib/syntax_tree/yarv/legacy.rb', line 257

def to_a(_iseq)
  [:opt_setinlinecache, cache]
end