Class: SyntaxTree::YARV::OptMod
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::OptMod
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
opt_mod 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 if both operands are floats. It pops both the receiver and the argument off the stack and pushes on the result.
### Usage
~~~ruby 4 % 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) ⇒ OptMod
constructor
A new instance of OptMod.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(calldata) ⇒ OptMod
Returns a new instance of OptMod.
3392 3393 3394 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3392 def initialize(calldata) @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
3390 3391 3392 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3390 def calldata @calldata end |
Instance Method Details
#call(vm) ⇒ Object
3420 3421 3422 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3420 def call(vm) canonical.call(vm) end |
#canonical ⇒ Object
3416 3417 3418 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3416 def canonical Send.new(calldata, nil) end |
#disasm(fmt) ⇒ Object
3396 3397 3398 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3396 def disasm(fmt) fmt.instruction("opt_mod", [fmt.calldata(calldata)]) end |
#length ⇒ Object
3404 3405 3406 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3404 def length 2 end |
#pops ⇒ Object
3408 3409 3410 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3408 def pops 2 end |
#pushes ⇒ Object
3412 3413 3414 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3412 def pushes 1 end |
#to_a(_iseq) ⇒ Object
3400 3401 3402 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3400 def to_a(_iseq) [:opt_mod, calldata.to_h] end |