Class: SyntaxTree::YARV::ConcatStrings
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::ConcatStrings
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
concatstrings pops a number of strings from the stack joins them together into a single string and pushes that string back on the stack.
This does no coercion and so is always used in conjunction with objtostring and anytostring to ensure the stack contents are always strings.
### Usage
~~~ruby “#5” ~~~
Instance Attribute Summary collapse
-
#number ⇒ Object
readonly
Returns the value of attribute number.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(number) ⇒ ConcatStrings
constructor
A new instance of ConcatStrings.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(number) ⇒ ConcatStrings
773 774 775 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 773 def initialize(number) @number = number end |
Instance Attribute Details
#number ⇒ Object (readonly)
Returns the value of attribute number.
771 772 773 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 771 def number @number end |
Instance Method Details
#==(other) ⇒ Object
789 790 791 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 789 def ==(other) other.is_a?(ConcatStrings) && other.number == number end |
#call(vm) ⇒ Object
809 810 811 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 809 def call(vm) vm.push(vm.pop(number).join) end |
#canonical ⇒ Object
805 806 807 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 805 def canonical self end |
#deconstruct_keys(_keys) ⇒ Object
785 786 787 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 785 def deconstruct_keys(_keys) { number: number } end |
#disasm(fmt) ⇒ Object
777 778 779 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 777 def disasm(fmt) fmt.instruction("concatstrings", [fmt.object(number)]) end |
#length ⇒ Object
793 794 795 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 793 def length 2 end |
#pops ⇒ Object
797 798 799 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 797 def pops number end |
#pushes ⇒ Object
801 802 803 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 801 def pushes 1 end |
#to_a(_iseq) ⇒ Object
781 782 783 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 781 def to_a(_iseq) [:concatstrings, number] end |