Class: SyntaxTree::YARV::TopN
Overview
Summary
topn pushes a single value onto the stack that is a copy of the value
within the stack that is number of slots down from the top.
Usage
case 3
when 1..5
puts "foo"
end
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) ⇒ TopN
Returns a new instance of TopN.
5656
5657
5658
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5656
def initialize(number)
@number = number
end
|
Instance Attribute Details
#number ⇒ Object
Returns the value of attribute number.
5654
5655
5656
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5654
def number
@number
end
|
Instance Method Details
#==(other) ⇒ Object
5672
5673
5674
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5672
def ==(other)
other.is_a?(TopN) && other.number == number
end
|
#call(vm) ⇒ Object
5684
5685
5686
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5684
def call(vm)
vm.push(vm.stack[-number - 1])
end
|
#deconstruct_keys(_keys) ⇒ Object
5668
5669
5670
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5668
def deconstruct_keys(_keys)
{ number: number }
end
|
#disasm(fmt) ⇒ Object
5660
5661
5662
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5660
def disasm(fmt)
fmt.instruction("topn", [fmt.object(number)])
end
|
#length ⇒ Object
5676
5677
5678
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5676
def length
2
end
|
#pushes ⇒ Object
5680
5681
5682
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5680
def pushes
1
end
|
#to_a(_iseq) ⇒ Object
5664
5665
5666
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5664
def to_a(_iseq)
[:topn, number]
end
|