Class: TypeProf::Core::Box
- Inherits:
-
Object
- Object
- TypeProf::Core::Box
- Defined in:
- lib/typeprof/core/graph/box.rb
Direct Known Subclasses
CVarReadBox, ConstReadBox, EscapeBox, GVarReadBox, HashSplatBox, IVarReadBox, MAsgnBox, MethodAliasBox, MethodCallBox, MethodDeclBox, MethodDefBox, SplatBox, TypeReadBox
Instance Attribute Summary collapse
-
#changes ⇒ Object
readonly
Returns the value of attribute changes.
-
#destroyed ⇒ Object
readonly
Returns the value of attribute destroyed.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
- #destroy(genv) ⇒ Object
- #diagnostics(genv, &blk) ⇒ Object
-
#initialize(node) ⇒ Box
constructor
A new instance of Box.
- #on_type_added(genv, src_tyvar, added_types) ⇒ Object
- #on_type_removed(genv, src_tyvar, removed_types) ⇒ Object
- #reuse(new_node) ⇒ Object
- #run(genv) ⇒ Object
-
#to_s ⇒ Object
(also: #inspect)
@@new_id = 0.
Constructor Details
Instance Attribute Details
#changes ⇒ Object (readonly)
Returns the value of attribute changes.
12 13 14 |
# File 'lib/typeprof/core/graph/box.rb', line 12 def changes @changes end |
#destroyed ⇒ Object (readonly)
Returns the value of attribute destroyed.
14 15 16 |
# File 'lib/typeprof/core/graph/box.rb', line 14 def destroyed @destroyed end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
14 15 16 |
# File 'lib/typeprof/core/graph/box.rb', line 14 def node @node end |
Instance Method Details
#destroy(genv) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/typeprof/core/graph/box.rb', line 16 def destroy(genv) $box_counts[self.class] -= 1 $box_counts[Box] -= 1 @destroyed = true @changes.reinstall(genv) # rollback all changes end |
#diagnostics(genv, &blk) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/typeprof/core/graph/box.rb', line 42 def diagnostics(genv, &blk) raise self.to_s if !@changes @changes.diagnostics.each(&blk) @changes.boxes.each_value do |box| box.diagnostics(genv, &blk) end end |
#on_type_added(genv, src_tyvar, added_types) ⇒ Object
28 29 30 |
# File 'lib/typeprof/core/graph/box.rb', line 28 def on_type_added(genv, src_tyvar, added_types) genv.add_run(self) end |
#on_type_removed(genv, src_tyvar, removed_types) ⇒ Object
32 33 34 |
# File 'lib/typeprof/core/graph/box.rb', line 32 def on_type_removed(genv, src_tyvar, removed_types) genv.add_run(self) end |
#reuse(new_node) ⇒ Object
23 24 25 26 |
# File 'lib/typeprof/core/graph/box.rb', line 23 def reuse(new_node) @node = new_node @changes.reuse(new_node) end |
#run(genv) ⇒ Object
36 37 38 39 40 |
# File 'lib/typeprof/core/graph/box.rb', line 36 def run(genv) return if @destroyed run0(genv, @changes) @changes.reinstall(genv) end |
#to_s ⇒ Object Also known as: inspect
@@new_id = 0
52 53 54 |
# File 'lib/typeprof/core/graph/box.rb', line 52 def to_s "#{ self.class.to_s.split("::").last[0] }#{ @id ||= $new_id += 1 }" end |