class SyntaxTree::YARV::SetLocalWC1

### Summary

‘setlocal_WC_1` is a specialized version of the `setlocal` instruction. It sets the value of a local variable on the parent frame to the value at the top of the stack as determined by the index given as its only argument.

### Usage

~~~ruby value = 5 self.then { value = 10 } ~~~

Attributes

index[R]

Public Class Methods

new(index) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5278
def initialize(index)
  @index = index
end

Public Instance Methods

==(other) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5294
def ==(other)
  other.is_a?(SetLocalWC1) && other.index == index
end
call(vm) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5310
def call(vm)
  canonical.call(vm)
end
canonical() click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5306
def canonical
  SetLocal.new(index, 1)
end
deconstruct_keys(_keys) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5290
def deconstruct_keys(_keys)
  { index: index }
end
disasm(fmt) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5282
def disasm(fmt)
  fmt.instruction("setlocal_WC_1", [fmt.local(index, implicit: 1)])
end
length() click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5298
def length
  2
end
pops() click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5302
def pops
  1
end
to_a(iseq) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5286
def to_a(iseq)
  [:setlocal_WC_1, iseq.parent_iseq.local_table.offset(index)]
end