This commit is contained in:
nub31
2025-07-22 22:10:31 +02:00
parent 2d2d346da0
commit 4055002a8c
25 changed files with 413 additions and 972 deletions

View File

@@ -1,22 +1,13 @@
using System.Text;
using NubLang.Syntax.Binding.Node;
namespace NubLang.Generation.QBE;
internal class QBEWriter
{
private readonly StringBuilder _builder = new();
private int _currentLine = -1;
public QBEWriter(string debugFile)
{
_builder.AppendLine($"dbgfile \"{debugFile}\"");
_builder.AppendLine();
}
public void StartFunction(string signature)
{
_currentLine = -1;
_builder.Append(signature);
_builder.AppendLine(" {");
_builder.AppendLine("@start");
@@ -27,26 +18,6 @@ internal class QBEWriter
_builder.AppendLine("}");
}
private void WriteDebugLocation(SourceSpan span)
{
var line = span.Start.Line;
if (_currentLine != line)
{
_builder.AppendLine($" dbgloc {line}");
_currentLine = line;
}
}
public void WriteDebugLocation(BoundNode node)
{
var firstToken = node.Tokens.FirstOrDefault();
if (firstToken != null)
{
// WriteDebugLocation(firstToken.Span);
}
}
public void Indented(string value)
{
_builder.Append('\t');