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

Support for IntToPtr and PtrToInt const copying

This commit is contained in:
Brian Fiete 2021-11-14 18:23:48 -08:00
parent 8d29a35947
commit 5a3c0eaf39
2 changed files with 43 additions and 0 deletions

View file

@ -716,6 +716,29 @@ BfIRValue BfIRConstHolder::CreateConst(BfConstant* fromConst, BfIRConstHolder* f
else
return CreateConstNull();
}
else if (fromConst->mConstType == BfConstType_PtrToInt)
{
auto fromPtrToInt = (BfConstantPtrToInt*)fromConst;
auto fromTarget = fromHolder->GetConstantById(fromPtrToInt->mTarget);
auto copiedTarget = CreateConst(fromTarget, fromHolder);
auto ptrToInt = mTempAlloc.Alloc<BfConstantPtrToInt>();
ptrToInt->mConstType = BfConstType_PtrToInt;
ptrToInt->mTarget = copiedTarget.mId;
ptrToInt->mToTypeCode = fromPtrToInt->mToTypeCode;
copiedConst = (BfConstant*)ptrToInt;
}
else if (fromConst->mConstType == BfConstType_IntToPtr)
{
auto fromPtrToInt = (BfConstantIntToPtr*)fromConst;
auto fromTarget = fromHolder->GetConstantById(fromPtrToInt->mTarget);
auto copiedTarget = CreateConst(fromTarget, fromHolder);
auto ptrToInt = mTempAlloc.Alloc<BfConstantIntToPtr>();
ptrToInt->mConstType = BfConstType_IntToPtr;
ptrToInt->mTarget = copiedTarget.mId;
ptrToInt->mToType = fromPtrToInt->mToType;
copiedConst = (BfConstant*)ptrToInt;
}
else
{
BF_FATAL("not handled");