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
- #==(other) ⇒ Object
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #deconstruct_keys(_keys) ⇒ 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.
1389 1390 1391 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1389 def initialize(number) @number = number end |
Instance Attribute Details
#number ⇒ Object (readonly)
Returns the value of attribute number.
1387 1388 1389 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1387 def number @number end |
Instance Method Details
#==(other) ⇒ Object
1405 1406 1407 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1405 def ==(other) other.is_a?(DupN) && other.number == number end |
#call(vm) ⇒ Object
1425 1426 1427 1428 1429 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1425 def call(vm) values = vm.pop(number) vm.push(*values) vm.push(*values) end |
#canonical ⇒ Object
1421 1422 1423 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1421 def canonical self end |
#deconstruct_keys(_keys) ⇒ Object
1401 1402 1403 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1401 def deconstruct_keys(_keys) { number: number } end |
#disasm(fmt) ⇒ Object
1393 1394 1395 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1393 def disasm(fmt) fmt.instruction("dupn", [fmt.object(number)]) end |
#length ⇒ Object
1409 1410 1411 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1409 def length 2 end |
#pops ⇒ Object
1413 1414 1415 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1413 def pops 0 end |
#pushes ⇒ Object
1417 1418 1419 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1417 def pushes number end |
#to_a(_iseq) ⇒ Object
1397 1398 1399 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1397 def to_a(_iseq) [:dupn, number] end |