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
- #==(other) ⇒ Object
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
- #disasm(fmt) ⇒ Object
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Instance Method Details
#==(other) ⇒ Object
729 730 731 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 729 def ==(other) other.is_a?(ConcatArray) end |
#call(vm) ⇒ Object
749 750 751 752 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 749 def call(vm) left, right = vm.pop(2) vm.push([*left, *right]) end |
#canonical ⇒ Object
745 746 747 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 745 def canonical self end |
#deconstruct_keys(_keys) ⇒ Object
725 726 727 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 725 def deconstruct_keys(_keys) {} end |
#disasm(fmt) ⇒ Object
717 718 719 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 717 def disasm(fmt) fmt.instruction("concatarray") end |
#length ⇒ Object
733 734 735 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 733 def length 1 end |
#pops ⇒ Object
737 738 739 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 737 def pops 2 end |
#pushes ⇒ Object
741 742 743 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 741 def pushes 1 end |
#to_a(_iseq) ⇒ Object
721 722 723 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 721 def to_a(_iseq) [:concatarray] end |