class SyntaxTree::YARV::Legacy::OptNewArrayMax

### 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 ~~~

Attributes

number[R]

Public Class Methods

new(number) click to toggle source
# File lib/syntax_tree/yarv/legacy.rb, line 142
def initialize(number)
  @number = number
end

Public Instance Methods

==(other) click to toggle source
# File lib/syntax_tree/yarv/legacy.rb, line 158
def ==(other)
  other.is_a?(OptNewArrayMax) && other.number == number
end
call(vm) click to toggle source
# File lib/syntax_tree/yarv/legacy.rb, line 174
def call(vm)
  vm.push(vm.pop(number).max)
end
deconstruct_keys(_keys) click to toggle source
# File lib/syntax_tree/yarv/legacy.rb, line 154
def deconstruct_keys(_keys)
  { number: number }
end
disasm(fmt) click to toggle source
# File lib/syntax_tree/yarv/legacy.rb, line 146
def disasm(fmt)
  fmt.instruction("opt_newarray_max", [fmt.object(number)])
end
length() click to toggle source
# File lib/syntax_tree/yarv/legacy.rb, line 162
def length
  2
end
pops() click to toggle source
# File lib/syntax_tree/yarv/legacy.rb, line 166
def pops
  number
end
pushes() click to toggle source
# File lib/syntax_tree/yarv/legacy.rb, line 170
def pushes
  1
end
to_a(_iseq) click to toggle source
# File lib/syntax_tree/yarv/legacy.rb, line 150
def to_a(_iseq)
  [:opt_newarray_max, number]
end