1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 03:52:19 +02:00

Made custom allocators work with pointers to structs, give proper errors

This commit is contained in:
Brian Fiete 2021-06-24 09:50:13 -07:00
parent bea4fe007a
commit 392b2e0b6c

View file

@ -8375,7 +8375,17 @@ BfIRValue BfModule::AllocBytes(BfAstNode* refNode, const BfAllocTarget& allocTar
else if (allocTarget.mCustomAllocator)
{
auto customTypeInst = allocTarget.mCustomAllocator.mType->ToTypeInstance();
if (customTypeInst != NULL)
if (customTypeInst == NULL)
{
if (allocTarget.mCustomAllocator.mType->IsStructPtr())
customTypeInst = allocTarget.mCustomAllocator.mType->GetUnderlyingType()->ToTypeInstance();
}
if (customTypeInst == NULL)
{
Fail(StrFormat("Type '%s' cannot be used as a custom allocator", TypeToString(allocTarget.mCustomAllocator.mType).c_str()), refNode);
}
else
{
BfTypedValueExpression typeValueExpr;
String allocMethodName = "Alloc";