refactoring: extracted local function updateEdgeDataForInstruction

This commit is contained in:
Svetlana Isakova
2014-02-26 17:25:40 +04:00
parent 7d46ff951e
commit de4a5bbb5b
@@ -112,6 +112,16 @@ public class PseudocodeVariableDataCollector(
allPreviousInstructions = previousInstructions
}
fun updateEdgeDataForInstruction(
previousValue: Edges<Map<VariableDescriptor, D>>?,
newValue: Edges<Map<VariableDescriptor, D>>?
) {
if (previousValue != newValue && newValue != null) {
changed[0] = true
edgesMap.put(instruction, newValue)
}
}
if (shouldLookInside(instruction, lookInside)) {
val functionInstruction = (instruction as LocalFunctionDeclarationInstruction)
val subroutinePseudocode = functionInstruction.getBody()
@@ -123,12 +133,9 @@ public class PseudocodeVariableDataCollector(
val newValue = edgesMap.get(lastInstruction)
val updatedValue = if (newValue == null) null else
Edges.create(
filterOutVariablesOutOfScope(lastInstruction, instruction, newValue.`in`),
filterOutVariablesOutOfScope(lastInstruction, instruction, newValue.out))
if (previousValue != updatedValue && updatedValue != null) {
changed[0] = true
edgesMap.put(instruction, updatedValue)
}
filterOutVariablesOutOfScope(lastInstruction, instruction, newValue.`in`),
filterOutVariablesOutOfScope(lastInstruction, instruction, newValue.out))
updateEdgeDataForInstruction(previousValue, updatedValue)
continue
}
val previousDataValue = edgesMap.get(instruction)
@@ -143,10 +150,7 @@ public class PseudocodeVariableDataCollector(
}
}
val mergedData = instructionDataMergeStrategy.execute(instruction, incomingEdgesData)
if (!mergedData.equals(previousDataValue)) {
changed[0] = true
edgesMap.put(instruction, mergedData)
}
updateEdgeDataForInstruction(previousDataValue, mergedData)
}
}