Class: SyntaxTree::YARV::OptSucc
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::OptSucc
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
opt_succ is a specialization of the opt_send_without_block instruction when the method being called is succ. Fast paths exist when the receiver is either a String or a Fixnum. It pops the receiver off the stack and pushes on the result.
### Usage
~~~ruby “”.succ ~~~
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) ⇒ OptSucc
constructor
A new instance of OptSucc.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(calldata) ⇒ OptSucc
Returns a new instance of OptSucc.
4680 4681 4682 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4680 def initialize(calldata) @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
4678 4679 4680 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4678 def calldata @calldata end |
Instance Method Details
#==(other) ⇒ Object
4696 4697 4698 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4696 def ==(other) other.is_a?(OptSucc) && other.calldata == calldata end |
#call(vm) ⇒ Object
4716 4717 4718 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4716 def call(vm) canonical.call(vm) end |
#canonical ⇒ Object
4712 4713 4714 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4712 def canonical Send.new(calldata, nil) end |
#deconstruct_keys(_keys) ⇒ Object
4692 4693 4694 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4692 def deconstruct_keys(_keys) { calldata: calldata } end |
#disasm(fmt) ⇒ Object
4684 4685 4686 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4684 def disasm(fmt) fmt.instruction("opt_succ", [fmt.calldata(calldata)]) end |
#length ⇒ Object
4700 4701 4702 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4700 def length 2 end |
#pops ⇒ Object
4704 4705 4706 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4704 def pops 1 end |
#pushes ⇒ Object
4708 4709 4710 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4708 def pushes 1 end |
#to_a(_iseq) ⇒ Object
4688 4689 4690 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4688 def to_a(_iseq) [:opt_succ, calldata.to_h] end |