This commit is contained in:
nub31
2025-06-27 15:55:32 +02:00
parent d9027d6751
commit 19c309c494
20 changed files with 159 additions and 232 deletions

View File

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