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
- #==(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
1243 1244 1245 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1243 def ==(other) other.is_a?(Dup) end |
#call(vm) ⇒ Object
1263 1264 1265 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1263 def call(vm) vm.push(vm.stack.last.dup) end |
#canonical ⇒ Object
1259 1260 1261 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1259 def canonical self end |
#deconstruct_keys(_keys) ⇒ Object
1239 1240 1241 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1239 def deconstruct_keys(_keys) {} end |
#disasm(fmt) ⇒ Object
1231 1232 1233 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1231 def disasm(fmt) fmt.instruction("dup") end |
#length ⇒ Object
1247 1248 1249 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1247 def length 1 end |
#pops ⇒ Object
1251 1252 1253 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1251 def pops 1 end |
#pushes ⇒ Object
1255 1256 1257 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1255 def pushes 2 end |
#to_a(_iseq) ⇒ Object
1235 1236 1237 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1235 def to_a(_iseq) [:dup] end |