Class: SyntaxTree::YARV::OptSucc
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
Instance Method Summary
collapse
Methods inherited from Instruction
#branch_targets, #falls_through?, #leaves?, #side_effects?
Constructor Details
#initialize(calldata) ⇒ OptSucc
Returns a new instance of OptSucc.
4447
4448
4449
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4447
def initialize(calldata)
@calldata = calldata
end
|
Instance Attribute Details
#calldata ⇒ Object
Returns the value of attribute calldata.
4445
4446
4447
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4445
def calldata
@calldata
end
|
Instance Method Details
#==(other) ⇒ Object
4463
4464
4465
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4463
def ==(other)
other.is_a?(OptSucc) && other.calldata == calldata
end
|
#call(vm) ⇒ Object
4483
4484
4485
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4483
def call(vm)
canonical.call(vm)
end
|
#canonical ⇒ Object
4479
4480
4481
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4479
def canonical
Send.new(calldata, nil)
end
|
#deconstruct_keys(_keys) ⇒ Object
4459
4460
4461
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4459
def deconstruct_keys(_keys)
{ calldata: calldata }
end
|
#disasm(fmt) ⇒ Object
4451
4452
4453
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4451
def disasm(fmt)
fmt.instruction("opt_succ", [fmt.calldata(calldata)])
end
|
#length ⇒ Object
4467
4468
4469
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4467
def length
2
end
|
#pops ⇒ Object
4471
4472
4473
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4471
def pops
1
end
|
#pushes ⇒ Object
4475
4476
4477
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4475
def pushes
1
end
|
#to_a(_iseq) ⇒ Object
4455
4456
4457
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4455
def to_a(_iseq)
[:opt_succ, calldata.to_h]
end
|