This commit is contained in:
nub31
2025-07-03 20:17:43 +02:00
parent f93ae27437
commit 36cbe3b186
2 changed files with 27 additions and 6 deletions

View File

@@ -827,13 +827,24 @@ public static class QBEGenerator
private static Val EmitDereference(BoundDereferenceNode dereference)
{
var result = EmitUnwrap(EmitExpression(dereference.Expression));
return EmitLoad(dereference.Type, result);
var pointerType = (NubPointerType)dereference.Expression.Type;
var pointer = EmitExpression(dereference.Expression);
// Complex types are already pointers, so no need to load them
if (pointerType.BaseType is NubComplexType)
{
return pointer;
}
return EmitLoad(dereference.Type, EmitUnwrap(pointer));
}
private static Val EmitAddressOf(BoundAddressOfNode addressOf)
{
throw new NotImplementedException();
var value = EmitExpression(addressOf.Expression);
Debug.Assert(value.Kind == ValKind.Pointer);
return new Val(value.Name, addressOf.Type, ValKind.Direct);
}
private static Val EmitBinaryExpression(BoundBinaryExpressionNode binaryExpression)