all instructions should be traversed

while reversed order is needed
not only reachable from sink instruction
This commit is contained in:
Svetlana Isakova
2012-06-08 20:25:18 +04:00
parent 9ede882cd5
commit 0e850e5d30
@@ -151,6 +151,15 @@ public class PseudocodeImpl implements Pseudocode {
if (reversedInstructions == null) {
LinkedHashSet<Instruction> traversedInstructions = Sets.newLinkedHashSet();
traverseInstructionsInReverseOrder(sinkInstruction, traversedInstructions);
if (traversedInstructions.size() < instructions.size()) {
List<Instruction> simplyReversedInstructions = Lists.newArrayList(instructions);
Collections.reverse(simplyReversedInstructions);
for (Instruction instruction : simplyReversedInstructions) {
if (!traversedInstructions.contains(instruction)) {
traverseInstructionsInReverseOrder(instruction, traversedInstructions);
}
}
}
reversedInstructions = Lists.newArrayList(traversedInstructions);
}
return reversedInstructions;