Class: SyntaxTree::YARV::ToRegExp
- Inherits:
-
Object
- Object
- 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
- #canonical ⇒ 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
Constructor Details
#initialize(options, length) ⇒ ToRegExp
Returns a new instance of ToRegExp.
6133 6134 6135 6136 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 6133 def initialize(, length) = @length = length end |
Instance Attribute Details
#length ⇒ Object (readonly)
Returns the value of attribute length.
6131 6132 6133 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 6131 def length @length end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6131 6132 6133 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 6131 def end |
Instance Method Details
#==(other) ⇒ Object
6150 6151 6152 6153 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 6150 def ==(other) other.is_a?(ToRegExp) && other. == && other.length == length end |
#call(vm) ⇒ Object
6167 6168 6169 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 6167 def call(vm) vm.push(Regexp.new(vm.pop(length).join, )) end |
#canonical ⇒ Object
6163 6164 6165 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 6163 def canonical self end |
#deconstruct_keys(_keys) ⇒ Object
6146 6147 6148 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 6146 def deconstruct_keys(_keys) { options: , length: length } end |
#disasm(fmt) ⇒ Object
6138 6139 6140 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 6138 def disasm(fmt) fmt.instruction("toregexp", [fmt.object(), fmt.object(length)]) end |
#pops ⇒ Object
6155 6156 6157 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 6155 def pops length end |
#pushes ⇒ Object
6159 6160 6161 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 6159 def pushes 1 end |
#to_a(_iseq) ⇒ Object
6142 6143 6144 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 6142 def to_a(_iseq) [:toregexp, , length] end |