Class: Myco::ConstantReference
- Inherits:
-
Object
- Object
- Myco::ConstantReference
- Defined in:
- lib/myco/bootstrap/find_constant.rb
Class Attribute Summary collapse
-
.verbose ⇒ Object
Returns the value of attribute verbose.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
- #find_constant_bucket_in_module(mod, name) ⇒ Object
- #find_value ⇒ Object
-
#initialize(name, scope) ⇒ ConstantReference
constructor
A new instance of ConstantReference.
- #value ⇒ Object
Constructor Details
#initialize(name, scope) ⇒ ConstantReference
Returns a new instance of ConstantReference.
91 92 93 94 |
# File 'lib/myco/bootstrap/find_constant.rb', line 91 def initialize name, scope @name = name @scope = scope end |
Class Attribute Details
.verbose ⇒ Object
Returns the value of attribute verbose.
85 86 87 |
# File 'lib/myco/bootstrap/find_constant.rb', line 85 def verbose @verbose end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
88 89 90 |
# File 'lib/myco/bootstrap/find_constant.rb', line 88 def name @name end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
89 90 91 |
# File 'lib/myco/bootstrap/find_constant.rb', line 89 def scope @scope end |
Instance Method Details
#find_constant_bucket_in_module(mod, name) ⇒ Object
118 119 120 121 122 123 124 125 126 127 |
# 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 ⇒ Object
108 109 110 111 112 113 114 115 116 |
# 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 ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 |
# 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 |