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
- #==(other) ⇒ Object
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #deconstruct_keys(_keys) ⇒ 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
3872 3873 3874 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3872 def initialize(calldata) @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
3870 3871 3872 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3870 def calldata @calldata end |
Instance Method Details
#==(other) ⇒ Object
3888 3889 3890 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3888 def ==(other) other.is_a?(OptMod) && other.calldata == calldata end |
#call(vm) ⇒ Object
3908 3909 3910 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3908 def call(vm) canonical.call(vm) end |
#canonical ⇒ Object
3904 3905 3906 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3904 def canonical Send.new(calldata, nil) end |
#deconstruct_keys(_keys) ⇒ Object
3884 3885 3886 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3884 def deconstruct_keys(_keys) { calldata: calldata } end |
#disasm(fmt) ⇒ Object
3876 3877 3878 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3876 def disasm(fmt) fmt.instruction("opt_mod", [fmt.calldata(calldata)]) end |
#length ⇒ Object
3892 3893 3894 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3892 def length 2 end |
#pops ⇒ Object
3896 3897 3898 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3896 def pops 2 end |
#pushes ⇒ Object
3900 3901 3902 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3900 def pushes 1 end |
#to_a(_iseq) ⇒ Object
3880 3881 3882 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3880 def to_a(_iseq) [:opt_mod, calldata.to_h] end |