mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Emit marker fixes - idSpan fix, persistent opening, specialized squiggle
This commit is contained in:
parent
bbd0fe8779
commit
866bddde2e
17 changed files with 237 additions and 65 deletions
|
@ -9919,7 +9919,7 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetCollapseRegions(BfCompiler* bfCo
|
|||
*valuePtr = foundTypeIds.mCount - 1;
|
||||
outString += "+";
|
||||
|
||||
if (emitParser == NULL)
|
||||
if ((emitParser == NULL) || (!emitParser->mIsEmitted))
|
||||
{
|
||||
String typeName;
|
||||
outString += typeInst->mTypeDef->mProject->mName;
|
||||
|
@ -9989,7 +9989,8 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetCollapseRegions(BfCompiler* bfCo
|
|||
|
||||
int startLine = 0;
|
||||
int startLineChar = 0;
|
||||
emitParser->GetLineCharAtIdx(kv.mValue.mSrcStart, startLine, startLineChar);
|
||||
if (kv.mValue.mSrcStart >= 0)
|
||||
emitParser->GetLineCharAtIdx(kv.mValue.mSrcStart, startLine, startLineChar);
|
||||
|
||||
int srcEnd = kv.mValue.mSrcEnd - 1;
|
||||
while (srcEnd >= kv.mValue.mSrcStart)
|
||||
|
@ -10006,8 +10007,9 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetCollapseRegions(BfCompiler* bfCo
|
|||
|
||||
int endLine = 0;
|
||||
int endLineChar = 0;
|
||||
emitParser->GetLineCharAtIdx(srcEnd, endLine, endLineChar);
|
||||
outString += StrFormat("e%d,%d,%d,%d\n", embedId, charIdx, startLine, endLine + 1);
|
||||
if (srcEnd >= 0)
|
||||
emitParser->GetLineCharAtIdx(srcEnd, endLine, endLineChar);
|
||||
outString += StrFormat("e%d,%d,%d,%d,%d\n", embedId, charIdx, startLine, endLine + 1, typeInst->mTypeDef->mTypeDeclaration->GetParser()->mTextVersion);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10036,7 +10038,7 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetCollapseRegions(BfCompiler* bfCo
|
|||
if (embedId == -1)
|
||||
continue;
|
||||
|
||||
outString += StrFormat("e%d,%d,%d,%d\n", embedId, kv.mKey, 0, 0);
|
||||
outString += StrFormat("e%d,%d,%d,%d,%d\n", embedId, kv.mKey, 0, 0, -1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -2955,7 +2955,7 @@ bool BfModule::IsSkippingExtraResolveChecks()
|
|||
return mCompiler->IsSkippingExtraResolveChecks();
|
||||
}
|
||||
|
||||
bool BfModule::AddErrorContext(StringImpl& errorString, BfAstNode* refNode, bool& isWhileSpecializing, bool isWarning)
|
||||
bool BfModule::AddErrorContext(StringImpl& errorString, BfAstNode* refNode, BfWhileSpecializingFlags& isWhileSpecializing, bool isWarning)
|
||||
{
|
||||
bool isWhileSpecializingMethod = false;
|
||||
if ((mIsSpecialModule) && (mModuleName == "vdata"))
|
||||
|
@ -3011,19 +3011,20 @@ bool BfModule::AddErrorContext(StringImpl& errorString, BfAstNode* refNode, bool
|
|||
if (isSpecializedMethod)
|
||||
{
|
||||
errorString += StrFormat("\n while specializing method '%s'", MethodToString(methodInstance).c_str());
|
||||
isWhileSpecializing = true;
|
||||
isWhileSpecializing = (BfWhileSpecializingFlags)(isWhileSpecializing | BfWhileSpecializingFlag_Method);
|
||||
isWhileSpecializingMethod = true;
|
||||
}
|
||||
else if ((methodInstance != NULL) && (methodInstance->mIsForeignMethodDef))
|
||||
{
|
||||
errorString += StrFormat("\n while implementing default interface method '%s'", MethodToString(methodInstance).c_str());
|
||||
isWhileSpecializing = true;
|
||||
isWhileSpecializing = (BfWhileSpecializingFlags)(isWhileSpecializing | BfWhileSpecializingFlag_Method);
|
||||
isWhileSpecializingMethod = true;
|
||||
}
|
||||
else if ((mCurTypeInstance->IsGenericTypeInstance()) && (!mCurTypeInstance->IsUnspecializedType()))
|
||||
|
||||
if ((mCurTypeInstance->IsGenericTypeInstance()) && (!mCurTypeInstance->IsUnspecializedType()))
|
||||
{
|
||||
errorString += StrFormat("\n while specializing type '%s'", TypeToString(mCurTypeInstance).c_str());
|
||||
isWhileSpecializing = true;
|
||||
isWhileSpecializing = (BfWhileSpecializingFlags)(isWhileSpecializing | BfWhileSpecializingFlag_Type);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -3059,7 +3060,7 @@ bool BfModule::AddErrorContext(StringImpl& errorString, BfAstNode* refNode, bool
|
|||
if ((!isWhileSpecializing) && (mCurTypeInstance != NULL) && ((mCurTypeInstance->IsGenericTypeInstance()) && (!mCurTypeInstance->IsUnspecializedType())))
|
||||
{
|
||||
errorString += StrFormat("\n while specializing type '%s'", TypeToString(mCurTypeInstance).c_str());
|
||||
isWhileSpecializing = true;
|
||||
isWhileSpecializing = (BfWhileSpecializingFlags)(isWhileSpecializing | BfWhileSpecializingFlag_Type);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -3131,7 +3132,7 @@ BfError* BfModule::Fail(const StringImpl& error, BfAstNode* refNode, bool isPers
|
|||
BfLogSysM("BfModule::Fail module %p type %p %s\n", this, mCurTypeInstance, error.c_str());
|
||||
|
||||
String errorString = error;
|
||||
bool isWhileSpecializing = false;
|
||||
BfWhileSpecializingFlags isWhileSpecializing = BfWhileSpecializingFlag_None;
|
||||
if (!AddErrorContext(errorString, refNode, isWhileSpecializing, false))
|
||||
return NULL;
|
||||
|
||||
|
@ -3276,10 +3277,10 @@ BfError* BfModule::Warn(int warningNum, const StringImpl& warning, BfAstNode* re
|
|||
refNode = BfNodeToNonTemporary(refNode);
|
||||
|
||||
String warningString = warning;
|
||||
bool isWhileSpecializing = false;
|
||||
BfWhileSpecializingFlags isWhileSpecializing = BfWhileSpecializingFlag_None;
|
||||
if (!AddErrorContext(warningString, refNode, isWhileSpecializing, true))
|
||||
return NULL;
|
||||
bool deferWarning = isWhileSpecializing;
|
||||
bool deferWarning = isWhileSpecializing != BfWhileSpecializingFlag_None;
|
||||
|
||||
if ((mCurMethodState != NULL) && (mCurMethodState->mMixinState != NULL))
|
||||
{
|
||||
|
|
|
@ -1558,7 +1558,7 @@ public:
|
|||
void SetFail();
|
||||
void VerifyOnDemandMethods();
|
||||
bool IsSkippingExtraResolveChecks();
|
||||
bool AddErrorContext(StringImpl& errorString, BfAstNode* refNode, bool& isWhileSpecializing, bool isWarning);
|
||||
bool AddErrorContext(StringImpl& errorString, BfAstNode* refNode, BfWhileSpecializingFlags& isWhileSpecializing, bool isWarning);
|
||||
CeDbgState* GetCeDbgState();
|
||||
BfError* Fail(const StringImpl& error, BfAstNode* refNode = NULL, bool isPersistent = false, bool deferError = false);
|
||||
BfError* FailInternal(const StringImpl& error, BfAstNode* refNode = NULL);
|
||||
|
|
|
@ -2507,7 +2507,7 @@ void BfModule::HandleCEAttributes(CeEmitContext* ceEmitContext, BfTypeInstance*
|
|||
if ((typeInstance->mCeTypeInfo != NULL) && (typeInstance->mCeTypeInfo->mNext == NULL))
|
||||
typeInstance->mCeTypeInfo->mNext = new BfCeTypeInfo();
|
||||
if ((typeInstance->mCeTypeInfo != NULL) && (typeInstance->mCeTypeInfo->mNext != NULL))
|
||||
typeInstance->mCeTypeInfo->mNext->mFailed = true;
|
||||
typeInstance->mCeTypeInfo->mNext->mFastFinished = true;
|
||||
if (typeInstance->mCeTypeInfo != NULL)
|
||||
{
|
||||
BfCeTypeEmitEntry* entry = NULL;
|
||||
|
@ -2528,6 +2528,8 @@ void BfModule::HandleCEAttributes(CeEmitContext* ceEmitContext, BfTypeInstance*
|
|||
entry.mEmitData = ceEmitContext->mEmitData;
|
||||
typeInstance->mCeTypeInfo->mNext->mTypeIFaceMap[typeId] = entry;
|
||||
}
|
||||
else if ((ceEmitContext->mFailed) && (typeInstance->mCeTypeInfo != NULL))
|
||||
typeInstance->mCeTypeInfo->mFailed = true;
|
||||
|
||||
if ((ceEmitContext->HasEmissions()) && (!mCompiler->mFastFinish))
|
||||
{
|
||||
|
@ -2787,7 +2789,7 @@ void BfModule::ExecuteCEOnCompile(CeEmitContext* ceEmitContext, BfTypeInstance*
|
|||
if ((typeInstance->mCeTypeInfo != NULL) && (typeInstance->mCeTypeInfo->mNext == NULL))
|
||||
typeInstance->mCeTypeInfo->mNext = new BfCeTypeInfo();
|
||||
if ((typeInstance->mCeTypeInfo != NULL) && (typeInstance->mCeTypeInfo->mNext != NULL))
|
||||
typeInstance->mCeTypeInfo->mNext->mFailed = true;
|
||||
typeInstance->mCeTypeInfo->mNext->mFastFinished = true;
|
||||
if (typeInstance->mCeTypeInfo != NULL)
|
||||
{
|
||||
BfCeTypeEmitEntry* entry = NULL;
|
||||
|
@ -2808,6 +2810,8 @@ void BfModule::ExecuteCEOnCompile(CeEmitContext* ceEmitContext, BfTypeInstance*
|
|||
entry.mEmitData = ceEmitContext->mEmitData;
|
||||
typeInstance->mCeTypeInfo->mNext->mOnCompileMap[methodDef->mIdx] = entry;
|
||||
}
|
||||
else if ((ceEmitContext->mFailed) && (typeInstance->mCeTypeInfo != NULL))
|
||||
typeInstance->mCeTypeInfo->mFailed = true;
|
||||
|
||||
if (!ceEmitContext->mEmitData.IsEmpty())
|
||||
{
|
||||
|
@ -4798,6 +4802,8 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
|||
|
||||
if (typeInstance->mCeTypeInfo != NULL)
|
||||
{
|
||||
bool prevHadEmissions = !typeInstance->mCeTypeInfo->mEmitSourceMap.IsEmpty();
|
||||
|
||||
if (typeInstance->mCeTypeInfo->mNext != NULL)
|
||||
{
|
||||
BfLogSysM("Type %p injecting next ceTypeInfo %p into ceTypeInfo %p\n", typeInstance, typeInstance->mCeTypeInfo->mNext, typeInstance->mCeTypeInfo);
|
||||
|
@ -4828,16 +4834,16 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
|||
|
||||
typeInstance->mCeTypeInfo->mNext->mHash = hashCtx.Finish128();
|
||||
|
||||
if (!typeInstance->mCeTypeInfo->mNext->mFailed)
|
||||
if (!typeInstance->mCeTypeInfo->mNext->mFastFinished)
|
||||
{
|
||||
if ((typeInstance->mCeTypeInfo->mHash != typeInstance->mCeTypeInfo->mNext->mHash) && (!typeInstance->mCeTypeInfo->mHash.IsZero()))
|
||||
mContext->QueueMidCompileRebuildDependentTypes(typeInstance, "comptime hash changed");
|
||||
typeInstance->mCeTypeInfo->mEmitSourceMap = typeInstance->mCeTypeInfo->mNext->mEmitSourceMap;
|
||||
typeInstance->mCeTypeInfo->mOnCompileMap = typeInstance->mCeTypeInfo->mNext->mOnCompileMap;
|
||||
typeInstance->mCeTypeInfo->mTypeIFaceMap = typeInstance->mCeTypeInfo->mNext->mTypeIFaceMap;
|
||||
typeInstance->mCeTypeInfo->mHash = typeInstance->mCeTypeInfo->mNext->mHash;
|
||||
typeInstance->mCeTypeInfo->mHash = typeInstance->mCeTypeInfo->mNext->mHash;
|
||||
}
|
||||
|
||||
|
||||
delete typeInstance->mCeTypeInfo->mNext;
|
||||
typeInstance->mCeTypeInfo->mNext = NULL;
|
||||
}
|
||||
|
@ -4851,6 +4857,15 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
|||
typeInstance->mCeTypeInfo->mTypeIFaceMap.Clear();
|
||||
typeInstance->mCeTypeInfo->mHash = Val128();
|
||||
}
|
||||
|
||||
if ((typeInstance->mCeTypeInfo->mFailed) &&
|
||||
(prevHadEmissions) &&
|
||||
(typeInstance->mCeTypeInfo->mEmitSourceMap.IsEmpty()))
|
||||
{
|
||||
// Just add a marker to retain the previous open emits
|
||||
typeInstance->mCeTypeInfo->mEmitSourceMap[-1] = BfCeTypeEmitSource();
|
||||
}
|
||||
typeInstance->mCeTypeInfo->mFailed = false;
|
||||
}
|
||||
|
||||
if ((typeInstance->mCeTypeInfo != NULL) && (!typeInstance->mCeTypeInfo->mPendingInterfaces.IsEmpty()))
|
||||
|
|
|
@ -345,6 +345,7 @@ BfParser::BfParser(BfSystem* bfSystem, BfProject* bfProject) : BfSource(bfSystem
|
|||
|
||||
gParserCount++;
|
||||
|
||||
mTextVersion = -1;
|
||||
mEmbedKind = BfSourceEmbedKind_None;
|
||||
mUsingCache = false;
|
||||
mParserData = NULL;
|
||||
|
@ -3850,9 +3851,10 @@ static BfAstNode* FindDebugExpressionNode(BfAstNode* checkNode, int cursorIdx)
|
|||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
BF_EXPORT void BF_CALLTYPE BfParser_SetSource(BfParser* bfParser, const char* data, int length, const char* fileName)
|
||||
BF_EXPORT void BF_CALLTYPE BfParser_SetSource(BfParser* bfParser, const char* data, int length, const char* fileName, int textVersion)
|
||||
{
|
||||
bfParser->mFileName = fileName;
|
||||
bfParser->mTextVersion = textVersion;
|
||||
bfParser->SetSource(data, length);
|
||||
}
|
||||
|
||||
|
|
|
@ -160,6 +160,7 @@ public:
|
|||
BfPassInstance* mPassInstance;
|
||||
BfSourceClassifier* mSourceClassifier;
|
||||
String mFileName;
|
||||
int mTextVersion;
|
||||
BfSourceEmbedKind mEmbedKind;
|
||||
bool mAwaitingDelete;
|
||||
|
||||
|
|
|
@ -4102,7 +4102,7 @@ BF_EXPORT int BF_CALLTYPE BfPassInstance_GetErrorCount(BfPassInstance* bfPassIns
|
|||
return (int)bfPassInstance->mErrors.size();
|
||||
}
|
||||
|
||||
BF_EXPORT const char* BF_CALLTYPE BfPassInstance_GetErrorData(BfPassInstance* bfPassInstance, int errorIdx, int& outCode, bool& outIsWarning, bool& outIsAfter, bool& outIsDeferred, bool& outIsWhileSpecializing, bool& outIsPersistent,
|
||||
BF_EXPORT const char* BF_CALLTYPE BfPassInstance_GetErrorData(BfPassInstance* bfPassInstance, int errorIdx, int& outCode, bool& outIsWarning, bool& outIsAfter, bool& outIsDeferred, BfWhileSpecializingFlags& outIsWhileSpecializing, bool& outIsPersistent,
|
||||
char*& projectName, char*& fileName, int& outSrcStart, int& outSrcEnd, int* outLine, int* outColumn, int& outMoreInfoCount)
|
||||
{
|
||||
BfError* bfError = bfPassInstance->mErrors[errorIdx];
|
||||
|
|
|
@ -166,6 +166,13 @@ struct BfAtomCompositeEquals
|
|||
}
|
||||
};
|
||||
|
||||
enum BfWhileSpecializingFlags : int8
|
||||
{
|
||||
BfWhileSpecializingFlag_None = 0,
|
||||
BfWhileSpecializingFlag_Type = 1,
|
||||
BfWhileSpecializingFlag_Method = 2
|
||||
};
|
||||
|
||||
enum BfCompilerOptionFlags
|
||||
{
|
||||
BfCompilerOptionFlag_EmitDebugInfo = 1,
|
||||
|
@ -1480,7 +1487,7 @@ class BfError : public BfErrorBase
|
|||
public:
|
||||
bool mIsAfter;
|
||||
bool mIsPersistent;
|
||||
bool mIsWhileSpecializing;
|
||||
BfWhileSpecializingFlags mIsWhileSpecializing;
|
||||
bool mIgnore;
|
||||
BfProject* mProject;
|
||||
String mError;
|
||||
|
@ -1489,10 +1496,10 @@ public:
|
|||
|
||||
public:
|
||||
BfError()
|
||||
{
|
||||
{
|
||||
mIsAfter = false;
|
||||
mIsPersistent = false;
|
||||
mIsWhileSpecializing = false;
|
||||
mIsWhileSpecializing = BfWhileSpecializingFlag_None;
|
||||
mIgnore = false;
|
||||
mProject = NULL;
|
||||
mWarningNumber = 0;
|
||||
|
|
|
@ -1011,6 +1011,7 @@ public:
|
|||
Array<int> mPendingInterfaces;
|
||||
Dictionary<CeRebuildKey, CeRebuildValue> mRebuildMap;
|
||||
Val128 mHash;
|
||||
bool mFastFinished;
|
||||
bool mFailed;
|
||||
bool mMayHaveUniqueEmitLocations;
|
||||
BfCeTypeInfo* mNext;
|
||||
|
@ -1018,6 +1019,7 @@ public:
|
|||
public:
|
||||
BfCeTypeInfo()
|
||||
{
|
||||
mFastFinished = false;
|
||||
mFailed = false;
|
||||
mMayHaveUniqueEmitLocations = false;
|
||||
mNext = NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue