...
This commit is contained in:
@@ -7,9 +7,8 @@ public static class QBE
|
|||||||
public static async Task<string?> Invoke(string ssa)
|
public static async Task<string?> Invoke(string ssa)
|
||||||
{
|
{
|
||||||
using var process = new Process();
|
using var process = new Process();
|
||||||
process.StartInfo = new ProcessStartInfo
|
process.StartInfo = new ProcessStartInfo("qbe")
|
||||||
{
|
{
|
||||||
FileName = "qbe",
|
|
||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
RedirectStandardInput = true,
|
RedirectStandardInput = true,
|
||||||
RedirectStandardOutput = true,
|
RedirectStandardOutput = true,
|
||||||
|
|||||||
@@ -200,16 +200,19 @@ public static class QBEGenerator
|
|||||||
{
|
{
|
||||||
case BoundArrayInitializerNode arrayInitializer:
|
case BoundArrayInitializerNode arrayInitializer:
|
||||||
{
|
{
|
||||||
|
_writer.WriteDebugLocation(arrayInitializer);
|
||||||
EmitStore(source.Type, EmitUnwrap(EmitArrayInitializer(arrayInitializer)), destinationPointer);
|
EmitStore(source.Type, EmitUnwrap(EmitArrayInitializer(arrayInitializer)), destinationPointer);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case BoundStructInitializerNode structInitializer:
|
case BoundStructInitializerNode structInitializer:
|
||||||
{
|
{
|
||||||
|
_writer.WriteDebugLocation(structInitializer);
|
||||||
EmitStructInitializer(structInitializer, destinationPointer);
|
EmitStructInitializer(structInitializer, destinationPointer);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case BoundLiteralNode { Kind: LiteralKind.String } literal:
|
case BoundLiteralNode { Kind: LiteralKind.String } literal:
|
||||||
{
|
{
|
||||||
|
_writer.WriteDebugLocation(literal);
|
||||||
EmitStore(source.Type, EmitUnwrap(EmitLiteral(literal)), destinationPointer);
|
EmitStore(source.Type, EmitUnwrap(EmitLiteral(literal)), destinationPointer);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -521,6 +524,7 @@ public static class QBEGenerator
|
|||||||
builder.Append($"({string.Join(", ", parameterStrings)})");
|
builder.Append($"({string.Join(", ", parameterStrings)})");
|
||||||
|
|
||||||
_writer.StartFunction(builder.ToString());
|
_writer.StartFunction(builder.ToString());
|
||||||
|
_writer.WriteDebugLocation(debugNode);
|
||||||
|
|
||||||
var parameterVars = parameters.Select(parameter => new Variable(parameter.Name, new Val("%" + parameter.Name, parameter.Type, ValKind.Direct))).ToList();
|
var parameterVars = parameters.Select(parameter => new Variable(parameter.Name, new Val("%" + parameter.Name, parameter.Type, ValKind.Direct))).ToList();
|
||||||
|
|
||||||
@@ -566,6 +570,8 @@ public static class QBEGenerator
|
|||||||
|
|
||||||
private static void EmitStatement(BoundStatementNode statement)
|
private static void EmitStatement(BoundStatementNode statement)
|
||||||
{
|
{
|
||||||
|
_writer.WriteDebugLocation(statement);
|
||||||
|
|
||||||
switch (statement)
|
switch (statement)
|
||||||
{
|
{
|
||||||
case BoundAssignmentNode assignment:
|
case BoundAssignmentNode assignment:
|
||||||
@@ -714,6 +720,7 @@ public static class QBEGenerator
|
|||||||
|
|
||||||
private static Val EmitExpression(BoundExpressionNode expression)
|
private static Val EmitExpression(BoundExpressionNode expression)
|
||||||
{
|
{
|
||||||
|
_writer.WriteDebugLocation(expression);
|
||||||
return expression switch
|
return expression switch
|
||||||
{
|
{
|
||||||
BoundAddressOfNode addressOf => EmitAddressOf(addressOf),
|
BoundAddressOfNode addressOf => EmitAddressOf(addressOf),
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ internal class QBEWriter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WriteDebugLocation(BoundNode node)
|
public void WriteDebugLocation(BoundNode node)
|
||||||
{
|
{
|
||||||
var firstToken = node.Tokens.FirstOrDefault();
|
var firstToken = node.Tokens.FirstOrDefault();
|
||||||
if (firstToken != null)
|
if (firstToken != null)
|
||||||
|
|||||||
Reference in New Issue
Block a user