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.
5691 5692 5693 5694 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5691 def initialize(, length) @options = @length = length end |
Instance Attribute Details
#length ⇒ Object (readonly)
Returns the value of attribute length.
5689 5690 5691 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5689 def length @length end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5689 5690 5691 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5689 def @options end |
Instance Method Details
#==(other) ⇒ Object
5708 5709 5710 5711 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5708 def ==(other) other.is_a?(ToRegExp) && other. == && other.length == length end |
#call(vm) ⇒ Object
5721 5722 5723 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5721 def call(vm) vm.push(Regexp.new(vm.pop(length).join, )) end |
#deconstruct_keys(_keys) ⇒ Object
5704 5705 5706 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5704 def deconstruct_keys(_keys) { options: , length: length } end |
#disasm(fmt) ⇒ Object
5696 5697 5698 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5696 def disasm(fmt) fmt.instruction("toregexp", [fmt.object(), fmt.object(length)]) end |
#pops ⇒ Object
5713 5714 5715 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5713 def pops length end |
#pushes ⇒ Object
5717 5718 5719 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5717 def pushes 1 end |
#to_a(_iseq) ⇒ Object
5700 5701 5702 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5700 def to_a(_iseq) [:toregexp, , length] end |