@@ -45,68 +45,73 @@ class MemoryDump(
45
45
sealed class MemoryObject (
46
46
val id : String ,
47
47
val kind : String ,
48
+ val module : String ,
48
49
val comparable : Boolean ,
49
50
)
50
51
51
52
class ReprMemoryObject (
52
53
id : String ,
53
54
kind : String ,
55
+ module : String ,
54
56
comparable : Boolean ,
55
57
val value : String ,
56
- ): MemoryObject(id, kind, comparable)
58
+ ): MemoryObject(id, kind, module, comparable)
57
59
58
60
class ListMemoryObject (
59
61
id : String ,
60
62
kind : String ,
63
+ module : String ,
61
64
comparable : Boolean ,
62
65
val items : List <String >,
63
- ): MemoryObject(id, kind, comparable)
66
+ ): MemoryObject(id, kind, module, comparable)
64
67
65
68
class DictMemoryObject (
66
69
id : String ,
67
70
kind : String ,
71
+ module : String ,
68
72
comparable : Boolean ,
69
73
val items : Map <String , String >,
70
- ): MemoryObject(id, kind, comparable)
74
+ ): MemoryObject(id, kind, module, comparable)
71
75
72
76
class ReduceMemoryObject (
73
77
id : String ,
74
78
kind : String ,
79
+ module : String ,
75
80
comparable : Boolean ,
76
81
val constructor : String ,
77
82
val args : String ,
78
83
val state : String ,
79
84
val listitems : String ,
80
85
val dictitems : String
81
- ): MemoryObject(id, kind, comparable)
86
+ ): MemoryObject(id, kind, module, comparable)
82
87
83
88
fun PythonTree.PythonTreeNode.toMemoryObject (memoryDump : MemoryDump ): String {
84
89
val obj = when (this ) {
85
90
is PythonTree .PrimitiveNode -> {
86
- ReprMemoryObject (this .id.toString(), this .type.name, this .comparable, this .repr)
91
+ ReprMemoryObject (this .id.toString(), this .type.name, this .type.moduleName, this . comparable, this .repr)
87
92
}
88
93
is PythonTree .ListNode -> {
89
94
val items = this .items.entries
90
95
.sortedBy { it.key }
91
96
.map { it.value.toMemoryObject(memoryDump) }
92
- ListMemoryObject (this .id.toString(), this .type.name, this .comparable, items)
97
+ ListMemoryObject (this .id.toString(), this .type.name, this .type.moduleName, this . comparable, items)
93
98
}
94
99
is PythonTree .TupleNode -> {
95
100
val items = this .items.entries
96
101
.sortedBy { it.key }
97
102
.map { it.value.toMemoryObject(memoryDump) }
98
- ListMemoryObject (this .id.toString(), this .type.name, this .comparable, items)
103
+ ListMemoryObject (this .id.toString(), this .type.name, this .type.moduleName, this . comparable, items)
99
104
}
100
105
is PythonTree .SetNode -> {
101
106
val items = this .items.map { it.toMemoryObject(memoryDump) }
102
- ListMemoryObject (this .id.toString(), this .type.name, this .comparable, items)
107
+ ListMemoryObject (this .id.toString(), this .type.name, this .type.moduleName, this . comparable, items)
103
108
}
104
109
is PythonTree .DictNode -> {
105
110
val items = this .items.entries
106
111
.associate {
107
112
it.key.toMemoryObject(memoryDump) to it.value.toMemoryObject(memoryDump)
108
113
}
109
- DictMemoryObject (this .id.toString(), this .type.name, this .comparable, items)
114
+ DictMemoryObject (this .id.toString(), this .type.name, this .type.moduleName, this . comparable, items)
110
115
}
111
116
is PythonTree .ReduceNode -> {
112
117
val stateObjId = PythonTree .DictNode (this .state.entries.associate { PythonTree .PrimitiveNode (pythonStrClassId, it.key) to it.value }.toMutableMap())
@@ -116,6 +121,7 @@ fun PythonTree.PythonTreeNode.toMemoryObject(memoryDump: MemoryDump): String {
116
121
ReduceMemoryObject (
117
122
this .id.toString(),
118
123
this .type.name,
124
+ this .type.moduleName,
119
125
this .comparable,
120
126
this .constructor .name,
121
127
argsIds.toMemoryObject(memoryDump),
@@ -137,7 +143,7 @@ fun MemoryObject.toPythonTree(memoryDump: MemoryDump): PythonTree.PythonTreeNode
137
143
is ReprMemoryObject -> {
138
144
PythonTree .PrimitiveNode (
139
145
this .id.toLong(),
140
- PythonClassId (this .kind),
146
+ PythonClassId (this .module, this . kind),
141
147
this .value
142
148
)
143
149
}
0 commit comments