Skip to content

Commit

Permalink
[PExplicit] Support continue statement
Browse files Browse the repository at this point in the history
Remove unreachable code after receive case block
  • Loading branch information
aman-goel committed Apr 11, 2024
1 parent 3f1315f commit dcaf6bc
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,10 @@ private bool WriteStmt(Function function, CompilationContext context, StringWrit
context.WriteLine(output, "break;");
break;

case ContinueStmt _:
context.WriteLine(output, "continue;");
break;

case CompoundStmt compoundStmt:
foreach (var subStmt in compoundStmt.Statements)
{
Expand Down Expand Up @@ -1106,9 +1110,13 @@ private void WriteContinuation(CompilationContext context, StringWriter output,
context.WriteLine(output, $"{GetPExplicitType(local.Type)} {CompilationContext.GetVar(local.Name)} = {GetDefaultValue(local.Type)};");
}
}
allCasesExited &= WriteStmt(continuation, context, output, caseContext, caseFun.Body);
bool caseExited = WriteStmt(continuation, context, output, caseContext, caseFun.Body);
allCasesExited &= caseExited;
context.WriteLine(output, "}");
context.WriteLine(output, "break;");
if (!caseExited)
{
context.WriteLine(output, "break;");
}
}
context.WriteLine(output, "default:");
context.WriteLine(output, "{");
Expand Down

0 comments on commit dcaf6bc

Please sign in to comment.