Class: SyntaxTree::YARV::OptLTLT
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::OptLTLT
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
opt_ltlt is a specialization of the opt_send_without_block instruction that occurs when the ‘<<` operator is used. Fast paths exists when the receiver is either a String or an Array. It pops both the receiver and the argument off the stack and pushes on the result.
### Usage
~~~ruby “” << 2 ~~~
Instance Attribute Summary collapse
-
#calldata ⇒ Object
readonly
Returns the value of attribute calldata.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(calldata) ⇒ OptLTLT
constructor
A new instance of OptLTLT.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(calldata) ⇒ OptLTLT
Returns a new instance of OptLTLT.
3757 3758 3759 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3757 def initialize(calldata) @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
3755 3756 3757 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3755 def calldata @calldata end |
Instance Method Details
#==(other) ⇒ Object
3773 3774 3775 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3773 def ==(other) other.is_a?(OptLTLT) && other.calldata == calldata end |
#call(vm) ⇒ Object
3793 3794 3795 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3793 def call(vm) canonical.call(vm) end |
#canonical ⇒ Object
3789 3790 3791 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3789 def canonical Send.new(calldata, nil) end |
#deconstruct_keys(_keys) ⇒ Object
3769 3770 3771 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3769 def deconstruct_keys(_keys) { calldata: calldata } end |
#disasm(fmt) ⇒ Object
3761 3762 3763 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3761 def disasm(fmt) fmt.instruction("opt_ltlt", [fmt.calldata(calldata)]) end |
#length ⇒ Object
3777 3778 3779 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3777 def length 2 end |
#pops ⇒ Object
3781 3782 3783 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3781 def pops 2 end |
#pushes ⇒ Object
3785 3786 3787 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3785 def pushes 1 end |
#to_a(_iseq) ⇒ Object
3765 3766 3767 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3765 def to_a(_iseq) [:opt_ltlt, calldata.to_h] end |