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
- #==(other) ⇒ Object
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #deconstruct_keys(_keys) ⇒ 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.
4275 4276 4277 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4275 def initialize(calldata) @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
4273 4274 4275 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4273 def calldata @calldata end |
Instance Method Details
#==(other) ⇒ Object
4291 4292 4293 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4291 def ==(other) other.is_a?(OptOr) && other.calldata == calldata end |
#call(vm) ⇒ Object
4311 4312 4313 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4311 def call(vm) canonical.call(vm) end |
#canonical ⇒ Object
4307 4308 4309 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4307 def canonical Send.new(calldata, nil) end |
#deconstruct_keys(_keys) ⇒ Object
4287 4288 4289 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4287 def deconstruct_keys(_keys) { calldata: calldata } end |
#disasm(fmt) ⇒ Object
4279 4280 4281 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4279 def disasm(fmt) fmt.instruction("opt_or", [fmt.calldata(calldata)]) end |
#length ⇒ Object
4295 4296 4297 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4295 def length 2 end |
#pops ⇒ Object
4299 4300 4301 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4299 def pops 2 end |
#pushes ⇒ Object
4303 4304 4305 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4303 def pushes 1 end |
#to_a(_iseq) ⇒ Object
4283 4284 4285 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4283 def to_a(_iseq) [:opt_or, calldata.to_h] end |