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