Class: SyntaxTree::YARV::OptNewArrayMin
Overview
### Summary
‘opt_newarray_min` is a specialization that occurs when the `min` 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].min ~~~
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 OptNewArrayMin.
3886
3887
3888
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3886
def initialize(number)
@number = number
end
|
Instance Attribute Details
#number ⇒ Object
Returns the value of attribute number.
3884
3885
3886
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3884
def number
@number
end
|
Instance Method Details
#==(other) ⇒ Object
3902
3903
3904
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3902
def ==(other)
other.is_a?(OptNewArrayMin) && other.number == number
end
|
#call(vm) ⇒ Object
3918
3919
3920
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3918
def call(vm)
vm.push(vm.pop(number).min)
end
|
#deconstruct_keys(_keys) ⇒ Object
3898
3899
3900
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3898
def deconstruct_keys(_keys)
{ number: number }
end
|
#disasm(fmt) ⇒ Object
3890
3891
3892
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3890
def disasm(fmt)
fmt.instruction("opt_newarray_min", [fmt.object(number)])
end
|
#length ⇒ Object
3906
3907
3908
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3906
def length
2
end
|
#pops ⇒ Object
3910
3911
3912
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3910
def pops
number
end
|
#pushes ⇒ Object
3914
3915
3916
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3914
def pushes
1
end
|
#to_a(_iseq) ⇒ Object
3894
3895
3896
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3894
def to_a(_iseq)
[:opt_newarray_min, number]
end
|