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
- #==(other) ⇒ Object
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #deconstruct_keys(_keys) ⇒ 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.
3929 3930 3931 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3929 def initialize(calldata) @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
3927 3928 3929 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3927 def calldata @calldata end |
Instance Method Details
#==(other) ⇒ Object
3945 3946 3947 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3945 def ==(other) other.is_a?(OptMult) && other.calldata == calldata end |
#call(vm) ⇒ Object
3965 3966 3967 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3965 def call(vm) canonical.call(vm) end |
#canonical ⇒ Object
3961 3962 3963 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3961 def canonical Send.new(calldata, nil) end |
#deconstruct_keys(_keys) ⇒ Object
3941 3942 3943 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3941 def deconstruct_keys(_keys) { calldata: calldata } end |
#disasm(fmt) ⇒ Object
3933 3934 3935 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3933 def disasm(fmt) fmt.instruction("opt_mult", [fmt.calldata(calldata)]) end |
#length ⇒ Object
3949 3950 3951 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3949 def length 2 end |
#pops ⇒ Object
3953 3954 3955 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3953 def pops 2 end |
#pushes ⇒ Object
3957 3958 3959 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3957 def pushes 1 end |
#to_a(_iseq) ⇒ Object
3937 3938 3939 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3937 def to_a(_iseq) [:opt_mult, calldata.to_h] end |