Class: SyntaxTree::YARV::OptLT

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

Overview

### Summary

opt_lt 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) ⇒ OptLT



3244
3245
3246
# File 'lib/syntax_tree/yarv/instructions.rb', line 3244

def initialize(calldata)
  @calldata = calldata
end

Instance Attribute Details

#calldataObject (readonly)

Returns the value of attribute calldata.



3242
3243
3244
# File 'lib/syntax_tree/yarv/instructions.rb', line 3242

def calldata
  @calldata
end

Instance Method Details

#call(vm) ⇒ Object



3272
3273
3274
# File 'lib/syntax_tree/yarv/instructions.rb', line 3272

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

#canonicalObject



3268
3269
3270
# File 'lib/syntax_tree/yarv/instructions.rb', line 3268

def canonical
  Send.new(calldata, nil)
end

#disasm(fmt) ⇒ Object



3248
3249
3250
# File 'lib/syntax_tree/yarv/instructions.rb', line 3248

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

#lengthObject



3256
3257
3258
# File 'lib/syntax_tree/yarv/instructions.rb', line 3256

def length
  2
end

#popsObject



3260
3261
3262
# File 'lib/syntax_tree/yarv/instructions.rb', line 3260

def pops
  2
end

#pushesObject



3264
3265
3266
# File 'lib/syntax_tree/yarv/instructions.rb', line 3264

def pushes
  1
end

#to_a(_iseq) ⇒ Object



3252
3253
3254
# File 'lib/syntax_tree/yarv/instructions.rb', line 3252

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