Class: SyntaxTree::YARV::OptSize
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::OptSize
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
opt_size is a specialization of opt_send_without_block, when the size 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.
### Usage
~~~ruby “”.size ~~~
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) ⇒ OptSize
constructor
A new instance of OptSize.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(calldata) ⇒ OptSize
Returns a new instance of OptSize.
3932 3933 3934 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3932 def initialize(calldata) @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
3930 3931 3932 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3930 def calldata @calldata end |
Instance Method Details
#call(vm) ⇒ Object
3960 3961 3962 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3960 def call(vm) canonical.call(vm) end |
#canonical ⇒ Object
3956 3957 3958 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3956 def canonical Send.new(calldata, nil) end |
#disasm(fmt) ⇒ Object
3936 3937 3938 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3936 def disasm(fmt) fmt.instruction("opt_size", [fmt.calldata(calldata)]) end |
#length ⇒ Object
3944 3945 3946 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3944 def length 2 end |
#pops ⇒ Object
3948 3949 3950 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3948 def pops 1 end |
#pushes ⇒ Object
3952 3953 3954 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3952 def pushes 1 end |
#to_a(_iseq) ⇒ Object
3940 3941 3942 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3940 def to_a(_iseq) [:opt_size, calldata.to_h] end |