Class: SyntaxTree::YARV::OptArefWith
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::OptArefWith
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
opt_aref_with is a specialization of the opt_aref instruction that occurs when the [] operator is used with a string argument known at compile time. There are fast paths if the receiver is a hash. It pops the receiver off the stack and pushes on the result.
### Usage
~~~ruby ‘test’ => true ~~~
Instance Attribute Summary collapse
-
#calldata ⇒ Object
readonly
Returns the value of attribute calldata.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(object, calldata) ⇒ OptArefWith
constructor
A new instance of OptArefWith.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(object, calldata) ⇒ OptArefWith
2624 2625 2626 2627 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2624 def initialize(object, calldata) @object = object @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
2622 2623 2624 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2622 def calldata @calldata end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
2622 2623 2624 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2622 def object @object end |
Instance Method Details
#call(vm) ⇒ Object
2656 2657 2658 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2656 def call(vm) vm.push(vm.pop[object]) end |
#canonical ⇒ Object
2652 2653 2654 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2652 def canonical self end |
#disasm(fmt) ⇒ Object
2629 2630 2631 2632 2633 2634 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2629 def disasm(fmt) fmt.instruction( "opt_aref_with", [fmt.object(object), fmt.calldata(calldata)] ) end |
#length ⇒ Object
2640 2641 2642 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2640 def length 3 end |
#pops ⇒ Object
2644 2645 2646 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2644 def pops 1 end |
#pushes ⇒ Object
2648 2649 2650 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2648 def pushes 1 end |
#to_a(_iseq) ⇒ Object
2636 2637 2638 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2636 def to_a(_iseq) [:opt_aref_with, object, calldata.to_h] end |