Class: SyntaxTree::YARV::OptDiv
Overview
### Summary
‘opt_div` 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 2 / 3 ~~~
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Instruction
#branch_targets, #falls_through?, #leaves?, #side_effects?
Constructor Details
#initialize(calldata) ⇒ OptDiv
Returns a new instance of OptDiv.
2976
2977
2978
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2976
def initialize(calldata)
@calldata = calldata
end
|
Instance Attribute Details
#calldata ⇒ Object
Returns the value of attribute calldata.
2974
2975
2976
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2974
def calldata
@calldata
end
|
Instance Method Details
#==(other) ⇒ Object
2992
2993
2994
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2992
def ==(other)
other.is_a?(OptDiv) && other.calldata == calldata
end
|
#call(vm) ⇒ Object
3012
3013
3014
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3012
def call(vm)
canonical.call(vm)
end
|
#canonical ⇒ Object
3008
3009
3010
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3008
def canonical
Send.new(calldata, nil)
end
|
#deconstruct_keys(_keys) ⇒ Object
2988
2989
2990
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2988
def deconstruct_keys(_keys)
{ calldata: calldata }
end
|
#disasm(fmt) ⇒ Object
2980
2981
2982
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2980
def disasm(fmt)
fmt.instruction("opt_div", [fmt.calldata(calldata)])
end
|
#length ⇒ Object
2996
2997
2998
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2996
def length
2
end
|
#pops ⇒ Object
3000
3001
3002
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3000
def pops
2
end
|
#pushes ⇒ Object
3004
3005
3006
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3004
def pushes
1
end
|
#to_a(_iseq) ⇒ Object
2984
2985
2986
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2984
def to_a(_iseq)
[:opt_div, calldata.to_h]
end
|