class CodeTools::AST::ScopedConstant

Attributes

name[RW]
parent[RW]

Public Class Methods

new(line, parent, name) click to toggle source
# File lib/rubinius/code/ast/constants.rb, line 30
def initialize(line, parent, name)
  @line = line
  @parent = parent
  @name = name
end

Public Instance Methods

assign_bytecode(g, value) click to toggle source
# File lib/rubinius/code/ast/constants.rb, line 43
def assign_bytecode(g, value)
  pos(g)

  value.bytecode(g)
  g.push_literal @name
  @parent.bytecode(g)
  g.rotate 3
end
assign_sexp()
Alias for: to_sexp
bytecode(g) click to toggle source
# File lib/rubinius/code/ast/constants.rb, line 36
def bytecode(g)
  pos(g)

  @parent.bytecode(g)
  g.find_const @name
end
defined(g) click to toggle source
# File lib/rubinius/code/ast/constants.rb, line 60
def defined(g)
  f = g.new_label
  done = g.new_label

  value_defined(g, f, false)

  g.pop
  g.push_literal "constant"
  g.goto done

  f.set!
  g.push_tagged_nil 0

  done.set!
end
masgn_bytecode(g) click to toggle source
# File lib/rubinius/code/ast/constants.rb, line 52
def masgn_bytecode(g)
  pos(g)

  @parent.bytecode(g)
  g.swap
  g.push_literal @name
end
to_sexp() click to toggle source
# File lib/rubinius/code/ast/constants.rb, line 105
def to_sexp
  [:colon2, @parent.to_sexp, @name]
end
Also aliased as: assign_sexp
value_defined(g, f, const_missing=true) click to toggle source
# File lib/rubinius/code/ast/constants.rb, line 76
def value_defined(g, f, const_missing=true)
  # Save the current exception into a stack local
  g.push_exception_state
  outer_exc_state = g.new_stack_local
  g.set_stack_local outer_exc_state
  g.pop

  ex = g.new_label
  ok = g.new_label
  g.setup_unwind ex, RescueType

  g.push_type
  @parent.bytecode(g)
  g.push_literal @name
  g.send :constant_path_defined?, 2
  g.dup
  g.goto_if_not_undefined ok
  g.pop
  g.goto f

  ex.set!
  g.clear_exception
  g.push_stack_local outer_exc_state
  g.restore_exception_state
  g.goto f

  ok.set!
end