Rename class
This commit is contained in:
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.JetNodeTypes;
|
||||
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.PseudocodeImpl;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
@@ -56,8 +56,8 @@ public class JetControlFlowProcessor {
|
||||
public Pseudocode generatePseudocode(@NotNull JetElement subroutine) {
|
||||
Pseudocode pseudocode = generate(subroutine);
|
||||
((PseudocodeImpl) pseudocode).postProcess();
|
||||
for (LocalDeclarationInstruction localDeclarationInstruction : pseudocode.getLocalDeclarations()) {
|
||||
((PseudocodeImpl)localDeclarationInstruction.getBody()).postProcess();
|
||||
for (LocalFunctionDeclarationInstruction localFunctionDeclarationInstruction : pseudocode.getLocalDeclarations()) {
|
||||
((PseudocodeImpl) localFunctionDeclarationInstruction.getBody()).postProcess();
|
||||
}
|
||||
return pseudocode;
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ public class JetFlowInformationProvider {
|
||||
Pseudocode pseudocode = pseudocodeVariablesData.getPseudocode();
|
||||
Map<Instruction, Edges<Map<VariableDescriptor,VariableInitState>>> initializers = pseudocodeVariablesData.getVariableInitializers();
|
||||
recordInitializedVariables(pseudocode, initializers);
|
||||
for (LocalDeclarationInstruction instruction : pseudocode.getLocalDeclarations()) {
|
||||
for (LocalFunctionDeclarationInstruction instruction : pseudocode.getLocalDeclarations()) {
|
||||
recordInitializedVariables(instruction.getBody(), initializers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public class PseudocodeTraverser {
|
||||
}
|
||||
|
||||
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(
|
||||
@@ -99,7 +99,7 @@ public class PseudocodeTraverser {
|
||||
for (Instruction instruction : instructions) {
|
||||
edgesMap.put(instruction, initialEdge);
|
||||
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)) {
|
||||
Pseudocode subroutinePseudocode = ((LocalDeclarationInstruction) instruction).getBody();
|
||||
Pseudocode subroutinePseudocode = ((LocalFunctionDeclarationInstruction) instruction).getBody();
|
||||
collectDataFromSubgraph(subroutinePseudocode, traversalOrder, lookInside, edgesMap, instructionDataMergeStrategy,
|
||||
previousInstructions,
|
||||
changed, true);
|
||||
@@ -168,8 +168,8 @@ public class PseudocodeTraverser {
|
||||
|
||||
List<Instruction> instructions = getInstructions(pseudocode, traversalOrder);
|
||||
for (Instruction instruction : instructions) {
|
||||
if (instruction instanceof LocalDeclarationInstruction) {
|
||||
traverse(((LocalDeclarationInstruction) instruction).getBody(), traversalOrder, instructionAnalyzeStrategy);
|
||||
if (instruction instanceof LocalFunctionDeclarationInstruction) {
|
||||
traverse(((LocalFunctionDeclarationInstruction) instruction).getBody(), traversalOrder, instructionAnalyzeStrategy);
|
||||
}
|
||||
instructionAnalyzeStrategy.execute(instruction);
|
||||
}
|
||||
@@ -182,8 +182,8 @@ public class PseudocodeTraverser {
|
||||
|
||||
List<Instruction> instructions = getInstructions(pseudocode, traversalOrder);
|
||||
for (Instruction instruction : instructions) {
|
||||
if (instruction instanceof LocalDeclarationInstruction) {
|
||||
traverse(((LocalDeclarationInstruction) instruction).getBody(), traversalOrder, edgesMap,
|
||||
if (instruction instanceof LocalFunctionDeclarationInstruction) {
|
||||
traverse(((LocalFunctionDeclarationInstruction) instruction).getBody(), traversalOrder, edgesMap,
|
||||
instructionDataAnalyzeStrategy);
|
||||
}
|
||||
Edges<D> edges = edgesMap.get(instruction);
|
||||
|
||||
@@ -86,8 +86,8 @@ public class PseudocodeVariablesData {
|
||||
Set<VariableDescriptor> declaredVariables = Sets.newHashSet();
|
||||
declaredVariables.addAll(getUpperLevelDeclaredVariables(pseudocode));
|
||||
|
||||
for (LocalDeclarationInstruction localDeclarationInstruction : pseudocode.getLocalDeclarations()) {
|
||||
Pseudocode localPseudocode = localDeclarationInstruction.getBody();
|
||||
for (LocalFunctionDeclarationInstruction localFunctionDeclarationInstruction : pseudocode.getLocalDeclarations()) {
|
||||
Pseudocode localPseudocode = localFunctionDeclarationInstruction.getBody();
|
||||
declaredVariables.addAll(getUpperLevelDeclaredVariables(localPseudocode));
|
||||
}
|
||||
return declaredVariables;
|
||||
@@ -154,8 +154,8 @@ public class PseudocodeVariablesData {
|
||||
});
|
||||
|
||||
|
||||
for (LocalDeclarationInstruction localDeclarationInstruction : pseudocode.getLocalDeclarations()) {
|
||||
Pseudocode localPseudocode = localDeclarationInstruction.getBody();
|
||||
for (LocalFunctionDeclarationInstruction localFunctionDeclarationInstruction : pseudocode.getLocalDeclarations()) {
|
||||
Pseudocode localPseudocode = localFunctionDeclarationInstruction.getBody();
|
||||
Map<Instruction, Edges<Map<VariableDescriptor, VariableInitState>>> initializersForLocalDeclaration = getVariableInitializers(localPseudocode);
|
||||
|
||||
for (Instruction instruction : initializersForLocalDeclaration.keySet()) {
|
||||
|
||||
@@ -21,7 +21,7 @@ public class InstructionVisitor {
|
||||
visitInstructionWithNext(instruction);
|
||||
}
|
||||
|
||||
public void visitLocalDeclarationInstruction(LocalDeclarationInstruction instruction) {
|
||||
public void visitLocalFunctionDeclarationInstruction(LocalFunctionDeclarationInstruction instruction) {
|
||||
visitInstructionWithNext(instruction);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
JetControlFlowInstructionsGeneratorWorker worker = popBuilder(subroutine);
|
||||
if (!builders.empty()) {
|
||||
JetControlFlowInstructionsGeneratorWorker builder = builders.peek();
|
||||
LocalDeclarationInstruction instruction = new LocalDeclarationInstruction(subroutine, worker.getPseudocode());
|
||||
LocalFunctionDeclarationInstruction instruction = new LocalFunctionDeclarationInstruction(subroutine, worker.getPseudocode());
|
||||
builder.add(instruction);
|
||||
}
|
||||
return worker.getPseudocode();
|
||||
|
||||
+4
-5
@@ -18,18 +18,17 @@ package org.jetbrains.jet.lang.cfg.pseudocode;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.JetDeclaration;
|
||||
import org.jetbrains.jet.lang.psi.JetElement;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
public class LocalDeclarationInstruction extends InstructionWithNext {
|
||||
public class LocalFunctionDeclarationInstruction extends InstructionWithNext {
|
||||
|
||||
private final Pseudocode body;
|
||||
private Instruction sink;
|
||||
|
||||
public LocalDeclarationInstruction(@NotNull JetElement element, Pseudocode body) {
|
||||
public LocalFunctionDeclarationInstruction(@NotNull JetElement element, Pseudocode body) {
|
||||
super(element);
|
||||
this.body = body;
|
||||
}
|
||||
@@ -55,7 +54,7 @@ public class LocalDeclarationInstruction extends InstructionWithNext {
|
||||
|
||||
@Override
|
||||
public void accept(InstructionVisitor visitor) {
|
||||
visitor.visitLocalDeclarationInstruction(this);
|
||||
visitor.visitLocalFunctionDeclarationInstruction(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,6 +64,6 @@ public class LocalDeclarationInstruction extends InstructionWithNext {
|
||||
|
||||
@Override
|
||||
protected Instruction createCopy() {
|
||||
return new LocalDeclarationInstruction((JetDeclaration) element, body);
|
||||
return new LocalFunctionDeclarationInstruction(element, body);
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public interface Pseudocode {
|
||||
JetElement getCorrespondingElement();
|
||||
|
||||
@NotNull
|
||||
Set<LocalDeclarationInstruction> getLocalDeclarations();
|
||||
Set<LocalFunctionDeclarationInstruction> getLocalDeclarations();
|
||||
|
||||
@NotNull
|
||||
List<Instruction> getInstructions();
|
||||
|
||||
@@ -74,7 +74,7 @@ public class PseudocodeImpl implements Pseudocode {
|
||||
private final List<Instruction> mutableInstructionList = new ArrayList<Instruction>();
|
||||
private final List<Instruction> instructions = new ArrayList<Instruction>();
|
||||
|
||||
private Set<LocalDeclarationInstruction> localDeclarations = null;
|
||||
private Set<LocalFunctionDeclarationInstruction> localDeclarations = null;
|
||||
//todo getters
|
||||
private final Map<JetElement, Instruction> representativeInstructions = new HashMap<JetElement, Instruction>();
|
||||
private final Map<JetExpression, LoopInfo> loopInfo = Maps.newHashMap();
|
||||
@@ -99,7 +99,7 @@ public class PseudocodeImpl implements Pseudocode {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<LocalDeclarationInstruction> getLocalDeclarations() {
|
||||
public Set<LocalFunctionDeclarationInstruction> getLocalDeclarations() {
|
||||
if (localDeclarations == null) {
|
||||
localDeclarations = getLocalDeclarations(this);
|
||||
}
|
||||
@@ -107,12 +107,12 @@ public class PseudocodeImpl implements Pseudocode {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Set<LocalDeclarationInstruction> getLocalDeclarations(@NotNull Pseudocode pseudocode) {
|
||||
Set<LocalDeclarationInstruction> localDeclarations = Sets.newLinkedHashSet();
|
||||
private static Set<LocalFunctionDeclarationInstruction> getLocalDeclarations(@NotNull Pseudocode pseudocode) {
|
||||
Set<LocalFunctionDeclarationInstruction> localDeclarations = Sets.newLinkedHashSet();
|
||||
for (Instruction instruction : pseudocode.getInstructions()) {
|
||||
if (instruction instanceof LocalDeclarationInstruction) {
|
||||
localDeclarations.add((LocalDeclarationInstruction) instruction);
|
||||
localDeclarations.addAll(getLocalDeclarations(((LocalDeclarationInstruction)instruction).getBody()));
|
||||
if (instruction instanceof LocalFunctionDeclarationInstruction) {
|
||||
localDeclarations.add((LocalFunctionDeclarationInstruction) instruction);
|
||||
localDeclarations.addAll(getLocalDeclarations(((LocalFunctionDeclarationInstruction)instruction).getBody()));
|
||||
}
|
||||
}
|
||||
return localDeclarations;
|
||||
@@ -287,7 +287,7 @@ public class PseudocodeImpl implements Pseudocode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitLocalDeclarationInstruction(LocalDeclarationInstruction instruction) {
|
||||
public void visitLocalFunctionDeclarationInstruction(LocalFunctionDeclarationInstruction instruction) {
|
||||
((PseudocodeImpl)instruction.getBody()).postProcess();
|
||||
instruction.setNext(getSinkInstruction());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user