Class: Rubinius::ToolSet.current::TS::AST::RegexLiteral
- Defined in:
- lib/rubinius/ast/literals.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#source ⇒ Object
Returns the value of attribute source.
Attributes inherited from Node
Instance Method Summary collapse
- #bytecode(g) ⇒ Object
- #defined(g) ⇒ Object
-
#initialize(line, str, flags) ⇒ RegexLiteral
constructor
A new instance of RegexLiteral.
- #to_sexp ⇒ Object
Methods inherited from Node
#ascii_graph, #attributes, #children, match_arguments?, match_send?, #new_block_generator, #new_generator, #node_name, #or_bytecode, #pos, #set_child, transform, #transform, transform_comment, transform_kind, transform_kind=, transform_name, #value_defined, #visit, #walk
Constructor Details
#initialize(line, str, flags) ⇒ RegexLiteral
Returns a new instance of RegexLiteral.
296 297 298 299 300 |
# File 'lib/rubinius/ast/literals.rb', line 296 def initialize(line, str, flags) @line = line @source = str @options = flags end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
294 295 296 |
# File 'lib/rubinius/ast/literals.rb', line 294 def @options end |
#source ⇒ Object
Returns the value of attribute source.
294 295 296 |
# File 'lib/rubinius/ast/literals.rb', line 294 def source @source end |
Instance Method Details
#bytecode(g) ⇒ Object
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
# File 'lib/rubinius/ast/literals.rb', line 302 def bytecode(g) pos(g) # A regex literal should only be converted to a Regexp the first time it # is encountered. We push a literal nil here, and then overwrite the # literal value with the created Regexp if it is nil, i.e. the first time # only. Subsequent encounters will use the previously created Regexp idx = g.add_literal(nil) g.push_literal_at idx g.dup g.is_nil lbl = g.new_label g.gif lbl g.pop g.push_cpath_top g.find_const :Regexp g.push_literal @source g.push @options g.send :new, 2 g.set_literal idx lbl.set! end |
#defined(g) ⇒ Object
326 327 328 |
# File 'lib/rubinius/ast/literals.rb', line 326 def defined(g) g.push_literal "expression" end |
#to_sexp ⇒ Object
330 331 332 |
# File 'lib/rubinius/ast/literals.rb', line 330 def to_sexp [:regex, @source, @options] end |