This commit is contained in:
nub31
2025-08-13 20:01:09 +02:00
parent bdcf0d3e7d
commit 46a2057e43
6 changed files with 41 additions and 35 deletions

View File

@@ -224,6 +224,11 @@ public partial class QBEGenerator
EmitStructInitializer(structInitializer, destinationPointer);
return true;
}
case InterfaceInitializerNode interfaceInitializer:
{
EmitInterfaceInitializer(interfaceInitializer, destinationPointer);
return true;
}
case LiteralNode { Kind: LiteralKind.String } literal:
{
EmitStore(source.Type, EmitUnwrap(EmitLiteral(literal)), destinationPointer);
@@ -250,9 +255,9 @@ public partial class QBEGenerator
}
else
{
if (complexType is StructTypeNode structType)
if (complexType is StructTypeNode or InterfaceTypeNode)
{
EmitMemcpy(value, destinationPointer, SizeOf(structType).ToString());
EmitMemcpy(value, destinationPointer, SizeOf(complexType).ToString());
}
else
{
@@ -261,7 +266,6 @@ public partial class QBEGenerator
ArrayTypeNode arrayType => EmitArraySizeInBytes(arrayType, value),
CStringTypeNode => EmitCStringSizeInBytes(value),
StringTypeNode => EmitStringSizeInBytes(value),
InterfaceTypeNode => 16.ToString(),
_ => throw new ArgumentOutOfRangeException(nameof(source.Type))
};
@@ -311,7 +315,7 @@ public partial class QBEGenerator
ArrayTypeNode arrayType => EmitArraySizeInBytes(arrayType, value),
CStringTypeNode => EmitCStringSizeInBytes(value),
StringTypeNode => EmitStringSizeInBytes(value),
InterfaceTypeNode => 16.ToString(),
InterfaceTypeNode interfaceType => SizeOf(interfaceType).ToString(),
StructTypeNode structType => SizeOf(structType).ToString(),
_ => throw new ArgumentOutOfRangeException(nameof(source.Type))
};
@@ -486,11 +490,6 @@ public partial class QBEGenerator
{
var offset = 0;
// if (structType.InterfaceImplementations.Any())
// {
// offset = 8;
// }
foreach (var field in structType.Fields)
{
var fieldAlignment = AlignmentOf(field);