Class: SyntaxTree::YARV::OptNot

Inherits:
Object
  • Object
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

Constructor Details

#initialize(calldata) ⇒ OptNot

Returns a new instance of OptNot.



3689
3690
3691
# File 'lib/syntax_tree/yarv/instructions.rb', line 3689

def initialize(calldata)
  @calldata = calldata
end

Instance Attribute Details

#calldataObject (readonly)

Returns the value of attribute calldata.



3687
3688
3689
# File 'lib/syntax_tree/yarv/instructions.rb', line 3687

def calldata
  @calldata
end

Instance Method Details

#call(vm) ⇒ Object



3717
3718
3719
# File 'lib/syntax_tree/yarv/instructions.rb', line 3717

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

#canonicalObject



3713
3714
3715
# File 'lib/syntax_tree/yarv/instructions.rb', line 3713

def canonical
  Send.new(calldata, nil)
end

#disasm(fmt) ⇒ Object



3693
3694
3695
# File 'lib/syntax_tree/yarv/instructions.rb', line 3693

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

#lengthObject



3701
3702
3703
# File 'lib/syntax_tree/yarv/instructions.rb', line 3701

def length
  2
end

#popsObject



3705
3706
3707
# File 'lib/syntax_tree/yarv/instructions.rb', line 3705

def pops
  1
end

#pushesObject



3709
3710
3711
# File 'lib/syntax_tree/yarv/instructions.rb', line 3709

def pushes
  1
end

#to_a(_iseq) ⇒ Object



3697
3698
3699
# File 'lib/syntax_tree/yarv/instructions.rb', line 3697

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