Class: SyntaxTree::YARV::OptLT

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

Overview

### Summary

opt_lt is a specialization of the opt_send_without_block instruction that occurs when the < operator is used. Fast paths exist when both operands are integers or floats. It pops both the receiver and the argument off the stack and pushes on the result.

### Usage

~~~ruby 3 < 4 ~~~

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(calldata) ⇒ OptLT

Returns a new instance of OptLT.



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

def initialize(calldata)
  @calldata = calldata
end

Instance Attribute Details

#calldataObject (readonly)

Returns the value of attribute calldata.



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

def calldata
  @calldata
end

Instance Method Details

#==(other) ⇒ Object



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

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

#call(vm) ⇒ Object



3736
3737
3738
# File 'lib/syntax_tree/yarv/instructions.rb', line 3736

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

#canonicalObject



3732
3733
3734
# File 'lib/syntax_tree/yarv/instructions.rb', line 3732

def canonical
  Send.new(calldata, nil)
end

#deconstruct_keys(_keys) ⇒ Object



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

def deconstruct_keys(_keys)
  { calldata: calldata }
end

#disasm(fmt) ⇒ Object



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

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

#lengthObject



3720
3721
3722
# File 'lib/syntax_tree/yarv/instructions.rb', line 3720

def length
  2
end

#popsObject



3724
3725
3726
# File 'lib/syntax_tree/yarv/instructions.rb', line 3724

def pops
  2
end

#pushesObject



3728
3729
3730
# File 'lib/syntax_tree/yarv/instructions.rb', line 3728

def pushes
  1
end

#to_a(_iseq) ⇒ Object



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

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