Class: SyntaxTree::YARV::OptDiv
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::OptDiv
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
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
-
#calldata ⇒ Object
readonly
Returns the value of attribute calldata.
Instance Method Summary collapse
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(calldata) ⇒ OptDiv
constructor
A new instance of OptDiv.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(calldata) ⇒ OptDiv
Returns a new instance of OptDiv.
2846 2847 2848 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2846 def initialize(calldata) @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
2844 2845 2846 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2844 def calldata @calldata end |
Instance Method Details
#call(vm) ⇒ Object
2874 2875 2876 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2874 def call(vm) canonical.call(vm) end |
#canonical ⇒ Object
2870 2871 2872 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2870 def canonical Send.new(calldata, nil) end |
#disasm(fmt) ⇒ Object
2850 2851 2852 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2850 def disasm(fmt) fmt.instruction("opt_div", [fmt.calldata(calldata)]) end |
#length ⇒ Object
2858 2859 2860 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2858 def length 2 end |
#pops ⇒ Object
2862 2863 2864 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2862 def pops 2 end |
#pushes ⇒ Object
2866 2867 2868 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2866 def pushes 1 end |
#to_a(_iseq) ⇒ Object
2854 2855 2856 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2854 def to_a(_iseq) [:opt_div, calldata.to_h] end |