@@ -54,12 +54,12 @@ class ConstructorAnalyzer {
54
54
* Retrieves information about [constructorId] params and modified fields from Soot.
55
55
*/
56
56
fun analyze (constructorId : ConstructorId ): ConstructorAssembleInfo {
57
- setFields.clear ()
58
- affectedFields.clear ()
57
+ val setFields = mutableSetOf< FieldId > ()
58
+ val affectedFields = mutableSetOf< FieldId > ()
59
59
60
60
val sootConstructor = sootConstructor(constructorId)
61
61
? : error(" Soot representation of $constructorId is not found." )
62
- val params = analyze(sootConstructor)
62
+ val params = analyze(sootConstructor, setFields, affectedFields )
63
63
64
64
return ConstructorAssembleInfo (constructorId, params, setFields, affectedFields)
65
65
}
@@ -106,24 +106,26 @@ class ConstructorAnalyzer {
106
106
return jimpleLocal.name.first() != ' $'
107
107
}
108
108
109
- private val setFields = mutableSetOf<FieldId >()
110
- private val affectedFields = mutableSetOf<FieldId >()
111
109
private val visitedConstructors = mutableSetOf<SootMethod >()
112
110
113
- private fun analyze (sootConstructor : SootMethod ): Map <Int , FieldId > {
111
+ private fun analyze (
112
+ sootConstructor : SootMethod ,
113
+ setFields : MutableSet <FieldId >,
114
+ affectedFields : MutableSet <FieldId >,
115
+ ): Map <Int , FieldId > {
114
116
if (sootConstructor in visitedConstructors) {
115
117
return emptyMap()
116
118
}
117
119
visitedConstructors.add(sootConstructor)
118
120
119
121
val jimpleBody = retrieveJimpleBody(sootConstructor) ? : return emptyMap()
120
- analyzeAssignments(jimpleBody)
122
+ analyzeAssignments(jimpleBody, setFields, affectedFields )
121
123
122
124
val indexOfLocals = jimpleVariableIndices(jimpleBody)
123
125
val indexedFields = indexToField(sootConstructor).toMutableMap()
124
126
125
127
for (invocation in invocations(jimpleBody)) {
126
- val invokedIndexedFields = analyze(invocation.method)
128
+ val invokedIndexedFields = analyze(invocation.method, setFields, affectedFields )
127
129
128
130
for ((index, argument) in invocation.args.withIndex()) {
129
131
val fieldId = invokedIndexedFields[index] ? : continue
@@ -140,7 +142,11 @@ class ConstructorAnalyzer {
140
142
* Analyze assignments if they are primitive and allow
141
143
* to set a field into required value so on.
142
144
*/
143
- private fun analyzeAssignments (jimpleBody : JimpleBody ) {
145
+ private fun analyzeAssignments (
146
+ jimpleBody : JimpleBody ,
147
+ setFields : MutableSet <FieldId >,
148
+ affectedFields : MutableSet <FieldId >,
149
+ ) {
144
150
for (assn in assignments(jimpleBody)) {
145
151
val leftPart = assn.leftOp as ? JInstanceFieldRef ? : continue
146
152
0 commit comments