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.
5803
5804
5805
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5803
def initialize(number)
@number = number
end
|
Instance Attribute Details
#number ⇒ Object
Returns the value of attribute number.
5801
5802
5803
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5801
def number
@number
end
|
Instance Method Details
#==(other) ⇒ Object
5819
5820
5821
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5819
def ==(other)
other.is_a?(TopN) && other.number == number
end
|
#call(vm) ⇒ Object
5831
5832
5833
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5831
def call(vm)
vm.push(vm.stack[-number - 1])
end
|
#deconstruct_keys(_keys) ⇒ Object
5815
5816
5817
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5815
def deconstruct_keys(_keys)
{ number: number }
end
|
#disasm(fmt) ⇒ Object
5807
5808
5809
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5807
def disasm(fmt)
fmt.instruction("topn", [fmt.object(number)])
end
|
#length ⇒ Object
5823
5824
5825
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5823
def length
2
end
|
#pushes ⇒ Object
5827
5828
5829
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5827
def pushes
1
end
|
#to_a(_iseq) ⇒ Object
5811
5812
5813
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5811
def to_a(_iseq)
[:topn, number]
end
|