Class: SyntaxTree::YARV::OptPlus
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::OptPlus
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
opt_plus 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, floats, strings, or arrays. 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) ⇒ OptPlus
constructor
A new instance of OptPlus.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(calldata) ⇒ OptPlus
3787 3788 3789 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3787 def initialize(calldata) @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
3785 3786 3787 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3785 def calldata @calldata end |
Instance Method Details
#call(vm) ⇒ Object
3815 3816 3817 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3815 def call(vm) canonical.call(vm) end |
#canonical ⇒ Object
3811 3812 3813 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3811 def canonical Send.new(calldata, nil) end |
#disasm(fmt) ⇒ Object
3791 3792 3793 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3791 def disasm(fmt) fmt.instruction("opt_plus", [fmt.calldata(calldata)]) end |
#length ⇒ Object
3799 3800 3801 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3799 def length 2 end |
#pops ⇒ Object
3803 3804 3805 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3803 def pops 2 end |
#pushes ⇒ Object
3807 3808 3809 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3807 def pushes 1 end |
#to_a(_iseq) ⇒ Object
3795 3796 3797 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3795 def to_a(_iseq) [:opt_plus, calldata.to_h] end |