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.
4051
4052
4053
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4051
def initialize(calldata)
@calldata = calldata
end
|
Instance Attribute Details
#calldata ⇒ Object
Returns the value of attribute calldata.
4049
4050
4051
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4049
def calldata
@calldata
end
|
Instance Method Details
#==(other) ⇒ Object
4067
4068
4069
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4067
def ==(other)
other.is_a?(OptOr) && other.calldata == calldata
end
|
#call(vm) ⇒ Object
4087
4088
4089
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4087
def call(vm)
canonical.call(vm)
end
|
#canonical ⇒ Object
4083
4084
4085
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4083
def canonical
Send.new(calldata, nil)
end
|
#deconstruct_keys(_keys) ⇒ Object
4063
4064
4065
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4063
def deconstruct_keys(_keys)
{ calldata: calldata }
end
|
#disasm(fmt) ⇒ Object
4055
4056
4057
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4055
def disasm(fmt)
fmt.instruction("opt_or", [fmt.calldata(calldata)])
end
|
#length ⇒ Object
4071
4072
4073
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4071
def length
2
end
|
#pops ⇒ Object
4075
4076
4077
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4075
def pops
2
end
|
#pushes ⇒ Object
4079
4080
4081
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4079
def pushes
1
end
|
#to_a(_iseq) ⇒ Object
4059
4060
4061
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4059
def to_a(_iseq)
[:opt_or, calldata.to_h]
end
|