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.



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

def initialize(calldata)
  @calldata = calldata
end

Instance Attribute Details

#calldataObject (readonly)

Returns the value of attribute calldata.



4116
4117
4118
# File 'lib/syntax_tree/yarv/instructions.rb', line 4116

def calldata
  @calldata
end

Instance Method Details

#==(other) ⇒ Object



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

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

#call(vm) ⇒ Object



4154
4155
4156
# File 'lib/syntax_tree/yarv/instructions.rb', line 4154

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

#canonicalObject



4150
4151
4152
# File 'lib/syntax_tree/yarv/instructions.rb', line 4150

def canonical
  Send.new(calldata, nil)
end

#deconstruct_keys(_keys) ⇒ Object



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

def deconstruct_keys(_keys)
  { calldata: calldata }
end

#disasm(fmt) ⇒ Object



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

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

#lengthObject



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

def length
  2
end

#popsObject



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

def pops
  2
end

#pushesObject



4146
4147
4148
# File 'lib/syntax_tree/yarv/instructions.rb', line 4146

def pushes
  1
end

#to_a(_iseq) ⇒ Object



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

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