Class: SyntaxTree::YARV::DupN
Overview
### Summary
dupn duplicates the top n stack elements.
### Usage
~~~ruby Object::X ||= true ~~~
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Instruction
#branch_targets, #canonical, #falls_through?, #leaves?, #pops, #side_effects?
Constructor Details
#initialize(number) ⇒ DupN
1345
1346
1347
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1345
def initialize(number)
@number = number
end
|
Instance Attribute Details
#number ⇒ Object
Returns the value of attribute number.
1343
1344
1345
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1343
def number
@number
end
|
Instance Method Details
#==(other) ⇒ Object
1361
1362
1363
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1361
def ==(other)
other.is_a?(DupN) && other.number == number
end
|
#call(vm) ⇒ Object
1373
1374
1375
1376
1377
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1373
def call(vm)
values = vm.pop(number)
vm.push(*values)
vm.push(*values)
end
|
#deconstruct_keys(_keys) ⇒ Object
1357
1358
1359
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1357
def deconstruct_keys(_keys)
{ number: number }
end
|
#disasm(fmt) ⇒ Object
1349
1350
1351
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1349
def disasm(fmt)
fmt.instruction("dupn", [fmt.object(number)])
end
|
#length ⇒ Object
1365
1366
1367
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1365
def length
2
end
|
#pushes ⇒ Object
1369
1370
1371
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1369
def pushes
number
end
|
#to_a(_iseq) ⇒ Object
1353
1354
1355
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1353
def to_a(_iseq)
[:dupn, number]
end
|