Module: TypeProf::Core::ConstRead

Included in:
BaseConstRead, ScopedConstRead
Defined in:
lib/typeprof/core/env/static_read.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cdefObject (readonly)

Returns the value of attribute cdef.



114
115
116
# File 'lib/typeprof/core/env/static_read.rb', line 114

def cdef
  @cdef
end

#cpathObject (readonly)

Returns the value of attribute cpath.



114
115
116
# File 'lib/typeprof/core/env/static_read.rb', line 114

def cpath
  @cpath
end

Instance Method Details

#check_module(genv, mod) ⇒ Object



91
92
93
94
95
96
97
98
99
100
# File 'lib/typeprof/core/env/static_read.rb', line 91

def check_module(genv, mod)
  cdef = mod.consts[@name]
  if cdef && cdef.exist?
    inner_mod = genv.resolve_cpath(mod.cpath + [@name]) # TODO
    cpath = inner_mod.exist? ? inner_mod.cpath : nil
    update_module(genv, cpath, cdef)
    return true
  end
  return false
end

#resolution_failed(genv) ⇒ Object



102
103
104
# File 'lib/typeprof/core/env/static_read.rb', line 102

def resolution_failed(genv)
  update_module(genv, nil, nil)
end

#update_module(genv, cpath, cdef) ⇒ Object



106
107
108
109
110
111
112
# File 'lib/typeprof/core/env/static_read.rb', line 106

def update_module(genv, cpath, cdef)
  if cpath != @cpath || cdef != @cdef
    @cpath = cpath
    @cdef = cdef
    propagate(genv)
  end
end