MCPcopy Create free account
hub / github.com/beefytech/Beef / DataToString

Method DataToString

IDEHelper/Compiler/BfModuleTypeUtils.cpp:15767–15939  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15765}
15766
15767void BfModule::DataToString(StringImpl& str, void* ptr, BfType* type)
15768{
15769 if (type->IsPrimitiveType())
15770 {
15771 BfPrimitiveType* primType = (BfPrimitiveType*)type;
15772 BfTypeCode typeCode = primType->GetTypeCode();
15773
15774 if (typeCode == BfTypeCode_IntPtr)
15775 {
15776 if (mSystem->mPtrSize == 8)
15777 typeCode = BfTypeCode_Int64;
15778 else
15779 typeCode = BfTypeCode_Int32;
15780 }
15781 else if (typeCode == BfTypeCode_UIntPtr)
15782 {
15783 if (mSystem->mPtrSize == 8)
15784 typeCode = BfTypeCode_UInt64;
15785 else
15786 typeCode = BfTypeCode_UInt32;
15787 }
15788
15789 switch (typeCode)
15790 {
15791 case BfTypeCode_Boolean:
15792 if (*(uint8*)ptr == 0)
15793 str += "false";
15794 else if (*(uint8*)ptr == 1)
15795 str += "true";
15796 else
15797 str += StrFormat("%d", *(uint8*)ptr);
15798 break;
15799 case BfTypeCode_Int8:
15800 str += StrFormat("%d", *(int8*)ptr);
15801 break;
15802 case BfTypeCode_UInt8:
15803 str += StrFormat("%d", *(uint8*)ptr);
15804 break;
15805 case BfTypeCode_Int16:
15806 str += StrFormat("%d", *(int16*)ptr);
15807 break;
15808 case BfTypeCode_UInt16:
15809 str += StrFormat("%d", *(uint16*)ptr);
15810 break;
15811 case BfTypeCode_Int32:
15812 str += StrFormat("%d", *(int32*)ptr);
15813 break;
15814 case BfTypeCode_Char8:
15815 case BfTypeCode_Char16:
15816 case BfTypeCode_Char32:
15817 {
15818 uint32 c = 0;
15819 if (typeCode == BfTypeCode_Char8)
15820 c = *(uint8*)ptr;
15821 else if (typeCode == BfTypeCode_Char16)
15822 c = *(uint16*)ptr;
15823 else if (typeCode == BfTypeCode_Char32)
15824 c = *(uint32*)ptr;

Callers

nothing calls this directly

Calls 5

IsPrimitiveTypeMethod · 0.45
GetTypeCodeMethod · 0.45
IsInstanceOfMethod · 0.45
ToTypeInstanceMethod · 0.45
IsPointerMethod · 0.45

Tested by

no test coverage detected