Bit of cleanup

This commit is contained in:
nub31
2025-07-24 18:57:49 +02:00
parent 9f933be343
commit 7f1e8c7d18
2 changed files with 5 additions and 18 deletions

View File

@@ -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)

View File

@@ -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');