Class: SyntaxTree::YARV::OptRegExpMatch2

Inherits:
Instruction show all
Defined in:
lib/syntax_tree/yarv/instructions.rb

Overview

### Summary

‘opt_regexpmatch2` is a specialization of the `opt_send_without_block` instruction that occurs when the `=~` operator is used. It pops both the receiver and the argument off the stack and pushes on the result.

### Usage

~~~ruby /a/ =~ “a” ~~~

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Instruction

#branch_targets, #falls_through?, #leaves?, #side_effects?

Constructor Details

#initialize(calldata) ⇒ OptRegExpMatch2

Returns a new instance of OptRegExpMatch2.



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

def initialize(calldata)
  @calldata = calldata
end

Instance Attribute Details

#calldataObject (readonly)

Returns the value of attribute calldata.



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

def calldata
  @calldata
end

Instance Method Details

#==(other) ⇒ Object



4122
4123
4124
# File 'lib/syntax_tree/yarv/instructions.rb', line 4122

def ==(other)
  other.is_a?(OptRegExpMatch2) && other.calldata == calldata
end

#call(vm) ⇒ Object



4142
4143
4144
# File 'lib/syntax_tree/yarv/instructions.rb', line 4142

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

#canonicalObject



4138
4139
4140
# File 'lib/syntax_tree/yarv/instructions.rb', line 4138

def canonical
  Send.new(calldata, nil)
end

#deconstruct_keys(_keys) ⇒ Object



4118
4119
4120
# File 'lib/syntax_tree/yarv/instructions.rb', line 4118

def deconstruct_keys(_keys)
  { calldata: calldata }
end

#disasm(fmt) ⇒ Object



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

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

#lengthObject



4126
4127
4128
# File 'lib/syntax_tree/yarv/instructions.rb', line 4126

def length
  2
end

#popsObject



4130
4131
4132
# File 'lib/syntax_tree/yarv/instructions.rb', line 4130

def pops
  2
end

#pushesObject



4134
4135
4136
# File 'lib/syntax_tree/yarv/instructions.rb', line 4134

def pushes
  1
end

#to_a(_iseq) ⇒ Object



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

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