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

Method AddErrorContext

IDEHelper/Compiler/BfModule.cpp:3123–3232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3121}
3122
3123bool BfModule::AddErrorContext(StringImpl& errorString, BfAstNode* refNode, BfWhileSpecializingFlags& isWhileSpecializing, bool isWarning)
3124{
3125 bool isWhileSpecializingMethod = false;
3126 if ((mIsSpecialModule) && (mModuleName == "vdata"))
3127 errorString += StrFormat("\n while generating vdata for project '%s'", mProject->mName.c_str());
3128 if ((mCurMethodInstance != NULL) && (mCurMethodInstance->mMethodDef->mMethodType == BfMethodType_CtorCalcAppend))
3129 errorString += StrFormat("\n while generating append size calculating method");
3130 else if (refNode == NULL)
3131 {
3132 if (mCurTypeInstance != NULL)
3133 errorString += StrFormat("\n while compiling '%s'", TypeToString(mCurTypeInstance, BfTypeNameFlags_None).c_str());
3134 else if (mProject != NULL)
3135 errorString += StrFormat("\n while compiling project '%s'", mProject->mName.c_str());
3136 }
3137
3138 if (mCurTypeInstance != NULL)
3139 {
3140 auto _CheckMethodInstance = [&](BfMethodInstance* methodInstance)
3141 {
3142 // Propogate the fail all the way to the main method (assuming we're in a local method or lambda)
3143 if (isWarning)
3144 methodInstance->mHasWarning = true;
3145 else
3146 methodInstance->mHasFailed = true;
3147
3148 if (!methodInstance->mHasStartedDeclaration)
3149 StartMethodDeclaration(methodInstance, NULL);
3150
3151 bool isSpecializedMethod = ((methodInstance != NULL) && (!methodInstance->mIsUnspecialized) && (methodInstance->mMethodInfoEx != NULL) && (methodInstance->mMethodInfoEx->mMethodGenericArguments.size() != 0));
3152 if (isSpecializedMethod)
3153 {
3154 //auto unspecializedMethod = &mCurMethodInstance->mMethodInstanceGroup->mMethodSpecializationMap.begin()->second;
3155 auto unspecializedMethod = methodInstance->mMethodInstanceGroup->mDefault;
3156 if (unspecializedMethod == methodInstance)
3157 {
3158 // This is a local method inside a generic method
3159 BF_ASSERT(methodInstance->mMethodDef->mIsLocalMethod);
3160 }
3161 else
3162 {
3163 if (isWarning)
3164 {
3165 if (unspecializedMethod->mHasWarning)
3166 return false; // At least SOME error has already been reported
3167 }
3168 else
3169 {
3170 if (unspecializedMethod->mHasFailed)
3171 return false; // At least SOME error has already been reported
3172 }
3173 }
3174 }
3175
3176 if (isSpecializedMethod)
3177 {
3178 errorString += StrFormat("\n while specializing method '%s'", MethodToString(methodInstance).c_str());
3179 isWhileSpecializing = (BfWhileSpecializingFlags)(isWhileSpecializing | BfWhileSpecializingFlag_Method);
3180 isWhileSpecializingMethod = true;

Callers

nothing calls this directly

Calls 5

TypeToStringFunction · 0.85
c_strMethod · 0.45
sizeMethod · 0.45
IsGenericTypeInstanceMethod · 0.45
IsUnspecializedTypeMethod · 0.45

Tested by

no test coverage detected