This commit is contained in:
nub31
2025-09-08 17:41:08 +02:00
parent 6216fdb68c
commit edccffd618
2 changed files with 11 additions and 11 deletions

View File

@@ -22,7 +22,7 @@ func main(args: []cstring): i64
let x: Printable = struct Human {
name = "Oliver"
age = 23
}
}
x.print()

View File

@@ -197,28 +197,28 @@ public class QBEGenerator
return size;
}
private bool EmitTryMoveInto(ExpressionNode source, string destinationPointer)
private bool EmitTryMoveInto(ExpressionNode source, string destinationLValue)
{
switch (source)
{
case ArrayInitializerNode arrayInitializer:
{
EmitStore(source.Type, EmitArrayInitializer(arrayInitializer), destinationPointer);
EmitStore(source.Type, EmitArrayInitializer(arrayInitializer), destinationLValue);
return true;
}
case StructInitializerNode structInitializer:
{
EmitStructInitializer(structInitializer, destinationPointer);
EmitStructInitializer(structInitializer, destinationLValue);
return true;
}
case InterfaceInitializerNode interfaceInitializer:
{
EmitInterfaceInitializer(interfaceInitializer, destinationPointer);
EmitInterfaceInitializer(interfaceInitializer, destinationLValue);
return true;
}
case LiteralNode { Kind: LiteralKind.String } literal:
{
EmitStore(source.Type, EmitLiteral(literal), destinationPointer);
EmitStore(source.Type, EmitLiteral(literal), destinationLValue);
return true;
}
}
@@ -226,10 +226,10 @@ public class QBEGenerator
return false;
}
private void EmitCopyIntoOrInitialize(ExpressionNode source, string destinationPointer)
private void EmitCopyIntoOrInitialize(ExpressionNode source, string destinationLValue)
{
// If the source is a value which is not used yet such as an array/struct initializer or literal, we can skip copying
if (EmitTryMoveInto(source, destinationPointer))
if (EmitTryMoveInto(source, destinationLValue))
{
return;
}
@@ -238,13 +238,13 @@ public class QBEGenerator
if (source.Type.IsSimpleType(out var simpleType, out var complexType))
{
EmitStore(simpleType, value, destinationPointer);
EmitStore(simpleType, value, destinationLValue);
}
else
{
if (complexType is StructTypeNode or InterfaceTypeNode)
{
EmitMemcpy(value, destinationPointer, SizeOf(complexType).ToString());
EmitMemcpy(value, destinationLValue, SizeOf(complexType).ToString());
}
else
{
@@ -259,7 +259,7 @@ public class QBEGenerator
var buffer = TmpName();
_writer.Indented($"{buffer} =l alloc8 {size}");
EmitMemcpy(value, buffer, size);
EmitStore(complexType, buffer, destinationPointer);
EmitStore(complexType, buffer, destinationLValue);
}
}
}