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
- #==(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
5930 5931 5932 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5930 def ==(other) other.is_a?(Swap) end |
#call(vm) ⇒ Object
5950 5951 5952 5953 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5950 def call(vm) left, right = vm.pop(2) vm.push(right, left) end |
#canonical ⇒ Object
5946 5947 5948 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5946 def canonical self end |
#deconstruct_keys(_keys) ⇒ Object
5926 5927 5928 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5926 def deconstruct_keys(_keys) {} end |
#disasm(fmt) ⇒ Object
5918 5919 5920 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5918 def disasm(fmt) fmt.instruction("swap") end |
#length ⇒ Object
5934 5935 5936 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5934 def length 1 end |
#pops ⇒ Object
5938 5939 5940 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5938 def pops 2 end |
#pushes ⇒ Object
5942 5943 5944 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5942 def pushes 2 end |
#to_a(_iseq) ⇒ Object
5922 5923 5924 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5922 def to_a(_iseq) [:swap] end |