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