@@ -54,12 +54,12 @@ class ConstructorAnalyzer {
5454 * Retrieves information about [constructorId] params and modified fields from Soot.
5555 */
5656 fun analyze (constructorId : ConstructorId ): ConstructorAssembleInfo {
57- setFields.clear ()
58- affectedFields.clear ()
57+ val setFields = mutableSetOf< FieldId > ()
58+ val affectedFields = mutableSetOf< FieldId > ()
5959
6060 val sootConstructor = sootConstructor(constructorId)
6161 ? : error(" Soot representation of $constructorId is not found." )
62- val params = analyze(sootConstructor)
62+ val params = analyze(sootConstructor, setFields, affectedFields )
6363
6464 return ConstructorAssembleInfo (constructorId, params, setFields, affectedFields)
6565 }
@@ -106,24 +106,26 @@ class ConstructorAnalyzer {
106106 return jimpleLocal.name.first() != ' $'
107107 }
108108
109- private val setFields = mutableSetOf<FieldId >()
110- private val affectedFields = mutableSetOf<FieldId >()
111109 private val visitedConstructors = mutableSetOf<SootMethod >()
112110
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 > {
114116 if (sootConstructor in visitedConstructors) {
115117 return emptyMap()
116118 }
117119 visitedConstructors.add(sootConstructor)
118120
119121 val jimpleBody = retrieveJimpleBody(sootConstructor) ? : return emptyMap()
120- analyzeAssignments(jimpleBody)
122+ analyzeAssignments(jimpleBody, setFields, affectedFields )
121123
122124 val indexOfLocals = jimpleVariableIndices(jimpleBody)
123125 val indexedFields = indexToField(sootConstructor).toMutableMap()
124126
125127 for (invocation in invocations(jimpleBody)) {
126- val invokedIndexedFields = analyze(invocation.method)
128+ val invokedIndexedFields = analyze(invocation.method, setFields, affectedFields )
127129
128130 for ((index, argument) in invocation.args.withIndex()) {
129131 val fieldId = invokedIndexedFields[index] ? : continue
@@ -140,7 +142,11 @@ class ConstructorAnalyzer {
140142 * Analyze assignments if they are primitive and allow
141143 * to set a field into required value so on.
142144 */
143- private fun analyzeAssignments (jimpleBody : JimpleBody ) {
145+ private fun analyzeAssignments (
146+ jimpleBody : JimpleBody ,
147+ setFields : MutableSet <FieldId >,
148+ affectedFields : MutableSet <FieldId >,
149+ ) {
144150 for (assn in assignments(jimpleBody)) {
145151 val leftPart = assn.leftOp as ? JInstanceFieldRef ? : continue
146152
0 commit comments