Class: SyntaxTree::YARV::OptGT

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

Overview

### Summary

‘opt_gt` 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) ⇒ OptGT

Returns a new instance of OptGT.



3317
3318
3319
# File 'lib/syntax_tree/yarv/instructions.rb', line 3317

def initialize(calldata)
  @calldata = calldata
end

Instance Attribute Details

#calldataObject (readonly)

Returns the value of attribute calldata.



3315
3316
3317
# File 'lib/syntax_tree/yarv/instructions.rb', line 3315

def calldata
  @calldata
end

Instance Method Details

#==(other) ⇒ Object



3333
3334
3335
# File 'lib/syntax_tree/yarv/instructions.rb', line 3333

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

#call(vm) ⇒ Object



3353
3354
3355
# File 'lib/syntax_tree/yarv/instructions.rb', line 3353

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

#canonicalObject



3349
3350
3351
# File 'lib/syntax_tree/yarv/instructions.rb', line 3349

def canonical
  Send.new(calldata, nil)
end

#deconstruct_keys(_keys) ⇒ Object



3329
3330
3331
# File 'lib/syntax_tree/yarv/instructions.rb', line 3329

def deconstruct_keys(_keys)
  { calldata: calldata }
end

#disasm(fmt) ⇒ Object



3321
3322
3323
# File 'lib/syntax_tree/yarv/instructions.rb', line 3321

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

#lengthObject



3337
3338
3339
# File 'lib/syntax_tree/yarv/instructions.rb', line 3337

def length
  2
end

#popsObject



3341
3342
3343
# File 'lib/syntax_tree/yarv/instructions.rb', line 3341

def pops
  2
end

#pushesObject



3345
3346
3347
# File 'lib/syntax_tree/yarv/instructions.rb', line 3345

def pushes
  1
end

#to_a(_iseq) ⇒ Object



3325
3326
3327
# File 'lib/syntax_tree/yarv/instructions.rb', line 3325

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