Class: TypeProf::Core::ValueEntity
- Inherits:
-
Object
- Object
- TypeProf::Core::ValueEntity
- Defined in:
- lib/typeprof/core/env/value_entity.rb
Instance Attribute Summary collapse
-
#decls ⇒ Object
readonly
Returns the value of attribute decls.
-
#defs ⇒ Object
readonly
Returns the value of attribute defs.
-
#read_boxes ⇒ Object
readonly
Returns the value of attribute read_boxes.
-
#vtx ⇒ Object
readonly
Returns the value of attribute vtx.
Instance Method Summary collapse
- #add_decl(decl) ⇒ Object
- #add_def(def_) ⇒ Object
- #exist? ⇒ Boolean
-
#initialize ⇒ ValueEntity
constructor
A new instance of ValueEntity.
- #on_const_added(genv, cpath) ⇒ Object
- #on_const_removed(genv, cpath) ⇒ Object
-
#on_decl_changed(genv) ⇒ Object
Re-run all read boxes that depend on this entity.
- #remove_decl(decl) ⇒ Object
- #remove_def(def_) ⇒ Object
Constructor Details
Instance Attribute Details
#decls ⇒ Object (readonly)
Returns the value of attribute decls.
10 11 12 |
# File 'lib/typeprof/core/env/value_entity.rb', line 10 def decls @decls end |
#defs ⇒ Object (readonly)
Returns the value of attribute defs.
10 11 12 |
# File 'lib/typeprof/core/env/value_entity.rb', line 10 def defs @defs end |
#read_boxes ⇒ Object (readonly)
Returns the value of attribute read_boxes.
10 11 12 |
# File 'lib/typeprof/core/env/value_entity.rb', line 10 def read_boxes @read_boxes end |
#vtx ⇒ Object (readonly)
Returns the value of attribute vtx.
10 11 12 |
# File 'lib/typeprof/core/env/value_entity.rb', line 10 def vtx @vtx end |
Instance Method Details
#add_decl(decl) ⇒ Object
12 13 14 |
# File 'lib/typeprof/core/env/value_entity.rb', line 12 def add_decl(decl) @decls << decl end |
#add_def(def_) ⇒ Object
28 29 30 |
# File 'lib/typeprof/core/env/value_entity.rb', line 28 def add_def(def_) @defs << def_ end |
#exist? ⇒ Boolean
36 37 38 |
# File 'lib/typeprof/core/env/value_entity.rb', line 36 def exist? !@decls.empty? || !@defs.empty? end |
#on_const_added(genv, cpath) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/typeprof/core/env/value_entity.rb', line 40 def on_const_added(genv, cpath) unless exist? parent_mod = genv.resolve_cpath(cpath[0..-2]) genv.add_static_eval_queue(:inner_modules_changed, [parent_mod, cpath[-1]]) end end |
#on_const_removed(genv, cpath) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/typeprof/core/env/value_entity.rb', line 47 def on_const_removed(genv, cpath) unless exist? parent_mod = genv.resolve_cpath(cpath[0..-2]) genv.add_static_eval_queue(:inner_modules_changed, [parent_mod, cpath[-1]]) end end |
#on_decl_changed(genv) ⇒ Object
Re-run all read boxes that depend on this entity. Used when a declaration is added or removed so that dependents (e.g. an IVarReadBox that previously fell back to the inferred type) can observe the new state.
24 25 26 |
# File 'lib/typeprof/core/env/value_entity.rb', line 24 def on_decl_changed(genv) @read_boxes.each {|box| genv.add_run(box) } end |
#remove_decl(decl) ⇒ Object
16 17 18 |
# File 'lib/typeprof/core/env/value_entity.rb', line 16 def remove_decl(decl) @decls.delete(decl) || raise end |
#remove_def(def_) ⇒ Object
32 33 34 |
# File 'lib/typeprof/core/env/value_entity.rb', line 32 def remove_def(def_) @defs.delete(def_) || raise end |