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
- #call(vm) ⇒ Object
- #canonical ⇒ 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
2943 2944 2945 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2943 def initialize(calldata) @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
2941 2942 2943 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2941 def calldata @calldata end |
Instance Method Details
#call(vm) ⇒ Object
2971 2972 2973 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2971 def call(vm) canonical.call(vm) end |
#canonical ⇒ Object
2967 2968 2969 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2967 def canonical Send.new(calldata, nil) end |
#disasm(fmt) ⇒ Object
2947 2948 2949 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2947 def disasm(fmt) fmt.instruction("opt_eq", [fmt.calldata(calldata)]) end |
#length ⇒ Object
2955 2956 2957 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2955 def length 2 end |
#pops ⇒ Object
2959 2960 2961 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2959 def pops 2 end |
#pushes ⇒ Object
2963 2964 2965 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2963 def pushes 1 end |
#to_a(_iseq) ⇒ Object
2951 2952 2953 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2951 def to_a(_iseq) [:opt_eq, calldata.to_h] end |