From 7f1e8c7d18b66298dc3e6af40454d654cb984ac1 Mon Sep 17 00:00:00 2001 From: nub31 Date: Thu, 24 Jul 2025 18:57:49 +0200 Subject: [PATCH] Bit of cleanup --- src/compiler/NubLang/Generation/QBE/QBEGenerator.cs | 11 +++++------ src/compiler/NubLang/Generation/QBE/QBEWriter.cs | 12 ------------ 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/compiler/NubLang/Generation/QBE/QBEGenerator.cs b/src/compiler/NubLang/Generation/QBE/QBEGenerator.cs index f45bafb..c5ec4e6 100644 --- a/src/compiler/NubLang/Generation/QBE/QBEGenerator.cs +++ b/src/compiler/NubLang/Generation/QBE/QBEGenerator.cs @@ -347,8 +347,10 @@ public partial class QBEGenerator var parameterStrings = parameters.Select(x => FuncQBETypeName(x.Type) + $" %{x.Name}"); builder.Append($"({string.Join(", ", parameterStrings)})"); + builder.AppendLine(" {"); + builder.Append("@start"); - _writer.StartFunction(builder.ToString()); + _writer.WriteLine(builder.ToString()); var scope = new Scope(); @@ -362,13 +364,10 @@ public partial class QBEGenerator // Implicit return for void functions if no explicit return has been set if (returnType is VoidTypeNode && body.Statements is [.., not ReturnNode]) { - if (returnType is VoidTypeNode) - { - _writer.Indented("ret"); - } + _writer.Indented("ret"); } - _writer.EndFunction(); + _writer.WriteLine("}"); } private void EmitStructDefinition(StructNode structDef) diff --git a/src/compiler/NubLang/Generation/QBE/QBEWriter.cs b/src/compiler/NubLang/Generation/QBE/QBEWriter.cs index 023eb56..2ff8668 100644 --- a/src/compiler/NubLang/Generation/QBE/QBEWriter.cs +++ b/src/compiler/NubLang/Generation/QBE/QBEWriter.cs @@ -6,18 +6,6 @@ internal class QBEWriter { private readonly StringBuilder _builder = new(); - public void StartFunction(string signature) - { - _builder.Append(signature); - _builder.AppendLine(" {"); - _builder.AppendLine("@start"); - } - - public void EndFunction() - { - _builder.AppendLine("}"); - } - public void Indented(string value) { _builder.Append('\t');