class SyntaxTree::YARV::SetSpecial

### Summary

‘setspecial` pops a value off the top of the stack and sets a special local variable to that value. The special local variable is determined by the key given as its only argument.

### Usage

~~~ruby baz if (foo == 1) .. (bar == 1) ~~~

Attributes

key[R]

Public Class Methods

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

Public Instance Methods

==(other) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5397
def ==(other)
  other.is_a?(SetSpecial) && other.key == key
end
call(vm) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5409
def call(vm)
  case key
  when GetSpecial::SVAR_LASTLINE
    raise NotImplementedError, "setspecial SVAR_LASTLINE"
  when GetSpecial::SVAR_BACKREF
    raise NotImplementedError, "setspecial SVAR_BACKREF"
  when GetSpecial::SVAR_FLIPFLOP_START
    vm.frame_svar.svars[GetSpecial::SVAR_FLIPFLOP_START]
  end
end
deconstruct_keys(_keys) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5393
def deconstruct_keys(_keys)
  { key: key }
end
disasm(fmt) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5385
def disasm(fmt)
  fmt.instruction("setspecial", [fmt.object(key)])
end
length() click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5401
def length
  2
end
pops() click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5405
def pops
  1
end
to_a(_iseq) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5389
def to_a(_iseq)
  [:setspecial, key]
end