Support codegen of empty do-while-loop
#KT-3009 In Progress
This commit is contained in:
@@ -429,7 +429,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
if (body != null) {
|
if (body != null) {
|
||||||
gen(body, Type.VOID_TYPE);
|
gen(body, Type.VOID_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
v.goTo(condition);
|
v.goTo(condition);
|
||||||
|
|
||||||
v.mark(end);
|
v.mark(end);
|
||||||
@@ -465,7 +465,10 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
conditionValue = generateBlock(statements, true);
|
conditionValue = generateBlock(statements, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
gen(body, Type.VOID_TYPE);
|
if (body != null) {
|
||||||
|
gen(body, Type.VOID_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
conditionValue = gen(condition);
|
conditionValue = gen(condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
fun box(): String {
|
||||||
|
do while (false);
|
||||||
|
|
||||||
|
var x = 0
|
||||||
|
do while (x++<5);
|
||||||
|
if (x != 6) return "Fail: $x"
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
@@ -1427,6 +1427,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
doTest("compiler/testData/codegen/box/controlStructures/doWhileFib.kt");
|
doTest("compiler/testData/codegen/box/controlStructures/doWhileFib.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("emptyDoWhile.kt")
|
||||||
|
public void testEmptyDoWhile() throws Exception {
|
||||||
|
doTest("compiler/testData/codegen/box/controlStructures/emptyDoWhile.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("emptyIf.kt")
|
@TestMetadata("emptyIf.kt")
|
||||||
public void testEmptyIf() throws Exception {
|
public void testEmptyIf() throws Exception {
|
||||||
doTest("compiler/testData/codegen/box/controlStructures/emptyIf.kt");
|
doTest("compiler/testData/codegen/box/controlStructures/emptyIf.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user