Class: SyntaxTree::YARV::OptGE

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

Overview

### Summary

opt_ge 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 4 >= 3 ~~~

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(calldata) ⇒ OptGE



2992
2993
2994
# File 'lib/syntax_tree/yarv/instructions.rb', line 2992

def initialize(calldata)
  @calldata = calldata
end

Instance Attribute Details

#calldataObject (readonly)

Returns the value of attribute calldata.



2990
2991
2992
# File 'lib/syntax_tree/yarv/instructions.rb', line 2990

def calldata
  @calldata
end

Instance Method Details

#call(vm) ⇒ Object



3020
3021
3022
# File 'lib/syntax_tree/yarv/instructions.rb', line 3020

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

#canonicalObject



3016
3017
3018
# File 'lib/syntax_tree/yarv/instructions.rb', line 3016

def canonical
  Send.new(calldata, nil)
end

#disasm(fmt) ⇒ Object



2996
2997
2998
# File 'lib/syntax_tree/yarv/instructions.rb', line 2996

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

#lengthObject



3004
3005
3006
# File 'lib/syntax_tree/yarv/instructions.rb', line 3004

def length
  2
end

#popsObject



3008
3009
3010
# File 'lib/syntax_tree/yarv/instructions.rb', line 3008

def pops
  2
end

#pushesObject



3012
3013
3014
# File 'lib/syntax_tree/yarv/instructions.rb', line 3012

def pushes
  1
end

#to_a(_iseq) ⇒ Object



3000
3001
3002
# File 'lib/syntax_tree/yarv/instructions.rb', line 3000

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