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.
3770
3771
3772
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3770
def initialize(calldata)
@calldata = calldata
end
|
Instance Attribute Details
#calldata ⇒ Object
Returns the value of attribute calldata.
3768
3769
3770
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3768
def calldata
@calldata
end
|
Instance Method Details
#==(other) ⇒ Object
3786
3787
3788
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3786
def ==(other)
other.is_a?(OptMult) && other.calldata == calldata
end
|
#call(vm) ⇒ Object
3806
3807
3808
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3806
def call(vm)
canonical.call(vm)
end
|
#canonical ⇒ Object
3802
3803
3804
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3802
def canonical
Send.new(calldata, nil)
end
|
#deconstruct_keys(_keys) ⇒ Object
3782
3783
3784
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3782
def deconstruct_keys(_keys)
{ calldata: calldata }
end
|
#disasm(fmt) ⇒ Object
3774
3775
3776
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3774
def disasm(fmt)
fmt.instruction("opt_mult", [fmt.calldata(calldata)])
end
|
#length ⇒ Object
3790
3791
3792
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3790
def length
2
end
|
#pops ⇒ Object
3794
3795
3796
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3794
def pops
2
end
|
#pushes ⇒ Object
3798
3799
3800
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3798
def pushes
1
end
|
#to_a(_iseq) ⇒ Object
3778
3779
3780
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3778
def to_a(_iseq)
[:opt_mult, calldata.to_h]
end
|