From bbfa99c9b6cf8a3882a0f15ff0736a972dc89e0c Mon Sep 17 00:00:00 2001 From: Lewis Bruck Date: Fri, 3 Jan 2025 13:42:55 -0800 Subject: [PATCH] Fix odd indenting of "else" in generated Java code Previously, normal if/else statements would be formatted like: if.. { } else { } and if/else blocks with an empty if block would be formatted like: if... {} else { } Made all if/else statments be formatted like if { } else { } --- .../CompilerCore/Backend/Java/MachineGenerator.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Src/PCompiler/CompilerCore/Backend/Java/MachineGenerator.cs b/Src/PCompiler/CompilerCore/Backend/Java/MachineGenerator.cs index a9cbadb52..479a884b9 100644 --- a/Src/PCompiler/CompilerCore/Backend/Java/MachineGenerator.cs +++ b/Src/PCompiler/CompilerCore/Backend/Java/MachineGenerator.cs @@ -445,7 +445,8 @@ private void WriteStmt(IPStmt stmt) if (ifStmt.ThenBranch.Statements.Count == 0) { - Write("{}"); + WriteLine("{"); + WriteLine("}"); } else { @@ -454,7 +455,7 @@ private void WriteStmt(IPStmt stmt) if (ifStmt.ElseBranch != null && ifStmt.ElseBranch.Statements.Count > 0) { - WriteLine(" else "); + WriteLine("else"); WriteStmt(ifStmt.ElseBranch); } break; @@ -964,4 +965,4 @@ private void WriteStructureAccess(IPExpr e) } } -} \ No newline at end of file +}