Class: TypeProf::Core::Box
- Inherits:
-
Object
- Object
- TypeProf::Core::Box
show all
- Defined in:
- lib/typeprof/core/graph/box.rb
Direct Known Subclasses
CVarReadBox, ConstReadBox, EscapeBox, GVarReadBox, HashSplatBox, IVarReadBox, InstanceTypeBox, MAsgnBox, MethodAliasBox, MethodCallBox, MethodDeclBox, MethodDefBox, SplatBox, TypeReadBox
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(node) ⇒ Box
Returns a new instance of Box.
4
5
6
7
8
9
10
|
# File 'lib/typeprof/core/graph/box.rb', line 4
def initialize(node)
@node = node
@changes = ChangeSet.new(node, self)
@destroyed = false
$box_counts[Box] += 1
$box_counts[self.class] += 1
end
|
Instance Attribute Details
#changes ⇒ Object
Returns the value of attribute changes.
12
13
14
|
# File 'lib/typeprof/core/graph/box.rb', line 12
def changes
@changes
end
|
#destroyed ⇒ Object
Returns the value of attribute destroyed.
14
15
16
|
# File 'lib/typeprof/core/graph/box.rb', line 14
def destroyed
@destroyed
end
|
#node ⇒ Object
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)
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
|
#run0(genv, changes) ⇒ Object
42
43
44
|
# File 'lib/typeprof/core/graph/box.rb', line 42
def run0(genv, changes)
raise NotImplementedError
end
|
#to_s ⇒ Object
Also known as:
inspect
46
47
48
|
# File 'lib/typeprof/core/graph/box.rb', line 46
def to_s
"#{ self.class.to_s.split("::").last }#{ @id ||= $new_id += 1 }"
end
|