CF for throw
This commit is contained in:
+6
-2
@@ -73,10 +73,12 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
private class JetControlFlowInstructionsGeneratorWorker implements JetControlFlowBuilder {
|
||||
|
||||
private final Pseudocode pseudocode;
|
||||
private final Label error;
|
||||
private final JetElement currentSubroutine;
|
||||
|
||||
private JetControlFlowInstructionsGeneratorWorker(@NotNull JetElement scopingElement, @NotNull JetElement currentSubroutine) {
|
||||
this.pseudocode = new Pseudocode(scopingElement);
|
||||
this.error = pseudocode.createLabel("error");
|
||||
this.currentSubroutine = currentSubroutine;
|
||||
}
|
||||
|
||||
@@ -176,7 +178,9 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
@Override
|
||||
public void exitSubroutine(@NotNull JetElement subroutine, boolean functionLiteral) {
|
||||
bindLabel(getExitPoint(subroutine));
|
||||
add(new SubroutineExitInstruction(subroutine));
|
||||
pseudocode.addExitInstruction(new SubroutineExitInstruction(subroutine, "<END>"));
|
||||
bindLabel(error);
|
||||
add(new SubroutineExitInstruction(subroutine, "<ERROR>"));
|
||||
elementToBlockInfo.remove(subroutine);
|
||||
allBlocks.pop();
|
||||
}
|
||||
@@ -241,7 +245,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
|
||||
@Override
|
||||
public void jumpToError(@NotNull JetThrowExpression expression) {
|
||||
// add(new UnconditionalJumpInstruction(error));
|
||||
add(new UnconditionalJumpInstruction(error));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -74,14 +74,15 @@ public class Pseudocode {
|
||||
return instructions;
|
||||
}
|
||||
|
||||
public void addExitInstruction(SubroutineExitInstruction exitInstruction) {
|
||||
addInstruction(exitInstruction);
|
||||
assert this.exitInstruction == null;
|
||||
this.exitInstruction = exitInstruction;
|
||||
}
|
||||
|
||||
public void addInstruction(Instruction instruction) {
|
||||
instructions.add(instruction);
|
||||
instruction.setOwner(this);
|
||||
if (instruction instanceof SubroutineExitInstruction) {
|
||||
SubroutineExitInstruction exitInstruction = (SubroutineExitInstruction) instruction;
|
||||
assert this.exitInstruction == null;
|
||||
this.exitInstruction = exitInstruction;
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -11,9 +11,11 @@ import java.util.Collections;
|
||||
*/
|
||||
public class SubroutineExitInstruction extends InstructionImpl {
|
||||
private final JetElement subroutine;
|
||||
private final String debugLabel;
|
||||
|
||||
public SubroutineExitInstruction(@NotNull JetElement subroutine) {
|
||||
public SubroutineExitInstruction(@NotNull JetElement subroutine, @NotNull String debugLabel) {
|
||||
this.subroutine = subroutine;
|
||||
this.debugLabel = debugLabel;
|
||||
}
|
||||
|
||||
public JetElement getSubroutine() {
|
||||
@@ -33,6 +35,6 @@ public class SubroutineExitInstruction extends InstructionImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "<END>";
|
||||
return debugLabel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,4 +41,6 @@ l5:
|
||||
w(z)
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
|
||||
@@ -6,6 +6,8 @@ l2:
|
||||
r(1)
|
||||
l3:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
== f ==
|
||||
fun f(a : Boolean) : Unit {
|
||||
@@ -67,11 +69,15 @@ l5:
|
||||
r(a || false)
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
l2:
|
||||
<START>
|
||||
r(1)
|
||||
l3:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
== foo ==
|
||||
fun foo(a : Boolean, b : Int) : Unit {}
|
||||
@@ -80,6 +86,8 @@ l0:
|
||||
<START>
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
== genfun ==
|
||||
fun genfun<T>() : Unit {}
|
||||
@@ -88,6 +96,8 @@ l0:
|
||||
<START>
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
== flfun ==
|
||||
fun flfun(f : {() : Any}) : Unit {}
|
||||
@@ -96,4 +106,6 @@ l0:
|
||||
<START>
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
|
||||
@@ -5,4 +5,6 @@ l0:
|
||||
<START>
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
== fail ==
|
||||
fun fail() : Nothing {
|
||||
throw new java.lang.RuntimeException()
|
||||
}
|
||||
---------------------
|
||||
l0:
|
||||
<START>
|
||||
r(new java.lang.RuntimeException())
|
||||
jmp(error)
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
@@ -0,0 +1,3 @@
|
||||
fun fail() : Nothing {
|
||||
throw new java.lang.RuntimeException()
|
||||
}
|
||||
@@ -15,6 +15,8 @@ l2:
|
||||
r(2)
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
== t3 ==
|
||||
fun t3() {
|
||||
@@ -47,6 +49,8 @@ l4:
|
||||
r(2)
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
== anonymous_0 ==
|
||||
{ () =>
|
||||
@@ -69,6 +73,8 @@ l5:
|
||||
l4:
|
||||
l6:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
== t3 ==
|
||||
fun t3() {
|
||||
@@ -97,6 +103,8 @@ l2:
|
||||
r(2)
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
l3:
|
||||
<START>
|
||||
r(2)
|
||||
@@ -111,6 +119,8 @@ l5:
|
||||
l4:
|
||||
l6:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
== anonymous_1 ==
|
||||
{ () =>
|
||||
@@ -143,6 +153,8 @@ l6:
|
||||
r(2)
|
||||
l3:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
== t3 ==
|
||||
fun t3() {
|
||||
@@ -172,6 +184,8 @@ l0:
|
||||
})
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
l2:
|
||||
<START>
|
||||
jmp?(l4)
|
||||
@@ -191,6 +205,8 @@ l6:
|
||||
r(2)
|
||||
l3:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
== t3 ==
|
||||
fun t3() {
|
||||
@@ -231,6 +247,8 @@ l2:
|
||||
read (Unit)
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
== t3 ==
|
||||
fun t3() {
|
||||
@@ -272,6 +290,8 @@ l2:
|
||||
r(2)
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
== t3 ==
|
||||
fun t3() {
|
||||
@@ -311,6 +331,8 @@ l2:
|
||||
r(2)
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
== t3 ==
|
||||
fun t3(a : Int) {
|
||||
@@ -354,6 +376,8 @@ l2:
|
||||
read (Unit)
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
== t3 ==
|
||||
fun t3(a : Int) {
|
||||
@@ -398,6 +422,8 @@ l2:
|
||||
r(2)
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
== t3 ==
|
||||
fun t3(a : Int) {
|
||||
@@ -440,6 +466,8 @@ l2:
|
||||
r(2)
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
== tf ==
|
||||
fun tf() {
|
||||
@@ -463,4 +491,6 @@ l2:
|
||||
ret(*) l1
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
|
||||
@@ -67,4 +67,6 @@ l13:
|
||||
r(14)
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
|
||||
@@ -16,6 +16,8 @@ l8:
|
||||
l7:
|
||||
l9:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
== anonymous_0 ==
|
||||
{a =>
|
||||
@@ -35,6 +37,8 @@ l4:
|
||||
ret(*) l5
|
||||
l5:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
== nonlocals1 ==
|
||||
fun nonlocals1(a : Boolean, b : Boolean) : Any? {
|
||||
@@ -80,6 +84,8 @@ l3:
|
||||
r(1.lng)
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
l4:
|
||||
<START>
|
||||
r(2)
|
||||
@@ -87,4 +93,6 @@ l4:
|
||||
ret(*) l5
|
||||
l5:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
|
||||
@@ -19,6 +19,8 @@ l2:
|
||||
read (Unit)
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
== dowhile ==
|
||||
fun dowhile() {
|
||||
@@ -39,4 +41,6 @@ l2:
|
||||
read (Unit)
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
|
||||
@@ -13,4 +13,6 @@ l2:
|
||||
r(false || (return false))
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
|
||||
@@ -6,4 +6,6 @@ l0:
|
||||
r(1)
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
<ERROR>
|
||||
=====================
|
||||
|
||||
Reference in New Issue
Block a user