class Opal::Nodes::BackRefNode

back_ref can be: $‘ $’ $& $+ (currently unsupported)

Public Instance Methods

compile() click to toggle source
Calls superclass method Opal::Nodes::GlobalVariableNode#compile
# File lib/opal/nodes/variables.rb, line 121
def compile
  helper :gvars

  case var_name
  when '&'
    handle_global_match
  when "'"
    handle_post_match
  when '`'
    handle_pre_match
  when '+'
    super
  else
    raise NotImplementedError
  end
end
handle_global_match() click to toggle source
# File lib/opal/nodes/variables.rb, line 138
def handle_global_match
  with_temp do |tmp|
    push "((#{tmp} = $gvars['~']) === nil ? nil : #{tmp}['$[]'](0))"
  end
end
handle_post_match() click to toggle source
# File lib/opal/nodes/variables.rb, line 150
def handle_post_match
  with_temp do |tmp|
    push "((#{tmp} = $gvars['~']) === nil ? nil : #{tmp}.$post_match())"
  end
end
handle_pre_match() click to toggle source
# File lib/opal/nodes/variables.rb, line 144
def handle_pre_match
  with_temp do |tmp|
    push "((#{tmp} = $gvars['~']) === nil ? nil : #{tmp}.$pre_match())"
  end
end