Class: SyntaxTree::YARV::DupN
Overview
Summary
dupn duplicates the top n stack elements.
Usage
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
Returns a new instance of DupN.
1398
1399
1400
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1398
def initialize(number)
@number = number
end
|
Instance Attribute Details
#number ⇒ Object
Returns the value of attribute number.
1396
1397
1398
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1396
def number
@number
end
|
Instance Method Details
#==(other) ⇒ Object
1414
1415
1416
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1414
def ==(other)
other.is_a?(DupN) && other.number == number
end
|
#call(vm) ⇒ Object
1426
1427
1428
1429
1430
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1426
def call(vm)
values = vm.pop(number)
vm.push(*values)
vm.push(*values)
end
|
#deconstruct_keys(_keys) ⇒ Object
1410
1411
1412
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1410
def deconstruct_keys(_keys)
{ number: number }
end
|
#disasm(fmt) ⇒ Object
1402
1403
1404
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1402
def disasm(fmt)
fmt.instruction("dupn", [fmt.object(number)])
end
|
#length ⇒ Object
1418
1419
1420
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1418
def length
2
end
|
#pushes ⇒ Object
1422
1423
1424
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1422
def pushes
number
end
|
#to_a(_iseq) ⇒ Object
1406
1407
1408
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1406
def to_a(_iseq)
[:dupn, number]
end
|