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

Method GenerateModuleName_Type

IDEHelper/Compiler/BfContext.cpp:2886–2993  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2884}
2885
2886void BfContext::GenerateModuleName_Type(BfType* type, StringImpl& name)
2887{
2888 if ((!name.empty()) && (name[name.length() - 1] != '_'))
2889 name += '_';
2890
2891 if (type->IsBoxed())
2892 {
2893 auto boxedType = (BfBoxedType*)type;
2894 if (boxedType->IsBoxedStructPtr())
2895 name += "BOXPTR_";
2896 else
2897 name += "BOX_";
2898 GenerateModuleName_Type(boxedType->mElementType, name);
2899 return;
2900 }
2901
2902 if (type->IsPrimitiveType())
2903 {
2904 auto primType = (BfPrimitiveType*)type;
2905 name += primType->mTypeDef->mName->mString;
2906 return;
2907 }
2908
2909 if (type->IsPointer())
2910 {
2911 auto ptrType = (BfPointerType*)type;
2912 name += "PTR_";
2913 GenerateModuleName_Type(ptrType->mElementType, name);
2914 return;
2915 }
2916
2917 if (type->IsTuple())
2918 {
2919 auto tupleType = (BfTypeInstance*)type;
2920 name += "TUPLE_";
2921 for (int fieldIdx = 0; fieldIdx < (int)tupleType->mFieldInstances.size(); fieldIdx++)
2922 {
2923 BfFieldInstance* fieldInstance = &tupleType->mFieldInstances[fieldIdx];
2924 BfFieldDef* fieldDef = fieldInstance->GetFieldDef();
2925 String fieldName = fieldDef->mName;
2926 if ((fieldName[0] < '0') || (fieldName[0] > '9'))
2927 name += StrFormat("U%d@%s", fieldName.length() + 1, fieldName.c_str());
2928 GenerateModuleName_Type(fieldInstance->mResolvedType, name);
2929 }
2930 return;
2931 }
2932
2933 if (type->IsDelegateFromTypeRef() || type->IsFunctionFromTypeRef())
2934 {
2935 auto typeInst = type->ToTypeInstance();
2936 auto delegateInfo = type->GetDelegateInfo();
2937
2938 auto methodDef = typeInst->mTypeDef->mMethods[0];
2939
2940 if (type->IsDelegateFromTypeRef())
2941 name += "DELEGATE_";
2942 else
2943 name += "FUNCTION_";

Callers

nothing calls this directly

Calls 15

IsBoxedStructPtrMethod · 0.80
GetFieldDefMethod · 0.80
emptyMethod · 0.45
lengthMethod · 0.45
IsBoxedMethod · 0.45
IsPrimitiveTypeMethod · 0.45
IsPointerMethod · 0.45
IsTupleMethod · 0.45
sizeMethod · 0.45
c_strMethod · 0.45
IsDelegateFromTypeRefMethod · 0.45
IsFunctionFromTypeRefMethod · 0.45

Tested by

no test coverage detected