Class: SyntaxTree::YARV::OptLE

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

Overview

### Summary

‘opt_le` 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) ⇒ OptLE

Returns a new instance of OptLE.



3316
3317
3318
# File 'lib/syntax_tree/yarv/instructions.rb', line 3316

def initialize(calldata)
  @calldata = calldata
end

Instance Attribute Details

#calldataObject (readonly)

Returns the value of attribute calldata.



3314
3315
3316
# File 'lib/syntax_tree/yarv/instructions.rb', line 3314

def calldata
  @calldata
end

Instance Method Details

#==(other) ⇒ Object



3332
3333
3334
# File 'lib/syntax_tree/yarv/instructions.rb', line 3332

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

#call(vm) ⇒ Object



3352
3353
3354
# File 'lib/syntax_tree/yarv/instructions.rb', line 3352

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

#canonicalObject



3348
3349
3350
# File 'lib/syntax_tree/yarv/instructions.rb', line 3348

def canonical
  Send.new(calldata, nil)
end

#deconstruct_keys(_keys) ⇒ Object



3328
3329
3330
# File 'lib/syntax_tree/yarv/instructions.rb', line 3328

def deconstruct_keys(_keys)
  { calldata: calldata }
end

#disasm(fmt) ⇒ Object



3320
3321
3322
# File 'lib/syntax_tree/yarv/instructions.rb', line 3320

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

#lengthObject



3336
3337
3338
# File 'lib/syntax_tree/yarv/instructions.rb', line 3336

def length
  2
end

#popsObject



3340
3341
3342
# File 'lib/syntax_tree/yarv/instructions.rb', line 3340

def pops
  2
end

#pushesObject



3344
3345
3346
# File 'lib/syntax_tree/yarv/instructions.rb', line 3344

def pushes
  1
end

#to_a(_iseq) ⇒ Object



3324
3325
3326
# File 'lib/syntax_tree/yarv/instructions.rb', line 3324

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