Class: SyntaxTree::YARV::OptSucc

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(calldata) ⇒ OptSucc



4085
4086
4087
# File 'lib/syntax_tree/yarv/instructions.rb', line 4085

def initialize(calldata)
  @calldata = calldata
end

Instance Attribute Details

#calldataObject (readonly)

Returns the value of attribute calldata.



4083
4084
4085
# File 'lib/syntax_tree/yarv/instructions.rb', line 4083

def calldata
  @calldata
end

Instance Method Details

#call(vm) ⇒ Object



4113
4114
4115
# File 'lib/syntax_tree/yarv/instructions.rb', line 4113

def call(vm)
  canonical.call(vm)
end

#canonicalObject



4109
4110
4111
# File 'lib/syntax_tree/yarv/instructions.rb', line 4109

def canonical
  Send.new(calldata, nil)
end

#disasm(fmt) ⇒ Object



4089
4090
4091
# File 'lib/syntax_tree/yarv/instructions.rb', line 4089

def disasm(fmt)
  fmt.instruction("opt_succ", [fmt.calldata(calldata)])
end

#lengthObject



4097
4098
4099
# File 'lib/syntax_tree/yarv/instructions.rb', line 4097

def length
  2
end

#popsObject



4101
4102
4103
# File 'lib/syntax_tree/yarv/instructions.rb', line 4101

def pops
  1
end

#pushesObject



4105
4106
4107
# File 'lib/syntax_tree/yarv/instructions.rb', line 4105

def pushes
  1
end

#to_a(_iseq) ⇒ Object



4093
4094
4095
# File 'lib/syntax_tree/yarv/instructions.rb', line 4093

def to_a(_iseq)
  [:opt_succ, calldata.to_h]
end