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.



3146
3147
3148
# File 'lib/syntax_tree/yarv/instructions.rb', line 3146

def initialize(calldata)
  @calldata = calldata
end

Instance Attribute Details

#calldataObject (readonly)

Returns the value of attribute calldata.



3144
3145
3146
# File 'lib/syntax_tree/yarv/instructions.rb', line 3144

def calldata
  @calldata
end

Instance Method Details

#==(other) ⇒ Object



3162
3163
3164
# File 'lib/syntax_tree/yarv/instructions.rb', line 3162

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

#call(vm) ⇒ Object



3182
3183
3184
# File 'lib/syntax_tree/yarv/instructions.rb', line 3182

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

#canonicalObject



3178
3179
3180
# File 'lib/syntax_tree/yarv/instructions.rb', line 3178

def canonical
  Send.new(calldata, nil)
end

#deconstruct_keys(_keys) ⇒ Object



3158
3159
3160
# File 'lib/syntax_tree/yarv/instructions.rb', line 3158

def deconstruct_keys(_keys)
  { calldata: calldata }
end

#disasm(fmt) ⇒ Object



3150
3151
3152
# File 'lib/syntax_tree/yarv/instructions.rb', line 3150

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

#lengthObject



3166
3167
3168
# File 'lib/syntax_tree/yarv/instructions.rb', line 3166

def length
  2
end

#popsObject



3170
3171
3172
# File 'lib/syntax_tree/yarv/instructions.rb', line 3170

def pops
  2
end

#pushesObject



3174
3175
3176
# File 'lib/syntax_tree/yarv/instructions.rb', line 3174

def pushes
  1
end

#to_a(_iseq) ⇒ Object



3154
3155
3156
# File 'lib/syntax_tree/yarv/instructions.rb', line 3154

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