Class: SyntaxTree::YARV::OptMult
Overview
### Summary
‘opt_mult` 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 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) ⇒ OptMult
Returns a new instance of OptMult.
3659
3660
3661
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3659
def initialize(calldata)
@calldata = calldata
end
|
Instance Attribute Details
#calldata ⇒ Object
Returns the value of attribute calldata.
3657
3658
3659
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3657
def calldata
@calldata
end
|
Instance Method Details
#==(other) ⇒ Object
3675
3676
3677
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3675
def ==(other)
other.is_a?(OptMult) && other.calldata == calldata
end
|
#call(vm) ⇒ Object
3695
3696
3697
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3695
def call(vm)
canonical.call(vm)
end
|
#canonical ⇒ Object
3691
3692
3693
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3691
def canonical
Send.new(calldata, nil)
end
|
#deconstruct_keys(_keys) ⇒ Object
3671
3672
3673
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3671
def deconstruct_keys(_keys)
{ calldata: calldata }
end
|
#disasm(fmt) ⇒ Object
3663
3664
3665
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3663
def disasm(fmt)
fmt.instruction("opt_mult", [fmt.calldata(calldata)])
end
|
#length ⇒ Object
3679
3680
3681
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3679
def length
2
end
|
#pops ⇒ Object
3683
3684
3685
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3683
def pops
2
end
|
#pushes ⇒ Object
3687
3688
3689
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3687
def pushes
1
end
|
#to_a(_iseq) ⇒ Object
3667
3668
3669
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3667
def to_a(_iseq)
[:opt_mult, calldata.to_h]
end
|