Class: SyntaxTree::YARV::Swap
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::Swap
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
swap swaps the top two elements in the stack.
### TracePoint
swap does not dispatch any events.
### Usage
~~~ruby !!defined?([]) ~~~
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
5175 5176 5177 5178 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5175 def call(vm) left, right = vm.pop(2) vm.push(right, left) end |
#canonical ⇒ Object
5171 5172 5173 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5171 def canonical self end |
#disasm(fmt) ⇒ Object
5151 5152 5153 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5151 def disasm(fmt) fmt.instruction("swap") end |
#length ⇒ Object
5159 5160 5161 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5159 def length 1 end |
#pops ⇒ Object
5163 5164 5165 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5163 def pops 2 end |
#pushes ⇒ Object
5167 5168 5169 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5167 def pushes 2 end |
#to_a(_iseq) ⇒ Object
5155 5156 5157 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5155 def to_a(_iseq) [:swap] end |