Class: SyntaxTree::YARV::ConcatArray
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::ConcatArray
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
concatarray concatenates the two Arrays on top of the stack.
It coerces the two objects at the top of the stack into Arrays by calling to_a if necessary, and makes sure to dup the first Array if it was already an Array, to avoid mutating it when concatenating.
### Usage
~~~ruby
- 1, *2
-
~~~
Instance Method Summary collapse
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #disasm(fmt) ⇒ Object
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Instance Method Details
#call(vm) ⇒ Object
675 676 677 678 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 675 def call(vm) left, right = vm.pop(2) vm.push([*left, *right]) end |
#canonical ⇒ Object
671 672 673 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 671 def canonical self end |
#disasm(fmt) ⇒ Object
651 652 653 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 651 def disasm(fmt) fmt.instruction("concatarray") end |
#length ⇒ Object
659 660 661 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 659 def length 1 end |
#pops ⇒ Object
663 664 665 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 663 def pops 2 end |
#pushes ⇒ Object
667 668 669 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 667 def pushes 1 end |
#to_a(_iseq) ⇒ Object
655 656 657 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 655 def to_a(_iseq) [:concatarray] end |