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.
5749
5750
5751
5752
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5749
def initialize(options, length)
@options = options
@length = length
end
|
Instance Attribute Details
#length ⇒ Object
Returns the value of attribute length.
5747
5748
5749
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5747
def length
@length
end
|
#options ⇒ Object
Returns the value of attribute options.
5747
5748
5749
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5747
def options
@options
end
|
Instance Method Details
#==(other) ⇒ Object
5766
5767
5768
5769
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5766
def ==(other)
other.is_a?(ToRegExp) && other.options == options &&
other.length == length
end
|
#call(vm) ⇒ Object
5779
5780
5781
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5779
def call(vm)
vm.push(Regexp.new(vm.pop(length).join, options))
end
|
#deconstruct_keys(_keys) ⇒ Object
5762
5763
5764
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5762
def deconstruct_keys(_keys)
{ options: options, length: length }
end
|
#disasm(fmt) ⇒ Object
5754
5755
5756
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5754
def disasm(fmt)
fmt.instruction("toregexp", [fmt.object(options), fmt.object(length)])
end
|
#pops ⇒ Object
5771
5772
5773
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5771
def pops
length
end
|
#pushes ⇒ Object
5775
5776
5777
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5775
def pushes
1
end
|
#to_a(_iseq) ⇒ Object
5758
5759
5760
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5758
def to_a(_iseq)
[:toregexp, options, length]
end
|