Class: SyntaxTree::YARV::OptLE

Inherits:
Object
  • Object
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

Constructor Details

#initialize(calldata) ⇒ OptLE

Returns a new instance of OptLE.



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

#call(vm) ⇒ Object



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

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

#canonicalObject



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

def canonical
  Send.new(calldata, nil)
end

#disasm(fmt) ⇒ Object



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

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

#lengthObject



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

def length
  2
end

#popsObject



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

def pops
  2
end

#pushesObject



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

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_le, calldata.to_h]
end