Class: SyntaxTree::YARV::OptLTLT
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
Instance Method Summary
collapse
Methods inherited from Instruction
#branch_targets, #falls_through?, #leaves?, #side_effects?
Constructor Details
#initialize(calldata) ⇒ OptLTLT
Returns a new instance of OptLTLT.
3487
3488
3489
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3487
def initialize(calldata)
@calldata = calldata
end
|
Instance Attribute Details
#calldata ⇒ Object
Returns the value of attribute calldata.
3485
3486
3487
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3485
def calldata
@calldata
end
|
Instance Method Details
#==(other) ⇒ Object
3503
3504
3505
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3503
def ==(other)
other.is_a?(OptLTLT) && other.calldata == calldata
end
|
#call(vm) ⇒ Object
3523
3524
3525
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3523
def call(vm)
canonical.call(vm)
end
|
#canonical ⇒ Object
3519
3520
3521
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3519
def canonical
Send.new(calldata, nil)
end
|
#deconstruct_keys(_keys) ⇒ Object
3499
3500
3501
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3499
def deconstruct_keys(_keys)
{ calldata: calldata }
end
|
#disasm(fmt) ⇒ Object
3491
3492
3493
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3491
def disasm(fmt)
fmt.instruction("opt_ltlt", [fmt.calldata(calldata)])
end
|
#length ⇒ Object
3507
3508
3509
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3507
def length
2
end
|
#pops ⇒ Object
3511
3512
3513
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3511
def pops
2
end
|
#pushes ⇒ Object
3515
3516
3517
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3515
def pushes
1
end
|
#to_a(_iseq) ⇒ Object
3495
3496
3497
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3495
def to_a(_iseq)
[:opt_ltlt, calldata.to_h]
end
|