Class: CodeTools::AST::Match

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

Instance Attribute Summary collapse

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods inherited from Node

#ascii_graph, #attributes, #children, #defined, 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, pattern, flags) ⇒ Match

Returns a new instance of Match.



445
446
447
448
# File 'lib/rubinius/code/ast/control_flow.rb', line 445

def initialize(line, pattern, flags)
  @line = line
  @pattern = RegexLiteral.new line, pattern, flags
end

Instance Attribute Details

#patternObject

Returns the value of attribute pattern.



443
444
445
# File 'lib/rubinius/code/ast/control_flow.rb', line 443

def pattern
  @pattern
end

Instance Method Details

#bytecode(g) ⇒ Object



450
451
452
453
454
455
456
457
458
459
460
461
# File 'lib/rubinius/code/ast/control_flow.rb', line 450

def bytecode(g)
  pos(g)

  g.push_rubinius
  g.find_const :Globals
  g.push_literal :$_
  g.send :[], 1

  @pattern.bytecode(g)

  g.send :=~, 1
end

#to_sexpObject



463
464
465
# File 'lib/rubinius/code/ast/control_flow.rb', line 463

def to_sexp
  [:match, @pattern.to_sexp]
end