Class: SyntaxTree::YARV::OptOr
Overview
### Summary
‘opt_or` is a specialization of the `opt_send_without_block` instruction that occurs when the `|` operator is used. There is a fast path for if both operands are integers. 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) ⇒ OptOr
Returns a new instance of OptOr.
4058
4059
4060
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4058
def initialize(calldata)
@calldata = calldata
end
|
Instance Attribute Details
#calldata ⇒ Object
Returns the value of attribute calldata.
4056
4057
4058
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4056
def calldata
@calldata
end
|
Instance Method Details
#==(other) ⇒ Object
4074
4075
4076
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4074
def ==(other)
other.is_a?(OptOr) && other.calldata == calldata
end
|
#call(vm) ⇒ Object
4094
4095
4096
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4094
def call(vm)
canonical.call(vm)
end
|
#canonical ⇒ Object
4090
4091
4092
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4090
def canonical
Send.new(calldata, nil)
end
|
#deconstruct_keys(_keys) ⇒ Object
4070
4071
4072
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4070
def deconstruct_keys(_keys)
{ calldata: calldata }
end
|
#disasm(fmt) ⇒ Object
4062
4063
4064
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4062
def disasm(fmt)
fmt.instruction("opt_or", [fmt.calldata(calldata)])
end
|
#length ⇒ Object
4078
4079
4080
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4078
def length
2
end
|
#pops ⇒ Object
4082
4083
4084
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4082
def pops
2
end
|
#pushes ⇒ Object
4086
4087
4088
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4086
def pushes
1
end
|
#to_a(_iseq) ⇒ Object
4066
4067
4068
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4066
def to_a(_iseq)
[:opt_or, calldata.to_h]
end
|