Class: SyntaxTree::YARV::OptArefWith
- Inherits:
-
Instruction
- Object
- Instruction
- 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
- #==(other) ⇒ Object
- #call(vm) ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(object, calldata) ⇒ OptArefWith
constructor
A new instance of OptArefWith.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Methods inherited from Instruction
#branch_targets, #canonical, #falls_through?, #leaves?, #side_effects?
Constructor Details
#initialize(object, calldata) ⇒ OptArefWith
Returns a new instance of OptArefWith.
2726 2727 2728 2729 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2726 def initialize(object, calldata) @object = object @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
2724 2725 2726 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2724 def calldata @calldata end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
2724 2725 2726 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2724 def object @object end |
Instance Method Details
#==(other) ⇒ Object
2746 2747 2748 2749 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2746 def ==(other) other.is_a?(OptArefWith) && other.object == object && other.calldata == calldata end |
#call(vm) ⇒ Object
2763 2764 2765 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2763 def call(vm) vm.push(vm.pop[object]) end |
#deconstruct_keys(_keys) ⇒ Object
2742 2743 2744 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2742 def deconstruct_keys(_keys) { object: object, calldata: calldata } end |
#disasm(fmt) ⇒ Object
2731 2732 2733 2734 2735 2736 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2731 def disasm(fmt) fmt.instruction( "opt_aref_with", [fmt.object(object), fmt.calldata(calldata)] ) end |
#length ⇒ Object
2751 2752 2753 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2751 def length 3 end |
#pops ⇒ Object
2755 2756 2757 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2755 def pops 1 end |
#pushes ⇒ Object
2759 2760 2761 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2759 def pushes 1 end |
#to_a(_iseq) ⇒ Object
2738 2739 2740 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2738 def to_a(_iseq) [:opt_aref_with, object, calldata.to_h] end |