check deeply inner local declarations added
This commit is contained in:
@@ -54,7 +54,6 @@ public class JetControlFlowProcessor {
|
||||
this.trace = trace;
|
||||
}
|
||||
|
||||
//todo
|
||||
public Pseudocode generatePseudocode(@NotNull JetDeclaration subroutine) {
|
||||
Pseudocode pseudocode = generate(subroutine);
|
||||
((PseudocodeImpl)pseudocode).postProcess();
|
||||
@@ -64,7 +63,7 @@ public class JetControlFlowProcessor {
|
||||
return pseudocode;
|
||||
}
|
||||
|
||||
public Pseudocode generate(@NotNull JetDeclaration subroutine) {
|
||||
private Pseudocode generate(@NotNull JetDeclaration subroutine) {
|
||||
builder.enterSubroutine(subroutine);
|
||||
if (subroutine instanceof JetDeclarationWithBody) {
|
||||
JetDeclarationWithBody declarationWithBody = (JetDeclarationWithBody) subroutine;
|
||||
|
||||
@@ -108,12 +108,18 @@ public class PseudocodeImpl implements Pseudocode {
|
||||
@Override
|
||||
public Set<LocalDeclarationInstruction> getLocalDeclarations() {
|
||||
if (localDeclarations == null) {
|
||||
localDeclarations = Sets.newLinkedHashSet();
|
||||
//todo look recursively inside local declarations
|
||||
for (Instruction instruction : instructions) {
|
||||
if (instruction instanceof LocalDeclarationInstruction) {
|
||||
localDeclarations.add((LocalDeclarationInstruction) instruction);
|
||||
}
|
||||
localDeclarations = getLocalDeclarations(this);
|
||||
}
|
||||
return localDeclarations;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Set<LocalDeclarationInstruction> getLocalDeclarations(@NotNull Pseudocode pseudocode) {
|
||||
Set<LocalDeclarationInstruction> localDeclarations = Sets.newHashSet();
|
||||
for (Instruction instruction : pseudocode.getInstructions()) {
|
||||
if (instruction instanceof LocalDeclarationInstruction) {
|
||||
localDeclarations.add((LocalDeclarationInstruction) instruction);
|
||||
localDeclarations.addAll(getLocalDeclarations(((LocalDeclarationInstruction)instruction).getBody()));
|
||||
}
|
||||
}
|
||||
return localDeclarations;
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package c
|
||||
|
||||
fun test() {
|
||||
val x = 10
|
||||
fun inner1() {
|
||||
fun inner2() {
|
||||
fun inner3() {
|
||||
val <!UNUSED_VARIABLE!>y<!> = x
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user