Class: SyntaxTree::YARV::OptNot

Inherits:
Instruction show all
Defined in:
lib/syntax_tree/yarv/instructions.rb

Overview

### Summary

opt_not negates the value on top of the stack by calling the ‘!` method on it. It pops the receiver off the stack and pushes on the result.

### Usage

~~~ruby !true ~~~

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Instruction

#branch_targets, #falls_through?, #leaves?, #side_effects?

Constructor Details

#initialize(calldata) ⇒ OptNot



3994
3995
3996
# File 'lib/syntax_tree/yarv/instructions.rb', line 3994

def initialize(calldata)
  @calldata = calldata
end

Instance Attribute Details

#calldataObject (readonly)

Returns the value of attribute calldata.



3992
3993
3994
# File 'lib/syntax_tree/yarv/instructions.rb', line 3992

def calldata
  @calldata
end

Instance Method Details

#==(other) ⇒ Object



4010
4011
4012
# File 'lib/syntax_tree/yarv/instructions.rb', line 4010

def ==(other)
  other.is_a?(OptNot) && other.calldata == calldata
end

#call(vm) ⇒ Object



4030
4031
4032
# File 'lib/syntax_tree/yarv/instructions.rb', line 4030

def call(vm)
  canonical.call(vm)
end

#canonicalObject



4026
4027
4028
# File 'lib/syntax_tree/yarv/instructions.rb', line 4026

def canonical
  Send.new(calldata, nil)
end

#deconstruct_keys(_keys) ⇒ Object



4006
4007
4008
# File 'lib/syntax_tree/yarv/instructions.rb', line 4006

def deconstruct_keys(_keys)
  { calldata: calldata }
end

#disasm(fmt) ⇒ Object



3998
3999
4000
# File 'lib/syntax_tree/yarv/instructions.rb', line 3998

def disasm(fmt)
  fmt.instruction("opt_not", [fmt.calldata(calldata)])
end

#lengthObject



4014
4015
4016
# File 'lib/syntax_tree/yarv/instructions.rb', line 4014

def length
  2
end

#popsObject



4018
4019
4020
# File 'lib/syntax_tree/yarv/instructions.rb', line 4018

def pops
  1
end

#pushesObject



4022
4023
4024
# File 'lib/syntax_tree/yarv/instructions.rb', line 4022

def pushes
  1
end

#to_a(_iseq) ⇒ Object



4002
4003
4004
# File 'lib/syntax_tree/yarv/instructions.rb', line 4002

def to_a(_iseq)
  [:opt_not, calldata.to_h]
end