Class: SyntaxTree::YARV::OptEmptyP
Overview
### Summary
‘opt_empty_p` is an optimization applied when the method `empty?` is called. It pops the receiver off the stack and pushes on the result of the method call.
### Usage
~~~ruby “”.empty? ~~~
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Instruction
#branch_targets, #falls_through?, #leaves?, #side_effects?
Constructor Details
#initialize(calldata) ⇒ OptEmptyP
Returns a new instance of OptEmptyP.
3143
3144
3145
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3143
def initialize(calldata)
@calldata = calldata
end
|
Instance Attribute Details
#calldata ⇒ Object
Returns the value of attribute calldata.
3141
3142
3143
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3141
def calldata
@calldata
end
|
Instance Method Details
#==(other) ⇒ Object
3159
3160
3161
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3159
def ==(other)
other.is_a?(OptEmptyP) && other.calldata == calldata
end
|
#call(vm) ⇒ Object
3179
3180
3181
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3179
def call(vm)
canonical.call(vm)
end
|
#canonical ⇒ Object
3175
3176
3177
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3175
def canonical
Send.new(calldata, nil)
end
|
#deconstruct_keys(_keys) ⇒ Object
3155
3156
3157
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3155
def deconstruct_keys(_keys)
{ calldata: calldata }
end
|
#disasm(fmt) ⇒ Object
3147
3148
3149
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3147
def disasm(fmt)
fmt.instruction("opt_empty_p", [fmt.calldata(calldata)])
end
|
#length ⇒ Object
3163
3164
3165
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3163
def length
2
end
|
#pops ⇒ Object
3167
3168
3169
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3167
def pops
1
end
|
#pushes ⇒ Object
3171
3172
3173
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3171
def pushes
1
end
|
#to_a(_iseq) ⇒ Object
3151
3152
3153
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3151
def to_a(_iseq)
[:opt_empty_p, calldata.to_h]
end
|