Class: SyntaxTree::YARV::OptAref
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::OptAref
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
opt_aref is a specialization of the opt_send_without_block instruction that occurs when the [] operator is used. There are fast paths if the receiver is an integer, array, or hash.
### Usage
~~~ruby 7 ~~~
Instance Attribute Summary collapse
-
#calldata ⇒ Object
readonly
Returns the value of attribute calldata.
Instance Method Summary collapse
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(calldata) ⇒ OptAref
constructor
A new instance of OptAref.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(calldata) ⇒ OptAref
2575 2576 2577 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2575 def initialize(calldata) @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
2573 2574 2575 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2573 def calldata @calldata end |
Instance Method Details
#call(vm) ⇒ Object
2603 2604 2605 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2603 def call(vm) canonical.call(vm) end |
#canonical ⇒ Object
2599 2600 2601 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2599 def canonical Send.new(calldata, nil) end |
#disasm(fmt) ⇒ Object
2579 2580 2581 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2579 def disasm(fmt) fmt.instruction("opt_aref", [fmt.calldata(calldata)]) end |
#length ⇒ Object
2587 2588 2589 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2587 def length 2 end |
#pops ⇒ Object
2591 2592 2593 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2591 def pops 2 end |
#pushes ⇒ Object
2595 2596 2597 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2595 def pushes 1 end |
#to_a(_iseq) ⇒ Object
2583 2584 2585 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2583 def to_a(_iseq) [:opt_aref, calldata.to_h] end |