Class: SyntaxTree::YARV::OptEq
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::OptEq
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
opt_eq is a specialization of the opt_send_without_block instruction that occurs when the == operator is used. Fast paths exist when both operands are integers, floats, symbols or strings. It pops both the receiver and the argument off the stack and pushes on the result.
### Usage
~~~ruby 2 == 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) ⇒ OptEq
constructor
A new instance of OptEq.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(calldata) ⇒ OptEq
3351 3352 3353 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3351 def initialize(calldata) @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
3349 3350 3351 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3349 def calldata @calldata end |
Instance Method Details
#==(other) ⇒ Object
3367 3368 3369 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3367 def ==(other) other.is_a?(OptEq) && other.calldata == calldata end |
#call(vm) ⇒ Object
3387 3388 3389 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3387 def call(vm) canonical.call(vm) end |
#canonical ⇒ Object
3383 3384 3385 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3383 def canonical Send.new(calldata, nil) end |
#deconstruct_keys(_keys) ⇒ Object
3363 3364 3365 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3363 def deconstruct_keys(_keys) { calldata: calldata } end |
#disasm(fmt) ⇒ Object
3355 3356 3357 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3355 def disasm(fmt) fmt.instruction("opt_eq", [fmt.calldata(calldata)]) end |
#length ⇒ Object
3371 3372 3373 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3371 def length 2 end |
#pops ⇒ Object
3375 3376 3377 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3375 def pops 2 end |
#pushes ⇒ Object
3379 3380 3381 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3379 def pushes 1 end |
#to_a(_iseq) ⇒ Object
3359 3360 3361 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3359 def to_a(_iseq) [:opt_eq, calldata.to_h] end |