Class: SyntaxTree::YARV::ToRegExp
- Inherits:
-
Instruction
- Object
- Instruction
- SyntaxTree::YARV::ToRegExp
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
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
~~~ruby /foo #bar/ ~~~
Instance Attribute Summary collapse
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #call(vm) ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(options, length) ⇒ ToRegExp
constructor
A new instance of ToRegExp.
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
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(, length) @options = @length = length end |
Instance Attribute Details
#length ⇒ Object (readonly)
Returns the value of attribute length.
5701 5702 5703 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5701 def length @length end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5701 5702 5703 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5701 def @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. == && 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, )) end |
#deconstruct_keys(_keys) ⇒ Object
5716 5717 5718 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5716 def deconstruct_keys(_keys) { 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(), 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, , length] end |