Class: SyntaxTree::YARV::OptRegExpMatch2

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

Constructor Details

#initialize(calldata) ⇒ OptRegExpMatch2

Returns a new instance of OptRegExpMatch2.



3835
3836
3837
# File 'lib/syntax_tree/yarv/instructions.rb', line 3835

def initialize(calldata)
  @calldata = calldata
end

Instance Attribute Details

#calldataObject (readonly)

Returns the value of attribute calldata.



3833
3834
3835
# File 'lib/syntax_tree/yarv/instructions.rb', line 3833

def calldata
  @calldata
end

Instance Method Details

#call(vm) ⇒ Object



3863
3864
3865
# File 'lib/syntax_tree/yarv/instructions.rb', line 3863

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

#canonicalObject



3859
3860
3861
# File 'lib/syntax_tree/yarv/instructions.rb', line 3859

def canonical
  Send.new(calldata, nil)
end

#disasm(fmt) ⇒ Object



3839
3840
3841
# File 'lib/syntax_tree/yarv/instructions.rb', line 3839

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

#lengthObject



3847
3848
3849
# File 'lib/syntax_tree/yarv/instructions.rb', line 3847

def length
  2
end

#popsObject



3851
3852
3853
# File 'lib/syntax_tree/yarv/instructions.rb', line 3851

def pops
  2
end

#pushesObject



3855
3856
3857
# File 'lib/syntax_tree/yarv/instructions.rb', line 3855

def pushes
  1
end

#to_a(_iseq) ⇒ Object



3843
3844
3845
# File 'lib/syntax_tree/yarv/instructions.rb', line 3843

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