Class: SyntaxTree::YARV::OptNewArrayMax
Overview
### Summary
‘opt_newarray_max` is a specialization that occurs when the `max` method is called on an array literal. It pops the values of the array off the stack and pushes on the result.
### Usage
~~~ruby [a, b, c].max ~~~
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Instruction
#branch_targets, #canonical, #falls_through?, #leaves?, #side_effects?
Constructor Details
Returns a new instance of OptNewArrayMax.
3776
3777
3778
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3776
def initialize(number)
@number = number
end
|
Instance Attribute Details
#number ⇒ Object
Returns the value of attribute number.
3774
3775
3776
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3774
def number
@number
end
|
Instance Method Details
#==(other) ⇒ Object
3792
3793
3794
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3792
def ==(other)
other.is_a?(OptNewArrayMax) && other.number == number
end
|
#call(vm) ⇒ Object
3808
3809
3810
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3808
def call(vm)
vm.push(vm.pop(number).max)
end
|
#deconstruct_keys(_keys) ⇒ Object
3788
3789
3790
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3788
def deconstruct_keys(_keys)
{ number: number }
end
|
#disasm(fmt) ⇒ Object
3780
3781
3782
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3780
def disasm(fmt)
fmt.instruction("opt_newarray_max", [fmt.object(number)])
end
|
#length ⇒ Object
3796
3797
3798
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3796
def length
2
end
|
#pops ⇒ Object
3800
3801
3802
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3800
def pops
number
end
|
#pushes ⇒ Object
3804
3805
3806
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3804
def pushes
1
end
|
#to_a(_iseq) ⇒ Object
3784
3785
3786
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3784
def to_a(_iseq)
[:opt_newarray_max, number]
end
|