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.
5702
5703
5704
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5702
def initialize(number)
@number = number
end
|
Instance Attribute Details
#number ⇒ Object
Returns the value of attribute number.
5700
5701
5702
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5700
def number
@number
end
|
Instance Method Details
#==(other) ⇒ Object
5718
5719
5720
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5718
def ==(other)
other.is_a?(TopN) && other.number == number
end
|
#call(vm) ⇒ Object
5730
5731
5732
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5730
def call(vm)
vm.push(vm.stack[-number - 1])
end
|
#deconstruct_keys(_keys) ⇒ Object
5714
5715
5716
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5714
def deconstruct_keys(_keys)
{ number: number }
end
|
#disasm(fmt) ⇒ Object
5706
5707
5708
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5706
def disasm(fmt)
fmt.instruction("topn", [fmt.object(number)])
end
|
#length ⇒ Object
5722
5723
5724
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5722
def length
2
end
|
#pushes ⇒ Object
5726
5727
5728
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5726
def pushes
1
end
|
#to_a(_iseq) ⇒ Object
5710
5711
5712
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5710
def to_a(_iseq)
[:topn, number]
end
|