class SyntaxTree::YARV::TopN
### 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
~~~ruby case 3 when 1..5
puts "foo"
end ~~~
Attributes
number[R]
Public Class Methods
new(number)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5656 def initialize(number) @number = number end
Public Instance Methods
==(other)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5672 def ==(other) other.is_a?(TopN) && other.number == number end
call(vm)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5684 def call(vm) vm.push(vm.stack[-number - 1]) end
deconstruct_keys(_keys)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5668 def deconstruct_keys(_keys) { number: number } end
disasm(fmt)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5660 def disasm(fmt) fmt.instruction("topn", [fmt.object(number)]) end
length()
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5676 def length 2 end
pushes()
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5680 def pushes 1 end
to_a(_iseq)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5664 def to_a(_iseq) [:topn, number] end