...
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user