Rearranged declarations, added missing annotations in JetControlFlowBuilder
This commit is contained in:
@@ -21,14 +21,31 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import org.jetbrains.jet.lang.cfg.pseudocode.Pseudocode;
|
import org.jetbrains.jet.lang.cfg.pseudocode.Pseudocode;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface JetControlFlowBuilder {
|
public interface JetControlFlowBuilder {
|
||||||
void read(@NotNull JetElement element);
|
// Subroutines
|
||||||
void readUnit(@NotNull JetExpression expression);
|
void enterSubroutine(@NotNull JetElement subroutine);
|
||||||
|
|
||||||
// General label management
|
@NotNull
|
||||||
|
Pseudocode exitSubroutine(@NotNull JetElement subroutine);
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
JetElement getCurrentSubroutine();
|
||||||
|
@Nullable
|
||||||
|
JetElement getReturnSubroutine();
|
||||||
|
|
||||||
|
// Entry/exit points
|
||||||
|
@NotNull
|
||||||
|
Label getEntryPoint(@NotNull JetElement labelElement);
|
||||||
|
@NotNull
|
||||||
|
Label getExitPoint(@NotNull JetElement labelElement);
|
||||||
|
|
||||||
|
// Declarations
|
||||||
|
void declare(@NotNull JetParameter parameter);
|
||||||
|
void declare(@NotNull JetVariableDeclaration property);
|
||||||
|
|
||||||
|
// Labels
|
||||||
@NotNull
|
@NotNull
|
||||||
Label createUnboundLabel();
|
Label createUnboundLabel();
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -40,13 +57,14 @@ public interface JetControlFlowBuilder {
|
|||||||
void jump(@NotNull Label label);
|
void jump(@NotNull Label label);
|
||||||
void jumpOnFalse(@NotNull Label label);
|
void jumpOnFalse(@NotNull Label label);
|
||||||
void jumpOnTrue(@NotNull Label label);
|
void jumpOnTrue(@NotNull Label label);
|
||||||
void nondeterministicJump(Label label); // Maybe, jump to label
|
void nondeterministicJump(@NotNull Label label); // Maybe, jump to label
|
||||||
void nondeterministicJump(List<Label> label);
|
void nondeterministicJump(@NotNull List<Label> label);
|
||||||
void jumpToError();
|
void jumpToError();
|
||||||
|
|
||||||
// Entry/exit points
|
void returnValue(@NotNull JetExpression returnExpression, @NotNull JetElement subroutine);
|
||||||
Label getEntryPoint(@NotNull JetElement labelElement);
|
void returnNoValue(@NotNull JetElement returnExpression, @NotNull JetElement subroutine);
|
||||||
Label getExitPoint(@NotNull JetElement labelElement);
|
|
||||||
|
void throwException(@NotNull JetThrowExpression throwExpression);
|
||||||
|
|
||||||
// Loops
|
// Loops
|
||||||
LoopInfo enterLoop(@NotNull JetExpression expression, @Nullable Label loopExitPoint, @Nullable Label conditionEntryPoint);
|
LoopInfo enterLoop(@NotNull JetExpression expression, @Nullable Label loopExitPoint, @Nullable Label conditionEntryPoint);
|
||||||
@@ -55,33 +73,17 @@ public interface JetControlFlowBuilder {
|
|||||||
@Nullable
|
@Nullable
|
||||||
JetElement getCurrentLoop();
|
JetElement getCurrentLoop();
|
||||||
|
|
||||||
// Finally
|
// Try-Finally
|
||||||
void enterTryFinally(@NotNull GenerationTrigger trigger);
|
void enterTryFinally(@NotNull GenerationTrigger trigger);
|
||||||
void exitTryFinally();
|
void exitTryFinally();
|
||||||
|
|
||||||
// Subroutines
|
void repeatPseudocode(@NotNull Label startLabel, @NotNull Label finishLabel);
|
||||||
void enterSubroutine(@NotNull JetElement subroutine);
|
|
||||||
|
|
||||||
Pseudocode exitSubroutine(@NotNull JetElement subroutine);
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
JetElement getCurrentSubroutine();
|
|
||||||
@Nullable
|
|
||||||
JetElement getReturnSubroutine();
|
|
||||||
|
|
||||||
void returnValue(@NotNull JetExpression returnExpression, @NotNull JetElement subroutine);
|
|
||||||
|
|
||||||
void returnNoValue(@NotNull JetElement returnExpression, @NotNull JetElement subroutine);
|
|
||||||
|
|
||||||
void throwException(@NotNull JetThrowExpression throwExpression);
|
|
||||||
|
|
||||||
|
// Reading values
|
||||||
|
void readUnit(@NotNull JetExpression expression);
|
||||||
|
void read(@NotNull JetElement element);
|
||||||
void write(@NotNull JetElement assignment, @NotNull JetElement lValue);
|
void write(@NotNull JetElement assignment, @NotNull JetElement lValue);
|
||||||
|
|
||||||
void declare(@NotNull JetParameter parameter);
|
|
||||||
void declare(@NotNull JetVariableDeclaration property);
|
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
void unsupported(JetElement element);
|
void unsupported(JetElement element);
|
||||||
|
|
||||||
void repeatPseudocode(@NotNull Label startLabel, @NotNull Label finishLabel);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,13 +78,13 @@ public class JetControlFlowBuilderAdapter implements JetControlFlowBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void nondeterministicJump(Label label) {
|
public void nondeterministicJump(@NotNull Label label) {
|
||||||
assert builder != null;
|
assert builder != null;
|
||||||
builder.nondeterministicJump(label);
|
builder.nondeterministicJump(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void nondeterministicJump(List<Label> labels) {
|
public void nondeterministicJump(@NotNull List<Label> labels) {
|
||||||
assert builder != null;
|
assert builder != null;
|
||||||
builder.nondeterministicJump(labels);
|
builder.nondeterministicJump(labels);
|
||||||
}
|
}
|
||||||
@@ -101,11 +101,13 @@ public class JetControlFlowBuilderAdapter implements JetControlFlowBuilder {
|
|||||||
builder.throwException(throwExpression);
|
builder.throwException(throwExpression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public Label getEntryPoint(@NotNull JetElement labelElement) {
|
public Label getEntryPoint(@NotNull JetElement labelElement) {
|
||||||
assert builder != null;
|
assert builder != null;
|
||||||
return builder.getEntryPoint(labelElement);
|
return builder.getEntryPoint(labelElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Label getExitPoint(@NotNull JetElement labelElement) {
|
public Label getExitPoint(@NotNull JetElement labelElement) {
|
||||||
assert builder != null;
|
assert builder != null;
|
||||||
@@ -149,6 +151,7 @@ public class JetControlFlowBuilderAdapter implements JetControlFlowBuilder {
|
|||||||
builder.enterSubroutine(subroutine);
|
builder.enterSubroutine(subroutine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Pseudocode exitSubroutine(@NotNull JetElement subroutine) {
|
public Pseudocode exitSubroutine(@NotNull JetElement subroutine) {
|
||||||
assert builder != null;
|
assert builder != null;
|
||||||
|
|||||||
+7
-3
@@ -67,6 +67,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
|||||||
builder.enterSubroutine(subroutine);
|
builder.enterSubroutine(subroutine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Pseudocode exitSubroutine(@NotNull JetElement subroutine) {
|
public Pseudocode exitSubroutine(@NotNull JetElement subroutine) {
|
||||||
super.exitSubroutine(subroutine);
|
super.exitSubroutine(subroutine);
|
||||||
@@ -165,11 +166,13 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
|||||||
return returnSubroutine;// subroutineInfo.empty() ? null : subroutineInfo.peek().getElement();
|
return returnSubroutine;// subroutineInfo.empty() ? null : subroutineInfo.peek().getElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Label getEntryPoint(@NotNull JetElement labelElement) {
|
public Label getEntryPoint(@NotNull JetElement labelElement) {
|
||||||
return elementToBlockInfo.get(labelElement).getEntryPoint();
|
return elementToBlockInfo.get(labelElement).getEntryPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Label getExitPoint(@NotNull JetElement labelElement) {
|
public Label getExitPoint(@NotNull JetElement labelElement) {
|
||||||
BreakableBlockInfo blockInfo = elementToBlockInfo.get(labelElement);
|
BreakableBlockInfo blockInfo = elementToBlockInfo.get(labelElement);
|
||||||
@@ -201,6 +204,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Pseudocode exitSubroutine(@NotNull JetElement subroutine) {
|
public Pseudocode exitSubroutine(@NotNull JetElement subroutine) {
|
||||||
bindLabel(getExitPoint(subroutine));
|
bindLabel(getExitPoint(subroutine));
|
||||||
@@ -211,7 +215,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
|||||||
pseudocode.addSinkInstruction(new SubroutineSinkInstruction(subroutine, "<SINK>"));
|
pseudocode.addSinkInstruction(new SubroutineSinkInstruction(subroutine, "<SINK>"));
|
||||||
elementToBlockInfo.remove(subroutine);
|
elementToBlockInfo.remove(subroutine);
|
||||||
allBlocks.pop();
|
allBlocks.pop();
|
||||||
return null;
|
return pseudocode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -277,13 +281,13 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void nondeterministicJump(Label label) {
|
public void nondeterministicJump(@NotNull Label label) {
|
||||||
handleJumpInsideTryFinally(label);
|
handleJumpInsideTryFinally(label);
|
||||||
add(new NondeterministicJumpInstruction(label));
|
add(new NondeterministicJumpInstruction(label));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void nondeterministicJump(List<Label> labels) {
|
public void nondeterministicJump(@NotNull List<Label> labels) {
|
||||||
//todo
|
//todo
|
||||||
//handleJumpInsideTryFinally(label);
|
//handleJumpInsideTryFinally(label);
|
||||||
add(new NondeterministicJumpInstruction(labels));
|
add(new NondeterministicJumpInstruction(labels));
|
||||||
|
|||||||
Reference in New Issue
Block a user