Class: CodeTools::AST::RegexLiteral

Inherits:
Node
  • Object
show all
Defined in:
lib/rubinius/code/ast/literals.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#line

Instance Method Summary collapse

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.



356
357
358
359
360
# File 'lib/rubinius/code/ast/literals.rb', line 356

def initialize(line, str, flags)
  @line = line
  @source = str
  @options = flags
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



354
355
356
# File 'lib/rubinius/code/ast/literals.rb', line 354

def options
  @options
end

#sourceObject

Returns the value of attribute source.



354
355
356
# File 'lib/rubinius/code/ast/literals.rb', line 354

def source
  @source
end

Instance Method Details

#bytecode(g) ⇒ Object



362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
# File 'lib/rubinius/code/ast/literals.rb', line 362

def bytecode(g)
  pos(g)

  build = g.new_label
  done = g.new_label

  g.push_nil

  build.set!
  g.push_memo nil
  g.dup
  g.goto_if_not_nil done

  g.pop
  g.push_cpath_top
  g.find_const :Regexp
  g.push_literal @source
  g.push_int @options
  g.send :new, 2
  g.goto build

  done.set!
end

#defined(g) ⇒ Object



386
387
388
# File 'lib/rubinius/code/ast/literals.rb', line 386

def defined(g)
  g.push_literal "expression"
end

#to_sexpObject



390
391
392
# File 'lib/rubinius/code/ast/literals.rb', line 390

def to_sexp
  [:regex, @source, @options]
end