Class: SyntaxTree::YARV::OptEmptyP
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::OptEmptyP
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
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
-
#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) ⇒ OptEmptyP
constructor
A new instance of OptEmptyP.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(calldata) ⇒ OptEmptyP
3294 3295 3296 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3294 def initialize(calldata) @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
3292 3293 3294 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3292 def calldata @calldata end |
Instance Method Details
#==(other) ⇒ Object
3310 3311 3312 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3310 def ==(other) other.is_a?(OptEmptyP) && other.calldata == calldata end |
#call(vm) ⇒ Object
3330 3331 3332 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3330 def call(vm) canonical.call(vm) end |
#canonical ⇒ Object
3326 3327 3328 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3326 def canonical Send.new(calldata, nil) end |
#deconstruct_keys(_keys) ⇒ Object
3306 3307 3308 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3306 def deconstruct_keys(_keys) { calldata: calldata } end |
#disasm(fmt) ⇒ Object
3298 3299 3300 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3298 def disasm(fmt) fmt.instruction("opt_empty_p", [fmt.calldata(calldata)]) end |
#length ⇒ Object
3314 3315 3316 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3314 def length 2 end |
#pops ⇒ Object
3318 3319 3320 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3318 def pops 1 end |
#pushes ⇒ Object
3322 3323 3324 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3322 def pushes 1 end |
#to_a(_iseq) ⇒ Object
3302 3303 3304 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3302 def to_a(_iseq) [:opt_empty_p, calldata.to_h] end |