Class: SyntaxTree::YARV::OptNewArrayMin
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::OptNewArrayMin
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
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
-
#number ⇒ Object
readonly
Returns the value of attribute number.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(number) ⇒ OptNewArrayMin
constructor
A new instance of OptNewArrayMin.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(number) ⇒ OptNewArrayMin
Returns a new instance of OptNewArrayMin.
4106 4107 4108 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4106 def initialize(number) @number = number end |
Instance Attribute Details
#number ⇒ Object (readonly)
Returns the value of attribute number.
4104 4105 4106 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4104 def number @number end |
Instance Method Details
#==(other) ⇒ Object
4122 4123 4124 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4122 def ==(other) other.is_a?(OptNewArrayMin) && other.number == number end |
#call(vm) ⇒ Object
4142 4143 4144 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4142 def call(vm) vm.push(vm.pop(number).min) end |
#canonical ⇒ Object
4138 4139 4140 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4138 def canonical self end |
#deconstruct_keys(_keys) ⇒ Object
4118 4119 4120 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4118 def deconstruct_keys(_keys) { number: number } end |
#disasm(fmt) ⇒ Object
4110 4111 4112 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4110 def disasm(fmt) fmt.instruction("opt_newarray_min", [fmt.object(number)]) end |
#length ⇒ Object
4126 4127 4128 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4126 def length 2 end |
#pops ⇒ Object
4130 4131 4132 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4130 def pops number end |
#pushes ⇒ Object
4134 4135 4136 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4134 def pushes 1 end |
#to_a(_iseq) ⇒ Object
4114 4115 4116 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4114 def to_a(_iseq) [:opt_newarray_min, number] end |