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.



4164
4165
4166
# File 'lib/syntax_tree/yarv/instructions.rb', line 4164

def initialize(calldata)
  @calldata = calldata
end

Instance Attribute Details

#calldataObject (readonly)

Returns the value of attribute calldata.



4162
4163
4164
# File 'lib/syntax_tree/yarv/instructions.rb', line 4162

def calldata
  @calldata
end

Instance Method Details

#==(other) ⇒ Object



4180
4181
4182
# File 'lib/syntax_tree/yarv/instructions.rb', line 4180

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

#call(vm) ⇒ Object



4200
4201
4202
# File 'lib/syntax_tree/yarv/instructions.rb', line 4200

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

#canonicalObject



4196
4197
4198
# File 'lib/syntax_tree/yarv/instructions.rb', line 4196

def canonical
  Send.new(calldata, nil)
end

#deconstruct_keys(_keys) ⇒ Object



4176
4177
4178
# File 'lib/syntax_tree/yarv/instructions.rb', line 4176

def deconstruct_keys(_keys)
  { calldata: calldata }
end

#disasm(fmt) ⇒ Object



4168
4169
4170
# File 'lib/syntax_tree/yarv/instructions.rb', line 4168

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

#lengthObject



4184
4185
4186
# File 'lib/syntax_tree/yarv/instructions.rb', line 4184

def length
  2
end

#popsObject



4188
4189
4190
# File 'lib/syntax_tree/yarv/instructions.rb', line 4188

def pops
  2
end

#pushesObject



4192
4193
4194
# File 'lib/syntax_tree/yarv/instructions.rb', line 4192

def pushes
  1
end

#to_a(_iseq) ⇒ Object



4172
4173
4174
# File 'lib/syntax_tree/yarv/instructions.rb', line 4172

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