Class: SyntaxTree::YARV::ToRegExp
Overview
Summary
toregexp pops a number of values off the stack, combines them into a new
regular expression, and pushes the new regular expression onto the stack.
Usage
/foo #{bar}/
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Instruction
#branch_targets, #canonical, #falls_through?, #leaves?, #side_effects?
Constructor Details
#initialize(options, length) ⇒ ToRegExp
Returns a new instance of ToRegExp.
5703
5704
5705
5706
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5703
def initialize(options, length)
@options = options
@length = length
end
|
Instance Attribute Details
#length ⇒ Object
Returns the value of attribute length.
5701
5702
5703
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5701
def length
@length
end
|
#options ⇒ Object
Returns the value of attribute options.
5701
5702
5703
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5701
def options
@options
end
|
Instance Method Details
#==(other) ⇒ Object
5720
5721
5722
5723
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5720
def ==(other)
other.is_a?(ToRegExp) && other.options == options &&
other.length == length
end
|
#call(vm) ⇒ Object
5733
5734
5735
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5733
def call(vm)
vm.push(Regexp.new(vm.pop(length).join, options))
end
|
#deconstruct_keys(_keys) ⇒ Object
5716
5717
5718
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5716
def deconstruct_keys(_keys)
{ options: options, length: length }
end
|
#disasm(fmt) ⇒ Object
5708
5709
5710
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5708
def disasm(fmt)
fmt.instruction("toregexp", [fmt.object(options), fmt.object(length)])
end
|
#pops ⇒ Object
5725
5726
5727
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5725
def pops
length
end
|
#pushes ⇒ Object
5729
5730
5731
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5729
def pushes
1
end
|
#to_a(_iseq) ⇒ Object
5712
5713
5714
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5712
def to_a(_iseq)
[:toregexp, options, length]
end
|