class CodeTools::AST::GlobalVariableAccess

Constants

EnglishBackrefs

Public Class Methods

for_name(line, name) click to toggle source
# File lib/rubinius/code/ast/variables.rb, line 258
def self.for_name(line, name)
  case name
  when :$!
    CurrentException.new(line)
  when :$~
    BackRef.new(line, :~)
  else
    if backref = EnglishBackrefs[name]
      BackRef.new(line, backref)
    else
      new(line, name)
    end
  end
end

Public Instance Methods

bytecode(g) click to toggle source
# File lib/rubinius/code/ast/variables.rb, line 273
def bytecode(g)
  pos(g)

  g.push_rubinius
  g.find_const :Globals
  g.push_literal @name
  g.send :[], 1
end
defined(g) click to toggle source
# File lib/rubinius/code/ast/variables.rb, line 290
def defined(g)
  f = g.new_label
  done = g.new_label

  variable_defined(g, f)
  g.push_literal "global-variable"
  g.goto done

  f.set!
  g.push_tagged_nil 0

  done.set!
end
to_sexp() click to toggle source
# File lib/rubinius/code/ast/variables.rb, line 304
def to_sexp
  [:gvar, @name]
end
variable_defined(g, f) click to toggle source
# File lib/rubinius/code/ast/variables.rb, line 282
def variable_defined(g, f)
  g.push_rubinius
  g.find_const :Globals
  g.push_literal @name
  g.send :key?, 1
  g.goto_if_false f
end