class SyntaxTree::YARV::OptNilP

### Summary

‘opt_nil_p` is an optimization applied when the method `nil?` is called. It returns true immediately when the receiver is `nil` and defers to the `nil?` method in other cases. It pops the receiver off the stack and pushes on the result.

### Usage

~~~ruby “”.nil? ~~~

Attributes

calldata[R]

Public Class Methods

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

Public Instance Methods

==(other) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3909
def ==(other)
  other.is_a?(OptNilP) && other.calldata == calldata
end
call(vm) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3929
def call(vm)
  canonical.call(vm)
end
canonical() click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3925
def canonical
  Send.new(calldata, nil)
end
deconstruct_keys(_keys) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3905
def deconstruct_keys(_keys)
  { calldata: calldata }
end
disasm(fmt) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3897
def disasm(fmt)
  fmt.instruction("opt_nil_p", [fmt.calldata(calldata)])
end
length() click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3913
def length
  2
end
pops() click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3917
def pops
  1
end
pushes() click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3921
def pushes
  1
end
to_a(_iseq) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3901
def to_a(_iseq)
  [:opt_nil_p, calldata.to_h]
end