Class: SyntaxTree::YARV::OptGE

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

Methods inherited from Instruction

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

Constructor Details

#initialize(calldata) ⇒ OptGE

Returns a new instance of OptGE.



3204
3205
3206
# File 'lib/syntax_tree/yarv/instructions.rb', line 3204

def initialize(calldata)
  @calldata = calldata
end

Instance Attribute Details

#calldataObject (readonly)

Returns the value of attribute calldata.



3202
3203
3204
# File 'lib/syntax_tree/yarv/instructions.rb', line 3202

def calldata
  @calldata
end

Instance Method Details

#==(other) ⇒ Object



3220
3221
3222
# File 'lib/syntax_tree/yarv/instructions.rb', line 3220

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

#call(vm) ⇒ Object



3240
3241
3242
# File 'lib/syntax_tree/yarv/instructions.rb', line 3240

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

#canonicalObject



3236
3237
3238
# File 'lib/syntax_tree/yarv/instructions.rb', line 3236

def canonical
  Send.new(calldata, nil)
end

#deconstruct_keys(_keys) ⇒ Object



3216
3217
3218
# File 'lib/syntax_tree/yarv/instructions.rb', line 3216

def deconstruct_keys(_keys)
  { calldata: calldata }
end

#disasm(fmt) ⇒ Object



3208
3209
3210
# File 'lib/syntax_tree/yarv/instructions.rb', line 3208

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

#lengthObject



3224
3225
3226
# File 'lib/syntax_tree/yarv/instructions.rb', line 3224

def length
  2
end

#popsObject



3228
3229
3230
# File 'lib/syntax_tree/yarv/instructions.rb', line 3228

def pops
  2
end

#pushesObject



3232
3233
3234
# File 'lib/syntax_tree/yarv/instructions.rb', line 3232

def pushes
  1
end

#to_a(_iseq) ⇒ Object



3212
3213
3214
# File 'lib/syntax_tree/yarv/instructions.rb', line 3212

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