Skip to content

Commit

Permalink
Fix switch statements not adding SSA successors
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredlll08 committed Jan 24, 2025
1 parent a70f335 commit 8987ae9
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ public CompilingStatement compile(StatementCompiler compiler, CodeBlock lastBloc
Compiling result = new Compiling(compiler, value, tail);
StatementCompiler innerScope = compiler.forLoop(result);

CodeBlock next = new CodeBlock();
CodeBlock next = lastBlock.createNext();
for (ParsedSwitchCase switchCase : cases) {
CodeBlock current = next;
next = new CodeBlock();
current.addSuccessor(tail);
next = lastBlock.createNext();
result.continueBlock = next;
result.cases.add(switchCase.compile(innerScope, current));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#output: Hello World

val field = "Hello World";

switch field {
case "Hello World":
println("Hello World");
break;
case "Goodbye World":
println("this is bad");
break;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#output: Hello World

val field = "Hello World";

switch(field) {
case "Hello World":
println("Hello World");
break;
case "Goodbye World":
println("this is bad");
break;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#output: Hello World

val field = "Hello World";

if true {
switch field {
case "Hello World":
println("Hello World");
break;
case "Goodbye World":
println("this is bad");
break;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#output: Hello World

val field = "Hello World";

if false {} else {
switch field {
case "Hello World":
println("Hello World");
break;
case "Goodbye World":
println("this is bad");
break;
}
}

0 comments on commit 8987ae9

Please sign in to comment.