Class: SyntaxTree::YARV::OptNewArrayMax
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::OptNewArrayMax
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
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
-
#number ⇒ Object
readonly
Returns the value of attribute number.
Instance Method Summary collapse
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(number) ⇒ OptNewArrayMax
constructor
A new instance of OptNewArrayMax.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(number) ⇒ OptNewArrayMax
3545 3546 3547 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3545 def initialize(number) @number = number end |
Instance Attribute Details
#number ⇒ Object (readonly)
Returns the value of attribute number.
3543 3544 3545 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3543 def number @number end |
Instance Method Details
#call(vm) ⇒ Object
3573 3574 3575 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3573 def call(vm) vm.push(vm.pop(number).max) end |
#canonical ⇒ Object
3569 3570 3571 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3569 def canonical self end |
#disasm(fmt) ⇒ Object
3549 3550 3551 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3549 def disasm(fmt) fmt.instruction("opt_newarray_max", [fmt.object(number)]) end |
#length ⇒ Object
3557 3558 3559 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3557 def length 2 end |
#pops ⇒ Object
3561 3562 3563 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3561 def pops number end |
#pushes ⇒ Object
3565 3566 3567 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3565 def pushes 1 end |
#to_a(_iseq) ⇒ Object
3553 3554 3555 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3553 def to_a(_iseq) [:opt_newarray_max, number] end |