class Myco::ConstantReference

Attributes

verbose[RW]
name[R]
scope[R]

Public Class Methods

new(name, scope) click to toggle source
# File lib/myco/bootstrap/find_constant.rb, line 91
def initialize name, scope
  @name  = name
  @scope = scope
end

Public Instance Methods

find_constant_bucket_in_module(mod, name) click to toggle source
# File lib/myco/bootstrap/find_constant.rb, line 118
def find_constant_bucket_in_module mod, name
  current = mod
  while current and Rubinius::Type.object_kind_of? current, Module
    # p current if Myco::ConstantReference.verbose
    return bucket if bucket = current.constant_table.lookup(name)
    current = current.direct_superclass
  end
  
  return nil
end
find_value() click to toggle source
# File lib/myco/bootstrap/find_constant.rb, line 108
def find_value
  bucket = find_constant_bucket_in_module(scope.module, name)
  bucket ? bucket.constant : (
    parent = scope.myco_parent
    parent ? parent.get_myco_constant_ref(name).value : (
      Rubinius::Type.const_get(::Myco, name)
    )
  )
end
value() click to toggle source
# File lib/myco/bootstrap/find_constant.rb, line 96
def value
  serial = @serial
  new_serial = Rubinius.global_serial
  
  if serial && serial >= new_serial
    @value
  else
    @serial = new_serial
    @value = find_value
  end
end