Class: SyntaxTree::YARV::OptLT

Inherits:
Instruction 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

Methods inherited from Instruction

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

Constructor Details

#initialize(calldata) ⇒ OptLT

Returns a new instance of OptLT.



3430
3431
3432
# File 'lib/syntax_tree/yarv/instructions.rb', line 3430

def initialize(calldata)
  @calldata = calldata
end

Instance Attribute Details

#calldataObject (readonly)

Returns the value of attribute calldata.



3428
3429
3430
# File 'lib/syntax_tree/yarv/instructions.rb', line 3428

def calldata
  @calldata
end

Instance Method Details

#==(other) ⇒ Object



3446
3447
3448
# File 'lib/syntax_tree/yarv/instructions.rb', line 3446

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

#call(vm) ⇒ Object



3466
3467
3468
# File 'lib/syntax_tree/yarv/instructions.rb', line 3466

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

#canonicalObject



3462
3463
3464
# File 'lib/syntax_tree/yarv/instructions.rb', line 3462

def canonical
  Send.new(calldata, nil)
end

#deconstruct_keys(_keys) ⇒ Object



3442
3443
3444
# File 'lib/syntax_tree/yarv/instructions.rb', line 3442

def deconstruct_keys(_keys)
  { calldata: calldata }
end

#disasm(fmt) ⇒ Object



3434
3435
3436
# File 'lib/syntax_tree/yarv/instructions.rb', line 3434

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

#lengthObject



3450
3451
3452
# File 'lib/syntax_tree/yarv/instructions.rb', line 3450

def length
  2
end

#popsObject



3454
3455
3456
# File 'lib/syntax_tree/yarv/instructions.rb', line 3454

def pops
  2
end

#pushesObject



3458
3459
3460
# File 'lib/syntax_tree/yarv/instructions.rb', line 3458

def pushes
  1
end

#to_a(_iseq) ⇒ Object



3438
3439
3440
# File 'lib/syntax_tree/yarv/instructions.rb', line 3438

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