Class: SyntaxTree::YARV::OptMinus
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::OptMinus
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
opt_minus 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 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) ⇒ OptMinus
constructor
A new instance of OptMinus.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(calldata) ⇒ OptMinus
Returns a new instance of OptMinus.
3343 3344 3345 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3343 def initialize(calldata) @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
3341 3342 3343 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3341 def calldata @calldata end |
Instance Method Details
#call(vm) ⇒ Object
3371 3372 3373 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3371 def call(vm) canonical.call(vm) end |
#canonical ⇒ Object
3367 3368 3369 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3367 def canonical Send.new(calldata, nil) end |
#disasm(fmt) ⇒ Object
3347 3348 3349 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3347 def disasm(fmt) fmt.instruction("opt_minus", [fmt.calldata(calldata)]) end |
#length ⇒ Object
3355 3356 3357 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3355 def length 2 end |
#pops ⇒ Object
3359 3360 3361 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3359 def pops 2 end |
#pushes ⇒ Object
3363 3364 3365 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3363 def pushes 1 end |
#to_a(_iseq) ⇒ Object
3351 3352 3353 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3351 def to_a(_iseq) [:opt_minus, calldata.to_h] end |