Class: SyntaxTree::YARV::OptAnd
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::OptAnd
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
opt_and is a specialization of the opt_send_without_block instruction that occurs when the ‘&` operator is used. There is a fast path for if both operands are integers. It pops both the receiver and the argument off the stack and pushes on the result.
### Usage
~~~ruby 2 & 3 ~~~
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) ⇒ OptAnd
constructor
A new instance of OptAnd.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(calldata) ⇒ OptAnd
Returns a new instance of OptAnd.
2867 2868 2869 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2867 def initialize(calldata) @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
2865 2866 2867 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2865 def calldata @calldata end |
Instance Method Details
#==(other) ⇒ Object
2883 2884 2885 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2883 def ==(other) other.is_a?(OptAnd) && other.calldata == calldata end |
#call(vm) ⇒ Object
2903 2904 2905 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2903 def call(vm) canonical.call(vm) end |
#canonical ⇒ Object
2899 2900 2901 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2899 def canonical Send.new(calldata, nil) end |
#deconstruct_keys(_keys) ⇒ Object
2879 2880 2881 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2879 def deconstruct_keys(_keys) { calldata: calldata } end |
#disasm(fmt) ⇒ Object
2871 2872 2873 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2871 def disasm(fmt) fmt.instruction("opt_and", [fmt.calldata(calldata)]) end |
#length ⇒ Object
2887 2888 2889 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2887 def length 2 end |
#pops ⇒ Object
2891 2892 2893 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2891 def pops 2 end |
#pushes ⇒ Object
2895 2896 2897 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2895 def pushes 1 end |
#to_a(_iseq) ⇒ Object
2875 2876 2877 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2875 def to_a(_iseq) [:opt_and, calldata.to_h] end |