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

Returns a new instance of OptGE.



3408
3409
3410
# File 'lib/syntax_tree/yarv/instructions.rb', line 3408

def initialize(calldata)
  @calldata = calldata
end

Instance Attribute Details

#calldataObject (readonly)

Returns the value of attribute calldata.



3406
3407
3408
# File 'lib/syntax_tree/yarv/instructions.rb', line 3406

def calldata
  @calldata
end

Instance Method Details

#==(other) ⇒ Object



3424
3425
3426
# File 'lib/syntax_tree/yarv/instructions.rb', line 3424

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

#call(vm) ⇒ Object



3444
3445
3446
# File 'lib/syntax_tree/yarv/instructions.rb', line 3444

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

#canonicalObject



3440
3441
3442
# File 'lib/syntax_tree/yarv/instructions.rb', line 3440

def canonical
  Send.new(calldata, nil)
end

#deconstruct_keys(_keys) ⇒ Object



3420
3421
3422
# File 'lib/syntax_tree/yarv/instructions.rb', line 3420

def deconstruct_keys(_keys)
  { calldata: calldata }
end

#disasm(fmt) ⇒ Object



3412
3413
3414
# File 'lib/syntax_tree/yarv/instructions.rb', line 3412

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

#lengthObject



3428
3429
3430
# File 'lib/syntax_tree/yarv/instructions.rb', line 3428

def length
  2
end

#popsObject



3432
3433
3434
# File 'lib/syntax_tree/yarv/instructions.rb', line 3432

def pops
  2
end

#pushesObject



3436
3437
3438
# File 'lib/syntax_tree/yarv/instructions.rb', line 3436

def pushes
  1
end

#to_a(_iseq) ⇒ Object



3416
3417
3418
# File 'lib/syntax_tree/yarv/instructions.rb', line 3416

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