Rename class
This commit is contained in:
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.JetNodeTypes;
|
import org.jetbrains.jet.JetNodeTypes;
|
||||||
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowInstructionsGenerator;
|
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowInstructionsGenerator;
|
||||||
import org.jetbrains.jet.lang.cfg.pseudocode.LocalDeclarationInstruction;
|
import org.jetbrains.jet.lang.cfg.pseudocode.LocalFunctionDeclarationInstruction;
|
||||||
import org.jetbrains.jet.lang.cfg.pseudocode.Pseudocode;
|
import org.jetbrains.jet.lang.cfg.pseudocode.Pseudocode;
|
||||||
import org.jetbrains.jet.lang.cfg.pseudocode.PseudocodeImpl;
|
import org.jetbrains.jet.lang.cfg.pseudocode.PseudocodeImpl;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
@@ -56,8 +56,8 @@ public class JetControlFlowProcessor {
|
|||||||
public Pseudocode generatePseudocode(@NotNull JetElement subroutine) {
|
public Pseudocode generatePseudocode(@NotNull JetElement subroutine) {
|
||||||
Pseudocode pseudocode = generate(subroutine);
|
Pseudocode pseudocode = generate(subroutine);
|
||||||
((PseudocodeImpl) pseudocode).postProcess();
|
((PseudocodeImpl) pseudocode).postProcess();
|
||||||
for (LocalDeclarationInstruction localDeclarationInstruction : pseudocode.getLocalDeclarations()) {
|
for (LocalFunctionDeclarationInstruction localFunctionDeclarationInstruction : pseudocode.getLocalDeclarations()) {
|
||||||
((PseudocodeImpl)localDeclarationInstruction.getBody()).postProcess();
|
((PseudocodeImpl) localFunctionDeclarationInstruction.getBody()).postProcess();
|
||||||
}
|
}
|
||||||
return pseudocode;
|
return pseudocode;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ public class JetFlowInformationProvider {
|
|||||||
Pseudocode pseudocode = pseudocodeVariablesData.getPseudocode();
|
Pseudocode pseudocode = pseudocodeVariablesData.getPseudocode();
|
||||||
Map<Instruction, Edges<Map<VariableDescriptor,VariableInitState>>> initializers = pseudocodeVariablesData.getVariableInitializers();
|
Map<Instruction, Edges<Map<VariableDescriptor,VariableInitState>>> initializers = pseudocodeVariablesData.getVariableInitializers();
|
||||||
recordInitializedVariables(pseudocode, initializers);
|
recordInitializedVariables(pseudocode, initializers);
|
||||||
for (LocalDeclarationInstruction instruction : pseudocode.getLocalDeclarations()) {
|
for (LocalFunctionDeclarationInstruction instruction : pseudocode.getLocalDeclarations()) {
|
||||||
recordInitializedVariables(instruction.getBody(), initializers);
|
recordInitializedVariables(instruction.getBody(), initializers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class PseudocodeTraverser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean shouldLookInside(Instruction instruction, LookInsideStrategy lookInside) {
|
private static boolean shouldLookInside(Instruction instruction, LookInsideStrategy lookInside) {
|
||||||
return lookInside == LookInsideStrategy.ANALYSE_LOCAL_DECLARATIONS && instruction instanceof LocalDeclarationInstruction;
|
return lookInside == LookInsideStrategy.ANALYSE_LOCAL_DECLARATIONS && instruction instanceof LocalFunctionDeclarationInstruction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <D> Map<Instruction, Edges<D>> collectData(
|
public static <D> Map<Instruction, Edges<D>> collectData(
|
||||||
@@ -99,7 +99,7 @@ public class PseudocodeTraverser {
|
|||||||
for (Instruction instruction : instructions) {
|
for (Instruction instruction : instructions) {
|
||||||
edgesMap.put(instruction, initialEdge);
|
edgesMap.put(instruction, initialEdge);
|
||||||
if (shouldLookInside(instruction, lookInside)) {
|
if (shouldLookInside(instruction, lookInside)) {
|
||||||
initializeEdgesMap(((LocalDeclarationInstruction) instruction).getBody(), lookInside, edgesMap, initialDataValue);
|
initializeEdgesMap(((LocalFunctionDeclarationInstruction) instruction).getBody(), lookInside, edgesMap, initialDataValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -131,7 +131,7 @@ public class PseudocodeTraverser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (shouldLookInside(instruction, lookInside)) {
|
if (shouldLookInside(instruction, lookInside)) {
|
||||||
Pseudocode subroutinePseudocode = ((LocalDeclarationInstruction) instruction).getBody();
|
Pseudocode subroutinePseudocode = ((LocalFunctionDeclarationInstruction) instruction).getBody();
|
||||||
collectDataFromSubgraph(subroutinePseudocode, traversalOrder, lookInside, edgesMap, instructionDataMergeStrategy,
|
collectDataFromSubgraph(subroutinePseudocode, traversalOrder, lookInside, edgesMap, instructionDataMergeStrategy,
|
||||||
previousInstructions,
|
previousInstructions,
|
||||||
changed, true);
|
changed, true);
|
||||||
@@ -168,8 +168,8 @@ public class PseudocodeTraverser {
|
|||||||
|
|
||||||
List<Instruction> instructions = getInstructions(pseudocode, traversalOrder);
|
List<Instruction> instructions = getInstructions(pseudocode, traversalOrder);
|
||||||
for (Instruction instruction : instructions) {
|
for (Instruction instruction : instructions) {
|
||||||
if (instruction instanceof LocalDeclarationInstruction) {
|
if (instruction instanceof LocalFunctionDeclarationInstruction) {
|
||||||
traverse(((LocalDeclarationInstruction) instruction).getBody(), traversalOrder, instructionAnalyzeStrategy);
|
traverse(((LocalFunctionDeclarationInstruction) instruction).getBody(), traversalOrder, instructionAnalyzeStrategy);
|
||||||
}
|
}
|
||||||
instructionAnalyzeStrategy.execute(instruction);
|
instructionAnalyzeStrategy.execute(instruction);
|
||||||
}
|
}
|
||||||
@@ -182,8 +182,8 @@ public class PseudocodeTraverser {
|
|||||||
|
|
||||||
List<Instruction> instructions = getInstructions(pseudocode, traversalOrder);
|
List<Instruction> instructions = getInstructions(pseudocode, traversalOrder);
|
||||||
for (Instruction instruction : instructions) {
|
for (Instruction instruction : instructions) {
|
||||||
if (instruction instanceof LocalDeclarationInstruction) {
|
if (instruction instanceof LocalFunctionDeclarationInstruction) {
|
||||||
traverse(((LocalDeclarationInstruction) instruction).getBody(), traversalOrder, edgesMap,
|
traverse(((LocalFunctionDeclarationInstruction) instruction).getBody(), traversalOrder, edgesMap,
|
||||||
instructionDataAnalyzeStrategy);
|
instructionDataAnalyzeStrategy);
|
||||||
}
|
}
|
||||||
Edges<D> edges = edgesMap.get(instruction);
|
Edges<D> edges = edgesMap.get(instruction);
|
||||||
|
|||||||
@@ -86,8 +86,8 @@ public class PseudocodeVariablesData {
|
|||||||
Set<VariableDescriptor> declaredVariables = Sets.newHashSet();
|
Set<VariableDescriptor> declaredVariables = Sets.newHashSet();
|
||||||
declaredVariables.addAll(getUpperLevelDeclaredVariables(pseudocode));
|
declaredVariables.addAll(getUpperLevelDeclaredVariables(pseudocode));
|
||||||
|
|
||||||
for (LocalDeclarationInstruction localDeclarationInstruction : pseudocode.getLocalDeclarations()) {
|
for (LocalFunctionDeclarationInstruction localFunctionDeclarationInstruction : pseudocode.getLocalDeclarations()) {
|
||||||
Pseudocode localPseudocode = localDeclarationInstruction.getBody();
|
Pseudocode localPseudocode = localFunctionDeclarationInstruction.getBody();
|
||||||
declaredVariables.addAll(getUpperLevelDeclaredVariables(localPseudocode));
|
declaredVariables.addAll(getUpperLevelDeclaredVariables(localPseudocode));
|
||||||
}
|
}
|
||||||
return declaredVariables;
|
return declaredVariables;
|
||||||
@@ -154,8 +154,8 @@ public class PseudocodeVariablesData {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
for (LocalDeclarationInstruction localDeclarationInstruction : pseudocode.getLocalDeclarations()) {
|
for (LocalFunctionDeclarationInstruction localFunctionDeclarationInstruction : pseudocode.getLocalDeclarations()) {
|
||||||
Pseudocode localPseudocode = localDeclarationInstruction.getBody();
|
Pseudocode localPseudocode = localFunctionDeclarationInstruction.getBody();
|
||||||
Map<Instruction, Edges<Map<VariableDescriptor, VariableInitState>>> initializersForLocalDeclaration = getVariableInitializers(localPseudocode);
|
Map<Instruction, Edges<Map<VariableDescriptor, VariableInitState>>> initializersForLocalDeclaration = getVariableInitializers(localPseudocode);
|
||||||
|
|
||||||
for (Instruction instruction : initializersForLocalDeclaration.keySet()) {
|
for (Instruction instruction : initializersForLocalDeclaration.keySet()) {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public class InstructionVisitor {
|
|||||||
visitInstructionWithNext(instruction);
|
visitInstructionWithNext(instruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void visitLocalDeclarationInstruction(LocalDeclarationInstruction instruction) {
|
public void visitLocalFunctionDeclarationInstruction(LocalFunctionDeclarationInstruction instruction) {
|
||||||
visitInstructionWithNext(instruction);
|
visitInstructionWithNext(instruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -74,7 +74,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
|||||||
JetControlFlowInstructionsGeneratorWorker worker = popBuilder(subroutine);
|
JetControlFlowInstructionsGeneratorWorker worker = popBuilder(subroutine);
|
||||||
if (!builders.empty()) {
|
if (!builders.empty()) {
|
||||||
JetControlFlowInstructionsGeneratorWorker builder = builders.peek();
|
JetControlFlowInstructionsGeneratorWorker builder = builders.peek();
|
||||||
LocalDeclarationInstruction instruction = new LocalDeclarationInstruction(subroutine, worker.getPseudocode());
|
LocalFunctionDeclarationInstruction instruction = new LocalFunctionDeclarationInstruction(subroutine, worker.getPseudocode());
|
||||||
builder.add(instruction);
|
builder.add(instruction);
|
||||||
}
|
}
|
||||||
return worker.getPseudocode();
|
return worker.getPseudocode();
|
||||||
|
|||||||
+4
-5
@@ -18,18 +18,17 @@ package org.jetbrains.jet.lang.cfg.pseudocode;
|
|||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.psi.JetDeclaration;
|
|
||||||
import org.jetbrains.jet.lang.psi.JetElement;
|
import org.jetbrains.jet.lang.psi.JetElement;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
public class LocalDeclarationInstruction extends InstructionWithNext {
|
public class LocalFunctionDeclarationInstruction extends InstructionWithNext {
|
||||||
|
|
||||||
private final Pseudocode body;
|
private final Pseudocode body;
|
||||||
private Instruction sink;
|
private Instruction sink;
|
||||||
|
|
||||||
public LocalDeclarationInstruction(@NotNull JetElement element, Pseudocode body) {
|
public LocalFunctionDeclarationInstruction(@NotNull JetElement element, Pseudocode body) {
|
||||||
super(element);
|
super(element);
|
||||||
this.body = body;
|
this.body = body;
|
||||||
}
|
}
|
||||||
@@ -55,7 +54,7 @@ public class LocalDeclarationInstruction extends InstructionWithNext {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void accept(InstructionVisitor visitor) {
|
public void accept(InstructionVisitor visitor) {
|
||||||
visitor.visitLocalDeclarationInstruction(this);
|
visitor.visitLocalFunctionDeclarationInstruction(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -65,6 +64,6 @@ public class LocalDeclarationInstruction extends InstructionWithNext {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Instruction createCopy() {
|
protected Instruction createCopy() {
|
||||||
return new LocalDeclarationInstruction((JetDeclaration) element, body);
|
return new LocalFunctionDeclarationInstruction(element, body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@ public interface Pseudocode {
|
|||||||
JetElement getCorrespondingElement();
|
JetElement getCorrespondingElement();
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
Set<LocalDeclarationInstruction> getLocalDeclarations();
|
Set<LocalFunctionDeclarationInstruction> getLocalDeclarations();
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
List<Instruction> getInstructions();
|
List<Instruction> getInstructions();
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public class PseudocodeImpl implements Pseudocode {
|
|||||||
private final List<Instruction> mutableInstructionList = new ArrayList<Instruction>();
|
private final List<Instruction> mutableInstructionList = new ArrayList<Instruction>();
|
||||||
private final List<Instruction> instructions = new ArrayList<Instruction>();
|
private final List<Instruction> instructions = new ArrayList<Instruction>();
|
||||||
|
|
||||||
private Set<LocalDeclarationInstruction> localDeclarations = null;
|
private Set<LocalFunctionDeclarationInstruction> localDeclarations = null;
|
||||||
//todo getters
|
//todo getters
|
||||||
private final Map<JetElement, Instruction> representativeInstructions = new HashMap<JetElement, Instruction>();
|
private final Map<JetElement, Instruction> representativeInstructions = new HashMap<JetElement, Instruction>();
|
||||||
private final Map<JetExpression, LoopInfo> loopInfo = Maps.newHashMap();
|
private final Map<JetExpression, LoopInfo> loopInfo = Maps.newHashMap();
|
||||||
@@ -99,7 +99,7 @@ public class PseudocodeImpl implements Pseudocode {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Set<LocalDeclarationInstruction> getLocalDeclarations() {
|
public Set<LocalFunctionDeclarationInstruction> getLocalDeclarations() {
|
||||||
if (localDeclarations == null) {
|
if (localDeclarations == null) {
|
||||||
localDeclarations = getLocalDeclarations(this);
|
localDeclarations = getLocalDeclarations(this);
|
||||||
}
|
}
|
||||||
@@ -107,12 +107,12 @@ public class PseudocodeImpl implements Pseudocode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static Set<LocalDeclarationInstruction> getLocalDeclarations(@NotNull Pseudocode pseudocode) {
|
private static Set<LocalFunctionDeclarationInstruction> getLocalDeclarations(@NotNull Pseudocode pseudocode) {
|
||||||
Set<LocalDeclarationInstruction> localDeclarations = Sets.newLinkedHashSet();
|
Set<LocalFunctionDeclarationInstruction> localDeclarations = Sets.newLinkedHashSet();
|
||||||
for (Instruction instruction : pseudocode.getInstructions()) {
|
for (Instruction instruction : pseudocode.getInstructions()) {
|
||||||
if (instruction instanceof LocalDeclarationInstruction) {
|
if (instruction instanceof LocalFunctionDeclarationInstruction) {
|
||||||
localDeclarations.add((LocalDeclarationInstruction) instruction);
|
localDeclarations.add((LocalFunctionDeclarationInstruction) instruction);
|
||||||
localDeclarations.addAll(getLocalDeclarations(((LocalDeclarationInstruction)instruction).getBody()));
|
localDeclarations.addAll(getLocalDeclarations(((LocalFunctionDeclarationInstruction)instruction).getBody()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return localDeclarations;
|
return localDeclarations;
|
||||||
@@ -287,7 +287,7 @@ public class PseudocodeImpl implements Pseudocode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitLocalDeclarationInstruction(LocalDeclarationInstruction instruction) {
|
public void visitLocalFunctionDeclarationInstruction(LocalFunctionDeclarationInstruction instruction) {
|
||||||
((PseudocodeImpl)instruction.getBody()).postProcess();
|
((PseudocodeImpl)instruction.getBody()).postProcess();
|
||||||
instruction.setNext(getSinkInstruction());
|
instruction.setNext(getSinkInstruction());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public abstract class AbstractControlFlowTest extends KotlinTestWithEnvironment
|
|||||||
for (JetDeclaration declaration : declarations) {
|
for (JetDeclaration declaration : declarations) {
|
||||||
Pseudocode pseudocode = PseudocodeUtil.generatePseudocode(declaration, bindingContext);
|
Pseudocode pseudocode = PseudocodeUtil.generatePseudocode(declaration, bindingContext);
|
||||||
data.put(declaration, pseudocode);
|
data.put(declaration, pseudocode);
|
||||||
for (LocalDeclarationInstruction instruction : pseudocode.getLocalDeclarations()) {
|
for (LocalFunctionDeclarationInstruction instruction : pseudocode.getLocalDeclarations()) {
|
||||||
Pseudocode localPseudocode = instruction.getBody();
|
Pseudocode localPseudocode = instruction.getBody();
|
||||||
data.put(localPseudocode.getCorrespondingElement(), localPseudocode);
|
data.put(localPseudocode.getCorrespondingElement(), localPseudocode);
|
||||||
}
|
}
|
||||||
@@ -228,9 +228,9 @@ public abstract class AbstractControlFlowTest extends KotlinTestWithEnvironment
|
|||||||
}
|
}
|
||||||
for (int i = 0, instructionsSize = instructions.size(); i < instructionsSize; i++) {
|
for (int i = 0, instructionsSize = instructions.size(); i < instructionsSize; i++) {
|
||||||
Instruction instruction = instructions.get(i);
|
Instruction instruction = instructions.get(i);
|
||||||
if (instruction instanceof LocalDeclarationInstruction) {
|
if (instruction instanceof LocalFunctionDeclarationInstruction) {
|
||||||
LocalDeclarationInstruction localDeclarationInstruction = (LocalDeclarationInstruction) instruction;
|
LocalFunctionDeclarationInstruction localFunctionDeclarationInstruction = (LocalFunctionDeclarationInstruction) instruction;
|
||||||
locals.add((PseudocodeImpl) localDeclarationInstruction.getBody());
|
locals.add((PseudocodeImpl) localFunctionDeclarationInstruction.getBody());
|
||||||
}
|
}
|
||||||
for (PseudocodeImpl.PseudocodeLabel label: labels) {
|
for (PseudocodeImpl.PseudocodeLabel label: labels) {
|
||||||
if (label.getTargetInstructionIndex() == i) {
|
if (label.getTargetInstructionIndex() == i) {
|
||||||
@@ -251,7 +251,7 @@ public abstract class AbstractControlFlowTest extends KotlinTestWithEnvironment
|
|||||||
for (Instruction fromInst : instructions) {
|
for (Instruction fromInst : instructions) {
|
||||||
fromInst.accept(new InstructionVisitor() {
|
fromInst.accept(new InstructionVisitor() {
|
||||||
@Override
|
@Override
|
||||||
public void visitLocalDeclarationInstruction(LocalDeclarationInstruction instruction) {
|
public void visitLocalFunctionDeclarationInstruction(LocalFunctionDeclarationInstruction instruction) {
|
||||||
int index = count[0];
|
int index = count[0];
|
||||||
// instruction.getBody().dumpSubgraph(out, "subgraph cluster_" + index, count, "color=blue;\nlabel = \"f" + index + "\";", nodeToName);
|
// 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(((PseudocodeImpl)instruction.getBody()).getAllInstructions().get(0)), null);
|
||||||
@@ -336,7 +336,7 @@ public abstract class AbstractControlFlowTest extends KotlinTestWithEnvironment
|
|||||||
else if (node instanceof UnsupportedElementInstruction) {
|
else if (node instanceof UnsupportedElementInstruction) {
|
||||||
shape = "box, fillcolor=red, style=filled";
|
shape = "box, fillcolor=red, style=filled";
|
||||||
}
|
}
|
||||||
else if (node instanceof LocalDeclarationInstruction) {
|
else if (node instanceof LocalFunctionDeclarationInstruction) {
|
||||||
shape = "Mcircle";
|
shape = "Mcircle";
|
||||||
}
|
}
|
||||||
else if (node instanceof SubroutineEnterInstruction || node instanceof SubroutineExitInstruction) {
|
else if (node instanceof SubroutineEnterInstruction || node instanceof SubroutineExitInstruction) {
|
||||||
|
|||||||
Reference in New Issue
Block a user