class SyntaxTree::YARV::DefinedIVar

### Summary

‘definedivar` checks if an instance variable is defined. It is a specialization of the `defined` instruction. It accepts three arguments: the name of the instance variable, an inline cache, and the string that should be pushed onto the stack in the event that the instance variable is defined.

### Usage

~~~ruby defined?(@value) ~~~

Attributes

cache[R]
message[R]
name[R]

Public Class Methods

new(name, cache, message) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1014
def initialize(name, cache, message)
  @name = name
  @cache = cache
  @message = message
end

Public Instance Methods

==(other) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1035
def ==(other)
  other.is_a?(DefinedIVar) && other.name == name &&
    other.cache == cache && other.message == message
end
call(vm) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1048
def call(vm)
  result = (message if vm.frame._self.instance_variable_defined?(name))

  vm.push(result)
end
deconstruct_keys(_keys) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1031
def deconstruct_keys(_keys)
  { name: name, cache: cache, message: message }
end
disasm(fmt) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1020
def disasm(fmt)
  fmt.instruction(
    "definedivar",
    [fmt.object(name), fmt.inline_storage(cache), fmt.object(message)]
  )
end
length() click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1040
def length
  4
end
pushes() click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1044
def pushes
  1
end
to_a(_iseq) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1027
def to_a(_iseq)
  [:definedivar, name, cache, message]
end