Subroutine exit knows when it's an error
This commit is contained in:
+2
-2
@@ -219,9 +219,9 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
|||||||
@Override
|
@Override
|
||||||
public Pseudocode exitSubroutine(@NotNull JetElement subroutine) {
|
public Pseudocode exitSubroutine(@NotNull JetElement subroutine) {
|
||||||
bindLabel(getExitPoint(subroutine));
|
bindLabel(getExitPoint(subroutine));
|
||||||
pseudocode.addExitInstruction(new SubroutineExitInstruction(subroutine, "<END>"));
|
pseudocode.addExitInstruction(new SubroutineExitInstruction(subroutine, false));
|
||||||
bindLabel(error);
|
bindLabel(error);
|
||||||
pseudocode.addErrorInstruction(new SubroutineExitInstruction(subroutine, "<ERROR>"));
|
pseudocode.addErrorInstruction(new SubroutineExitInstruction(subroutine, true));
|
||||||
bindLabel(sink);
|
bindLabel(sink);
|
||||||
pseudocode.addSinkInstruction(new SubroutineSinkInstruction(subroutine, "<SINK>"));
|
pseudocode.addSinkInstruction(new SubroutineSinkInstruction(subroutine, "<SINK>"));
|
||||||
elementToBlockInfo.remove(subroutine);
|
elementToBlockInfo.remove(subroutine);
|
||||||
|
|||||||
+9
-5
@@ -24,18 +24,22 @@ import java.util.Collections;
|
|||||||
|
|
||||||
public class SubroutineExitInstruction extends InstructionImpl {
|
public class SubroutineExitInstruction extends InstructionImpl {
|
||||||
private final JetElement subroutine;
|
private final JetElement subroutine;
|
||||||
private final String debugLabel;
|
private final boolean isError;
|
||||||
private SubroutineSinkInstruction sinkInstruction;
|
private SubroutineSinkInstruction sinkInstruction;
|
||||||
|
|
||||||
public SubroutineExitInstruction(@NotNull JetElement subroutine, @NotNull String debugLabel) {
|
public SubroutineExitInstruction(@NotNull JetElement subroutine, boolean isError) {
|
||||||
this.subroutine = subroutine;
|
this.subroutine = subroutine;
|
||||||
this.debugLabel = debugLabel;
|
this.isError = isError;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JetElement getSubroutine() {
|
public JetElement getSubroutine() {
|
||||||
return subroutine;
|
return subroutine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isError() {
|
||||||
|
return isError;
|
||||||
|
}
|
||||||
|
|
||||||
public void setSink(SubroutineSinkInstruction instruction) {
|
public void setSink(SubroutineSinkInstruction instruction) {
|
||||||
sinkInstruction = (SubroutineSinkInstruction) outgoingEdgeTo(instruction);
|
sinkInstruction = (SubroutineSinkInstruction) outgoingEdgeTo(instruction);
|
||||||
}
|
}
|
||||||
@@ -59,12 +63,12 @@ public class SubroutineExitInstruction extends InstructionImpl {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return debugLabel;
|
return isError ? "<ERROR>" : "<END>";
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
protected Instruction createCopy() {
|
protected Instruction createCopy() {
|
||||||
return new SubroutineExitInstruction(subroutine, debugLabel);
|
return new SubroutineExitInstruction(subroutine, isError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user