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
[a, b, c].min
Instance Attribute Summary collapse
-
#number ⇒ Object
readonly
Returns the value of attribute number.
Instance Method Summary collapse
- #call(vm) ⇒ Object
- #canonical ⇒ 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.
3593 3594 3595 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3593 def initialize(number) @number = number end |
Instance Attribute Details
#number ⇒ Object (readonly)
Returns the value of attribute number.
3591 3592 3593 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3591 def number @number end |
Instance Method Details
#call(vm) ⇒ Object
3621 3622 3623 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3621 def call(vm) vm.push(vm.pop(number).min) end |
#canonical ⇒ Object
3617 3618 3619 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3617 def canonical self end |
#disasm(fmt) ⇒ Object
3597 3598 3599 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3597 def disasm(fmt) fmt.instruction("opt_newarray_min", [fmt.object(number)]) end |
#length ⇒ Object
3605 3606 3607 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3605 def length 2 end |
#pops ⇒ Object
3609 3610 3611 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3609 def pops number end |
#pushes ⇒ Object
3613 3614 3615 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3613 def pushes 1 end |
#to_a(_iseq) ⇒ Object
3601 3602 3603 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3601 def to_a(_iseq) [:opt_newarray_min, number] end |