class SyntaxTree::YARV::OptNEq
### Summary
‘opt_neq` is an optimization that tests whether two values at the top of the stack are not equal by testing their equality and calling the `!` on the result. This allows `opt_neq` to use the fast paths optimized in `opt_eq` when both operands are Integers, Floats, Symbols
, or Strings. It pops both the receiver and the argument off the stack and pushes on the result.
### Usage
~~~ruby 2 != 2 ~~~
Attributes
eq_calldata[R]
neq_calldata[R]
Public Class Methods
new(eq_calldata, neq_calldata)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3776 def initialize(eq_calldata, neq_calldata) @eq_calldata = eq_calldata @neq_calldata = neq_calldata end
Public Instance Methods
==(other)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3796 def ==(other) other.is_a?(OptNEq) && other.eq_calldata == eq_calldata && other.neq_calldata == neq_calldata end
call(vm)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3813 def call(vm) receiver, argument = vm.pop(2) vm.push(receiver != argument) end
deconstruct_keys(_keys)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3792 def deconstruct_keys(_keys) { eq_calldata: eq_calldata, neq_calldata: neq_calldata } end
disasm(fmt)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3781 def disasm(fmt) fmt.instruction( "opt_neq", [fmt.calldata(eq_calldata), fmt.calldata(neq_calldata)] ) end
length()
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3801 def length 3 end
pops()
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3805 def pops 2 end
pushes()
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3809 def pushes 1 end
to_a(_iseq)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3788 def to_a(_iseq) [:opt_neq, eq_calldata.to_h, neq_calldata.to_h] end