-
Notifications
You must be signed in to change notification settings - Fork 3
/
referenceRecycle.go
79 lines (67 loc) · 1.81 KB
/
referenceRecycle.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// File provided by the K Framework Go backend. Timestamp: 2019-08-13 18:19:50.499
package ieletestingmodel
// RecycleUnused sends to the recycle bin all objects left without references.
// This goes recursively through the whole sub-tree.
func (ms *ModelState) RecycleUnused(ref KReference) {
refType, dataRef, value := parseKrefBasic(ref)
switch refType {
case boolRef:
case bottomRef:
case emptyKseqRef:
case smallPositiveIntRef:
case smallNegativeIntRef:
case stringRef:
case bytesRef:
case ktokenRef:
case bigIntRef:
obj, _ := ms.getData(dataRef).getBigIntObject(ref)
if obj.reuseStatus == active && obj.referenceCount < 1 {
// recycle
obj.referenceCount = 0
obj.reuseStatus = inRecycleBin
ms.getData(dataRef).bigIntRecycleBin = append(ms.getData(dataRef).bigIntRecycleBin, ref)
}
case nonEmptyKseqRef:
ks := ms.KSequenceToSlice(ref)
for _, child := range ks {
ms.RecycleUnused(child)
}
case kapplyRef:
for _, child := range ms.kapplyArgSlice(ref) {
ms.RecycleUnused(child)
}
default:
// object types
obj := ms.getData(dataRef).getReferencedObject(value)
obj.recycleUnused(ms)
}
}
func (k *InjectedKLabel) recycleUnused(ms *ModelState) {
}
func (k *KVariable) recycleUnused(ms *ModelState) {
}
func (k *Map) recycleUnused(ms *ModelState) {
for _, v := range k.Data {
ms.RecycleUnused(v)
}
}
func (k *List) recycleUnused(ms *ModelState) {
for _, item := range k.Data {
ms.RecycleUnused(item)
}
}
func (k *Set) recycleUnused(ms *ModelState) {
}
func (k *Array) recycleUnused(ms *ModelState) {
for i := 0; i < len(k.Data.data); i++ {
if k.Data.data[i] != NullReference {
ms.RecycleUnused(k.Data.data[i])
}
}
}
func (k *MInt) recycleUnused(ms *ModelState) {
}
func (k *Float) recycleUnused(ms *ModelState) {
}
func (k *StringBuffer) recycleUnused(ms *ModelState) {
}