This repository has been archived on 2025-10-24. You can view files and clone it, but cannot push or open issues or pull requests.
Files
nub-lang-archive-2/src/compiler/NubLang.CLI/QBE.cs
nub31 7c64d57cbc ...
2025-07-07 16:45:44 +02:00

37 lines
955 B
C#

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