Class: SyntaxTree::YARV::Dup
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::Dup
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
dup copies the top value of the stack and pushes it onto the stack.
### Usage
~~~ruby $global = 5 ~~~
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
1137 1138 1139 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1137 def call(vm) vm.push(vm.stack.last.dup) end |
#canonical ⇒ Object
1133 1134 1135 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1133 def canonical self end |
#disasm(fmt) ⇒ Object
1113 1114 1115 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1113 def disasm(fmt) fmt.instruction("dup") end |
#length ⇒ Object
1121 1122 1123 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1121 def length 1 end |
#pops ⇒ Object
1125 1126 1127 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1125 def pops 1 end |
#pushes ⇒ Object
1129 1130 1131 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1129 def pushes 2 end |
#to_a(_iseq) ⇒ Object
1117 1118 1119 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1117 def to_a(_iseq) [:dup] end |