This repository has been archived on 2025-10-23. You can view files and clone it, but cannot push or open issues or pull requests.
Files
nub-lang-archive/src/compilation/CLI/QBE.cs
nub31 ab66916217 ...
2025-06-26 11:58:45 +02:00

38 lines
1006 B
C#

using System.Diagnostics;
namespace CLI;
public static class QBE
{
public static async Task<string?> Invoke(string ssa)
{
using var qbeProcess = new Process();
qbeProcess.StartInfo = new ProcessStartInfo
{
FileName = "qbe",
UseShellExecute = false,
RedirectStandardInput = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
};
qbeProcess.Start();
await qbeProcess.StandardInput.WriteAsync(ssa);
qbeProcess.StandardInput.Close();
await qbeProcess.WaitForExitAsync();
var qbeErrors = await qbeProcess.StandardError.ReadToEndAsync();
if (!string.IsNullOrWhiteSpace(qbeErrors))
{
await Console.Error.WriteLineAsync("qbe error:\n" + qbeErrors);
}
var asm = await qbeProcess.StandardOutput.ReadToEndAsync();
return qbeProcess.ExitCode == 0 ? asm : null;
}
}