Class: SyntaxTree::YARV::ConcatStrings
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
Instance Method Summary
collapse
Methods inherited from Instruction
#branch_targets, #canonical, #falls_through?, #leaves?, #side_effects?
Constructor Details
723
724
725
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 723
def initialize(number)
@number = number
end
|
Instance Attribute Details
#number ⇒ Object
Returns the value of attribute number.
721
722
723
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 721
def number
@number
end
|
Instance Method Details
#==(other) ⇒ Object
739
740
741
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 739
def ==(other)
other.is_a?(ConcatStrings) && other.number == number
end
|
#call(vm) ⇒ Object
755
756
757
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 755
def call(vm)
vm.push(vm.pop(number).join)
end
|
#deconstruct_keys(_keys) ⇒ Object
735
736
737
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 735
def deconstruct_keys(_keys)
{ number: number }
end
|
#disasm(fmt) ⇒ Object
727
728
729
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 727
def disasm(fmt)
fmt.instruction("concatstrings", [fmt.object(number)])
end
|
#length ⇒ Object
743
744
745
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 743
def length
2
end
|
#pops ⇒ Object
747
748
749
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 747
def pops
number
end
|
#pushes ⇒ Object
751
752
753
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 751
def pushes
1
end
|
#to_a(_iseq) ⇒ Object
731
732
733
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 731
def to_a(_iseq)
[:concatstrings, number]
end
|