Class: SyntaxTree::YARV::OptPlus
Overview
### Summary
‘opt_plus` is a specialization of the `opt_send_without_block` instruction that occurs when the `+` operator is used. There are fast paths for if both operands are integers, floats, strings, or arrays. It pops both the receiver and the argument off the stack and pushes on the result.
### Usage
~~~ruby 2 + 3 ~~~
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Instruction
#branch_targets, #falls_through?, #leaves?, #side_effects?
Constructor Details
#initialize(calldata) ⇒ OptPlus
Returns a new instance of OptPlus.
4062
4063
4064
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4062
def initialize(calldata)
@calldata = calldata
end
|
Instance Attribute Details
#calldata ⇒ Object
Returns the value of attribute calldata.
4060
4061
4062
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4060
def calldata
@calldata
end
|
Instance Method Details
#==(other) ⇒ Object
4078
4079
4080
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4078
def ==(other)
other.is_a?(OptPlus) && other.calldata == calldata
end
|
#call(vm) ⇒ Object
4098
4099
4100
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4098
def call(vm)
canonical.call(vm)
end
|
#canonical ⇒ Object
4094
4095
4096
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4094
def canonical
Send.new(calldata, nil)
end
|
#deconstruct_keys(_keys) ⇒ Object
4074
4075
4076
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4074
def deconstruct_keys(_keys)
{ calldata: calldata }
end
|
#disasm(fmt) ⇒ Object
4066
4067
4068
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4066
def disasm(fmt)
fmt.instruction("opt_plus", [fmt.calldata(calldata)])
end
|
#length ⇒ Object
4082
4083
4084
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4082
def length
2
end
|
#pops ⇒ Object
4086
4087
4088
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4086
def pops
2
end
|
#pushes ⇒ Object
4090
4091
4092
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4090
def pushes
1
end
|
#to_a(_iseq) ⇒ Object
4070
4071
4072
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4070
def to_a(_iseq)
[:opt_plus, calldata.to_h]
end
|