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
- #call(vm) ⇒ Object
- #canonical ⇒ 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
Returns a new instance of ConcatStrings.
699 700 701 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 699 def initialize(number) @number = number end |
Instance Attribute Details
#number ⇒ Object (readonly)
Returns the value of attribute number.
697 698 699 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 697 def number @number end |
Instance Method Details
#call(vm) ⇒ Object
727 728 729 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 727 def call(vm) vm.push(vm.pop(number).join) end |
#canonical ⇒ Object
723 724 725 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 723 def canonical self end |
#disasm(fmt) ⇒ Object
703 704 705 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 703 def disasm(fmt) fmt.instruction("concatstrings", [fmt.object(number)]) end |
#length ⇒ Object
711 712 713 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 711 def length 2 end |
#pops ⇒ Object
715 716 717 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 715 def pops number end |
#pushes ⇒ Object
719 720 721 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 719 def pushes 1 end |
#to_a(_iseq) ⇒ Object
707 708 709 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 707 def to_a(_iseq) [:concatstrings, number] end |