Class: SyntaxTree::YARV::OptOr
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::OptOr
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
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
-
#calldata ⇒ Object
readonly
Returns the value of attribute calldata.
Instance Method Summary collapse
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(calldata) ⇒ OptOr
constructor
A new instance of OptOr.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(calldata) ⇒ OptOr
Returns a new instance of OptOr.
3738 3739 3740 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3738 def initialize(calldata) @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
3736 3737 3738 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3736 def calldata @calldata end |
Instance Method Details
#call(vm) ⇒ Object
3766 3767 3768 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3766 def call(vm) canonical.call(vm) end |
#canonical ⇒ Object
3762 3763 3764 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3762 def canonical Send.new(calldata, nil) end |
#disasm(fmt) ⇒ Object
3742 3743 3744 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3742 def disasm(fmt) fmt.instruction("opt_or", [fmt.calldata(calldata)]) end |
#length ⇒ Object
3750 3751 3752 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3750 def length 2 end |
#pops ⇒ Object
3754 3755 3756 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3754 def pops 2 end |
#pushes ⇒ Object
3758 3759 3760 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3758 def pushes 1 end |
#to_a(_iseq) ⇒ Object
3746 3747 3748 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3746 def to_a(_iseq) [:opt_or, calldata.to_h] end |