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.
2669
2670
2671
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2669
def initialize(calldata)
@calldata = calldata
end
|
Instance Attribute Details
#calldata ⇒ Object
Returns the value of attribute calldata.
2667
2668
2669
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2667
def calldata
@calldata
end
|
Instance Method Details
#==(other) ⇒ Object
2685
2686
2687
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2685
def ==(other)
other.is_a?(OptAref) && other.calldata == calldata
end
|
#call(vm) ⇒ Object
2705
2706
2707
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2705
def call(vm)
canonical.call(vm)
end
|
#canonical ⇒ Object
2701
2702
2703
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2701
def canonical
Send.new(calldata, nil)
end
|
#deconstruct_keys(_keys) ⇒ Object
2681
2682
2683
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2681
def deconstruct_keys(_keys)
{ calldata: calldata }
end
|
#disasm(fmt) ⇒ Object
2673
2674
2675
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2673
def disasm(fmt)
fmt.instruction("opt_aref", [fmt.calldata(calldata)])
end
|
#length ⇒ Object
2689
2690
2691
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2689
def length
2
end
|
#pops ⇒ Object
2693
2694
2695
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2693
def pops
2
end
|
#pushes ⇒ Object
2697
2698
2699
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2697
def pushes
1
end
|
#to_a(_iseq) ⇒ Object
2677
2678
2679
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2677
def to_a(_iseq)
[:opt_aref, calldata.to_h]
end
|