class SyntaxTree::YARV::OptLength
### Summary
‘opt_length` is a specialization of `opt_send_without_block`, when the `length` method is called. There are fast paths when the receiver is either a string, hash, or array. It pops the receiver off the stack and pushes on the result of the method call.
### Usage
~~~ruby “”.length ~~~
Attributes
calldata[R]
Public Class Methods
new(calldata)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3431 def initialize(calldata) @calldata = calldata end
Public Instance Methods
==(other)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3447 def ==(other) other.is_a?(OptLength) && other.calldata == calldata end
call(vm)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3467 def call(vm) canonical.call(vm) end
canonical()
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3463 def canonical Send.new(calldata, nil) end
deconstruct_keys(_keys)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3443 def deconstruct_keys(_keys) { calldata: calldata } end
disasm(fmt)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3435 def disasm(fmt) fmt.instruction("opt_length", [fmt.calldata(calldata)]) end
length()
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3451 def length 2 end
pops()
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3455 def pops 1 end
pushes()
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3459 def pushes 1 end
to_a(_iseq)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 3439 def to_a(_iseq) [:opt_length, calldata.to_h] end