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

Improved nullptr tostring

This commit is contained in:
Brian Fiete 2020-08-10 06:39:31 -07:00
parent 6b67a4493d
commit 2a2b944fdd

View file

@ -666,7 +666,10 @@ BfIRValue BfIRConstHolder::CreateConst(BfConstant* fromConst, BfIRConstHolder* f
} }
else if (fromConst->mTypeCode == BfTypeCode_NullPtr) else if (fromConst->mTypeCode == BfTypeCode_NullPtr)
{ {
return CreateConstNull(); if (fromConst->mIRType)
return CreateConstNull(fromConst->mIRType);
else
return CreateConstNull();
} }
else else
{ {
@ -1217,19 +1220,13 @@ String BfIRBuilder::ToString(BfIRValue irValue)
} }
else if (constant->mTypeCode == BfTypeCode_NullPtr) else if (constant->mTypeCode == BfTypeCode_NullPtr)
{ {
if (constant->mInt32 == -1) String ret = "null";
return "null"; if (constant->mIRType)
else if (mBfIRCodeGen != NULL)
{ {
auto llvmType = mBfIRCodeGen->GetLLVMType(constant->mInt32); ret += "\n";
std::string outStr; ret += ToString(constant->mIRType);
llvm::raw_string_ostream strStream(outStr);
llvmType->print(strStream);
strStream.flush();
return StrFormat("null(%s)", outStr.c_str());
} }
else return ret;
return "???";
} }
else if (constant->mTypeCode == BfTypeCode_Boolean) else if (constant->mTypeCode == BfTypeCode_Boolean)
{ {
@ -1414,12 +1411,14 @@ String BfIRBuilder::ToString(BfIRType irType)
return str; return str;
} }
#endif #endif
else if (irType.mKind == BfIRTypeData::TypeKind_TypeId)
{
return StrFormat("Type Id %d", irType.mId);
}
else else
{ {
return "???"; return "Type ???";
} }
} }
String BfIRBuilder::ToString(BfIRFunction irFunc) String BfIRBuilder::ToString(BfIRFunction irFunc)