Class: SyntaxTree::YARV::DupN
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::DupN
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
dupn duplicates the top n stack elements.
### Usage
~~~ruby Object::X ||= true ~~~
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) ⇒ DupN
constructor
A new instance of DupN.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(number) ⇒ DupN
Returns a new instance of DupN.
1247 1248 1249 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1247 def initialize(number) @number = number end |
Instance Attribute Details
#number ⇒ Object (readonly)
Returns the value of attribute number.
1245 1246 1247 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1245 def number @number end |
Instance Method Details
#call(vm) ⇒ Object
1275 1276 1277 1278 1279 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1275 def call(vm) values = vm.pop(number) vm.push(*values) vm.push(*values) end |
#canonical ⇒ Object
1271 1272 1273 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1271 def canonical self end |
#disasm(fmt) ⇒ Object
1251 1252 1253 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1251 def disasm(fmt) fmt.instruction("dupn", [fmt.object(number)]) end |
#length ⇒ Object
1259 1260 1261 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1259 def length 2 end |
#pops ⇒ Object
1263 1264 1265 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1263 def pops 0 end |
#pushes ⇒ Object
1267 1268 1269 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1267 def pushes number end |
#to_a(_iseq) ⇒ Object
1255 1256 1257 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1255 def to_a(_iseq) [:dupn, number] end |