Class: SyntaxTree::YARV::OptMinus
Overview
### Summary
‘opt_minus` is a specialization of the `opt_send_without_block` instruction that occurs when the `-` operator is used. There are fast paths for if both operands are integers or if both operands are floats. It pops both the receiver and the argument off the stack and pushes on the result.
### Usage
~~~ruby 3 - 2 ~~~
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Instruction
#branch_targets, #falls_through?, #leaves?, #side_effects?
Constructor Details
#initialize(calldata) ⇒ OptMinus
Returns a new instance of OptMinus.
3545
3546
3547
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3545
def initialize(calldata)
@calldata = calldata
end
|
Instance Attribute Details
#calldata ⇒ Object
Returns the value of attribute calldata.
3543
3544
3545
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3543
def calldata
@calldata
end
|
Instance Method Details
#==(other) ⇒ Object
3561
3562
3563
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3561
def ==(other)
other.is_a?(OptMinus) && other.calldata == calldata
end
|
#call(vm) ⇒ Object
3581
3582
3583
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3581
def call(vm)
canonical.call(vm)
end
|
#canonical ⇒ Object
3577
3578
3579
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3577
def canonical
Send.new(calldata, nil)
end
|
#deconstruct_keys(_keys) ⇒ Object
3557
3558
3559
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3557
def deconstruct_keys(_keys)
{ calldata: calldata }
end
|
#disasm(fmt) ⇒ Object
3549
3550
3551
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3549
def disasm(fmt)
fmt.instruction("opt_minus", [fmt.calldata(calldata)])
end
|
#length ⇒ Object
3565
3566
3567
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3565
def length
2
end
|
#pops ⇒ Object
3569
3570
3571
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3569
def pops
2
end
|
#pushes ⇒ Object
3573
3574
3575
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3573
def pushes
1
end
|
#to_a(_iseq) ⇒ Object
3553
3554
3555
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3553
def to_a(_iseq)
[:opt_minus, calldata.to_h]
end
|