Rename: getAllInstructions -> getInstructionsIncludingDeadCode

Added this method to 'Pseudocode' interface instead of 'getDeadInstructions',
added 'isDead' to 'Instruction' interface
This commit is contained in:
Svetlana Isakova
2014-06-11 12:53:03 +04:00
parent 4efeb2eae2
commit 67fd858432
10 changed files with 31 additions and 41 deletions
@@ -19,9 +19,8 @@ package org.jetbrains.jet.cfg;
import kotlin.Function3;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.cfg.pseudocode.instructions.Instruction;
import org.jetbrains.jet.lang.cfg.pseudocode.instructions.InstructionImpl;
import org.jetbrains.jet.lang.cfg.pseudocode.PseudocodeImpl;
import org.jetbrains.jet.lang.cfg.pseudocode.instructions.Instruction;
import org.jetbrains.jet.lang.resolve.BindingContext;
import java.util.*;
@@ -34,7 +33,7 @@ public abstract class AbstractControlFlowTest extends AbstractPseudocodeTest {
@NotNull StringBuilder out,
@NotNull BindingContext bindingContext
) {
final int nextInstructionsColumnWidth = countNextInstructionsColumnWidth(pseudocode.getAllInstructions());
final int nextInstructionsColumnWidth = countNextInstructionsColumnWidth(pseudocode.getInstructionsIncludingDeadCode());
dumpInstructions(pseudocode, out, new Function3<Instruction, Instruction, Instruction, String>() {
@Override
@@ -107,9 +106,9 @@ public abstract class AbstractControlFlowTest extends AbstractPseudocodeTest {
@Override
protected void checkPseudocode(PseudocodeImpl pseudocode) {
//check edges directions
Collection<Instruction> instructions = pseudocode.getAllInstructions();
Collection<Instruction> instructions = pseudocode.getInstructionsIncludingDeadCode();
for (Instruction instruction : instructions) {
if (!((InstructionImpl)instruction).getDead()) {
if (!instruction.getDead()) {
for (Instruction nextInstruction : instruction.getNextInstructions()) {
assertTrue("instruction '" + instruction + "' has '" + nextInstruction + "' among next instructions list, but not vice versa",
nextInstruction.getPreviousInstructions().contains(instruction));
@@ -49,7 +49,7 @@ public abstract class AbstractDataFlowTest extends AbstractPseudocodeTest {
pseudocodeVariablesData.getVariableUseStatusData();
final String initPrefix = " INIT:";
final String usePrefix = " USE:";
final int initializersColumnWidth = countDataColumnWidth(initPrefix, pseudocode.getAllInstructions(), variableInitializers);
final int initializersColumnWidth = countDataColumnWidth(initPrefix, pseudocode.getInstructionsIncludingDeadCode(), variableInitializers);
dumpInstructions(pseudocode, out, new Function3<Instruction, Instruction, Instruction, String>() {
@Override
@@ -179,7 +179,7 @@ public abstract class AbstractPseudocodeTest extends KotlinTestWithEnvironment {
@NotNull StringBuilder out,
@NotNull Function3<Instruction, /*next*/Instruction, /*prev*/Instruction, String> getInstructionData
) {
List<Instruction> instructions = pseudocode.getAllInstructions();
List<Instruction> instructions = pseudocode.getInstructionsIncludingDeadCode();
Set<Instruction> remainedAfterPostProcessInstructions = Sets.newHashSet(pseudocode.getInstructions());
List<PseudocodeImpl.PseudocodeLabel> labels = pseudocode.getLabels();
int instructionColumnWidth = countInstructionColumnWidth(instructions);
@@ -44,7 +44,7 @@ public class CFGraphToDotFilePrinter {
int[] count = new int[1];
Map<Instruction, String> nodeToName = new HashMap<Instruction, String>();
for (Pseudocode pseudocode : pseudocodes) {
dumpNodes(((PseudocodeImpl)pseudocode).getAllInstructions(), out, count, nodeToName, Sets
dumpNodes(pseudocode.getInstructionsIncludingDeadCode(), out, count, nodeToName, Sets
.newHashSet(pseudocode.getInstructions()));
}
int i = 0;
@@ -61,7 +61,7 @@ public class CFGraphToDotFilePrinter {
out.println("subgraph cluster_" + i + " {\n" +
"label=\"" + label + "\";\n" +
"color=blue;\n");
dumpEdges(((PseudocodeImpl)pseudocode).getAllInstructions(), out, count, nodeToName);
dumpEdges(pseudocode.getInstructionsIncludingDeadCode(), out, count, nodeToName);
out.println("}");
i++;
}
@@ -76,7 +76,7 @@ public class CFGraphToDotFilePrinter {
public void visitLocalFunctionDeclarationInstruction(LocalFunctionDeclarationInstruction instruction) {
int index = count[0];
// instruction.getBody().dumpSubgraph(out, "subgraph cluster_" + index, count, "color=blue;\nlabel = \"f" + index + "\";", nodeToName);
printEdge(out, nodeToName.get(instruction), nodeToName.get(((PseudocodeImpl)instruction.getBody()).getAllInstructions().get(0)), null);
printEdge(out, nodeToName.get(instruction), nodeToName.get(instruction.getBody().getInstructionsIncludingDeadCode().get(0)), null);
visitInstructionWithNext(instruction);
}