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
Public Class Methods
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5803 def initialize(number) @number = number end
Public Instance Methods
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5819 def ==(other) other.is_a?(TopN) && other.number == number end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5831 def call(vm) vm.push(vm.stack[-number - 1]) end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5815 def deconstruct_keys(_keys) { number: number } end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5807 def disasm(fmt) fmt.instruction("topn", [fmt.object(number)]) end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5811 def to_a(_iseq) [:topn, number] end