Class: SyntaxTree::YARV::OptMult
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::OptMult
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
opt_mult is a specialization of the opt_send_without_block instruction that occurs when the ‘*` operator is used. There are fast paths for if both operands are integers or floats. It pops both the receiver and the argument off the stack and pushes on the result.
### Usage
~~~ruby 3 * 2 ~~~
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) ⇒ OptMult
constructor
A new instance of OptMult.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(calldata) ⇒ OptMult
Returns a new instance of OptMult.
3441 3442 3443 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3441 def initialize(calldata) @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
3439 3440 3441 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3439 def calldata @calldata end |
Instance Method Details
#call(vm) ⇒ Object
3469 3470 3471 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3469 def call(vm) canonical.call(vm) end |
#canonical ⇒ Object
3465 3466 3467 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3465 def canonical Send.new(calldata, nil) end |
#disasm(fmt) ⇒ Object
3445 3446 3447 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3445 def disasm(fmt) fmt.instruction("opt_mult", [fmt.calldata(calldata)]) end |
#length ⇒ Object
3453 3454 3455 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3453 def length 2 end |
#pops ⇒ Object
3457 3458 3459 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3457 def pops 2 end |
#pushes ⇒ Object
3461 3462 3463 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3461 def pushes 1 end |
#to_a(_iseq) ⇒ Object
3449 3450 3451 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3449 def to_a(_iseq) [:opt_mult, calldata.to_h] end |