Class: SyntaxTree::YARV::OptAnd
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::OptAnd
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
opt_and 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) ⇒ OptAnd
constructor
A new instance of OptAnd.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(calldata) ⇒ OptAnd
Returns a new instance of OptAnd.
2527 2528 2529 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2527 def initialize(calldata) @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
2525 2526 2527 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2525 def calldata @calldata end |
Instance Method Details
#call(vm) ⇒ Object
2555 2556 2557 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2555 def call(vm) canonical.call(vm) end |
#canonical ⇒ Object
2551 2552 2553 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2551 def canonical Send.new(calldata, nil) end |
#disasm(fmt) ⇒ Object
2531 2532 2533 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2531 def disasm(fmt) fmt.instruction("opt_and", [fmt.calldata(calldata)]) end |
#length ⇒ Object
2539 2540 2541 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2539 def length 2 end |
#pops ⇒ Object
2543 2544 2545 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2543 def pops 2 end |
#pushes ⇒ Object
2547 2548 2549 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2547 def pushes 1 end |
#to_a(_iseq) ⇒ Object
2535 2536 2537 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2535 def to_a(_iseq) [:opt_and, calldata.to_h] end |