1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 12:32:20 +02:00

Added GetAllocSize to FlexibleArrayAttribute

This commit is contained in:
Brian Fiete 2022-08-28 06:57:02 -07:00
parent 9ba19e4cd7
commit ec4ccb2e9c

View file

@ -108,7 +108,10 @@ namespace System
if ((field.FieldType == null) || (!field.FieldType.IsSizedArray) || (field.FieldType.Size != 0))
Runtime.FatalError("Type must end in a zero-sized array");
var elementType = (field.FieldType as SizedArrayType).UnderlyingType;
Compiler.EmitTypeBody(type, scope $"public {elementType}* {mName} mut => (({elementType}*)((uint8*)&this + Math.Align(typeof(Self).Size, typeof({elementType}).Align)));");
Compiler.EmitTypeBody(type, scope $"""
public {elementType}* {mName} mut => (({elementType}*)((uint8*)&this + Math.Align(typeof(Self).Size, typeof({elementType}).Align)));
public static int GetAllocSize(int arrayCount) => Math.Align(typeof(Self).Size, typeof({elementType}).Align) + typeof({elementType}).Size*arrayCount;
""");
}
}
}