|
@@ -506,7 +506,10 @@ void BfModule::CheckInjectNewRevision(BfTypeInstance* typeInstance)
|
|
{
|
|
{
|
|
if ((typeInstance != NULL) && (typeInstance->mTypeDef != NULL))
|
|
if ((typeInstance != NULL) && (typeInstance->mTypeDef != NULL))
|
|
{
|
|
{
|
|
- if (typeInstance->mTypeDef->mNextRevision != NULL)
|
|
|
|
|
|
+ auto typeDef = typeInstance->mTypeDef;
|
|
|
|
+ if (typeDef->mEmitParent != NULL)
|
|
|
|
+ typeDef = typeDef->mEmitParent;
|
|
|
|
+ if (typeDef->mNextRevision != NULL)
|
|
{
|
|
{
|
|
// It's possible that our main compiler thread is generating a new typedef while we're autocompleting. This handles that case...
|
|
// It's possible that our main compiler thread is generating a new typedef while we're autocompleting. This handles that case...
|
|
if (typeInstance->mDefineState == BfTypeDefineState_Undefined)
|
|
if (typeInstance->mDefineState == BfTypeDefineState_Undefined)
|
|
@@ -519,8 +522,8 @@ void BfModule::CheckInjectNewRevision(BfTypeInstance* typeInstance)
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- mContext->HandleChangedTypeDef(typeInstance->mTypeDef);
|
|
|
|
- mSystem->InjectNewRevision(typeInstance->mTypeDef);
|
|
|
|
|
|
+ mContext->HandleChangedTypeDef(typeDef);
|
|
|
|
+ mSystem->InjectNewRevision(typeDef);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -529,7 +532,10 @@ void BfModule::CheckInjectNewRevision(BfTypeInstance* typeInstance)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if ((!typeInstance->IsDeleting()) && (!mCompiler->IsAutocomplete()))
|
|
if ((!typeInstance->IsDeleting()) && (!mCompiler->IsAutocomplete()))
|
|
- BF_ASSERT((typeInstance->mTypeDef->mDefState == BfTypeDef::DefState_Defined) || (typeInstance->mTypeDef->mDefState == BfTypeDef::DefState_New));
|
|
|
|
|
|
+ BF_ASSERT((typeDef->mDefState == BfTypeDef::DefState_Defined) || (typeDef->mDefState == BfTypeDef::DefState_New));
|
|
|
|
+
|
|
|
|
+ if ((typeInstance->mTypeDef->mDefState == BfTypeDef::DefState_EmittedDirty) && (typeInstance->mTypeDef->mEmitParent->mNextRevision == NULL))
|
|
|
|
+ mSystem->UpdateEmittedTypeDef(typeInstance->mTypeDef);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -560,6 +566,8 @@ void BfModule::InitType(BfType* resolvedTypeRef, BfPopulateType populateType)
|
|
{
|
|
{
|
|
CheckInjectNewRevision(typeInst);
|
|
CheckInjectNewRevision(typeInst);
|
|
|
|
|
|
|
|
+ BF_ASSERT(!typeInst->mTypeDef->IsEmitted());
|
|
|
|
+
|
|
if (typeInst->mBaseType != NULL)
|
|
if (typeInst->mBaseType != NULL)
|
|
BF_ASSERT((typeInst->mBaseType->mRebuildFlags & BfTypeRebuildFlag_Deleted) == 0);
|
|
BF_ASSERT((typeInst->mBaseType->mRebuildFlags & BfTypeRebuildFlag_Deleted) == 0);
|
|
|
|
|
|
@@ -1126,6 +1134,11 @@ void BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType
|
|
else
|
|
else
|
|
resolvedTypeRef->mTypeId = mCompiler->mCurTypeId++;
|
|
resolvedTypeRef->mTypeId = mCompiler->mCurTypeId++;
|
|
|
|
|
|
|
|
+ if (resolvedTypeRef->mTypeId == 2568)
|
|
|
|
+ {
|
|
|
|
+ NOP;
|
|
|
|
+ }
|
|
|
|
+
|
|
while (resolvedTypeRef->mTypeId >= (int)mContext->mTypes.size())
|
|
while (resolvedTypeRef->mTypeId >= (int)mContext->mTypes.size())
|
|
mContext->mTypes.Add(NULL);
|
|
mContext->mTypes.Add(NULL);
|
|
mContext->mTypes[resolvedTypeRef->mTypeId] = resolvedTypeRef;
|
|
mContext->mTypes[resolvedTypeRef->mTypeId] = resolvedTypeRef;
|
|
@@ -1413,7 +1426,7 @@ void BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType
|
|
|
|
|
|
if (mContext->mBfObjectType == NULL)
|
|
if (mContext->mBfObjectType == NULL)
|
|
{
|
|
{
|
|
- if (typeInstance->mTypeDef == mCompiler->mBfObjectTypeDef)
|
|
|
|
|
|
+ if (typeInstance->IsInstanceOf(mCompiler->mBfObjectTypeDef))
|
|
mContext->mBfObjectType = typeInstance;
|
|
mContext->mBfObjectType = typeInstance;
|
|
else if (mCompiler->mBfObjectTypeDef != NULL)
|
|
else if (mCompiler->mBfObjectTypeDef != NULL)
|
|
ResolveTypeDef(mCompiler->mBfObjectTypeDef);
|
|
ResolveTypeDef(mCompiler->mBfObjectTypeDef);
|
|
@@ -1836,7 +1849,7 @@ int BfModule::GenerateTypeOptions(BfCustomAttributes* customAttributes, BfTypeIn
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if ((!typeInstance->IsBoxed()) && (typeInstance->mTypeDef == mCompiler->mPointerTTypeDef))
|
|
|
|
|
|
+ if ((!typeInstance->IsBoxed()) && (typeInstance->IsInstanceOf(mCompiler->mPointerTTypeDef)))
|
|
{
|
|
{
|
|
BF_ASSERT(typeInstance->IsGenericTypeInstance());
|
|
BF_ASSERT(typeInstance->IsGenericTypeInstance());
|
|
auto innerType = typeInstance->mGenericTypeInfo->mTypeGenericArguments[0];
|
|
auto innerType = typeInstance->mGenericTypeInfo->mTypeGenericArguments[0];
|
|
@@ -1916,7 +1929,7 @@ void BfModule::SetTypeOptions(BfTypeInstance* typeInstance)
|
|
typeInstance->mTypeOptionsIdx = GenerateTypeOptions(typeInstance->mCustomAttributes, typeInstance, true);
|
|
typeInstance->mTypeOptionsIdx = GenerateTypeOptions(typeInstance->mCustomAttributes, typeInstance, true);
|
|
}
|
|
}
|
|
|
|
|
|
-BfCEParseContext BfModule::CEEmitParse(BfTypeInstance* typeInstance, BfTypeDef* activeTypeDef, const StringImpl& src)
|
|
|
|
|
|
+BfCEParseContext BfModule::CEEmitParse(BfTypeInstance* typeInstance, const StringImpl& src)
|
|
{
|
|
{
|
|
BfCEParseContext ceParseContext;
|
|
BfCEParseContext ceParseContext;
|
|
ceParseContext.mFailIdx = mCompiler->mPassInstance->mFailedIdx;
|
|
ceParseContext.mFailIdx = mCompiler->mPassInstance->mFailedIdx;
|
|
@@ -1924,45 +1937,56 @@ BfCEParseContext BfModule::CEEmitParse(BfTypeInstance* typeInstance, BfTypeDef*
|
|
|
|
|
|
bool createdParser = false;
|
|
bool createdParser = false;
|
|
int startSrcIdx = 0;
|
|
int startSrcIdx = 0;
|
|
- if (activeTypeDef->mEmitParser == NULL)
|
|
|
|
|
|
+
|
|
|
|
+ BfParser* emitParser = NULL;
|
|
|
|
+
|
|
|
|
+ if (typeInstance->mTypeDef->mEmitParent == NULL)
|
|
{
|
|
{
|
|
- createdParser = true;
|
|
|
|
- BfParser* parser = new BfParser(mSystem, typeInstance->mTypeDef->mProject);
|
|
|
|
- parser->mIsEmitted = true;
|
|
|
|
- parser->mFileName = typeInstance->mTypeDef->mName->ToString();
|
|
|
|
|
|
+ BF_ASSERT(typeInstance->mTypeDef->mNextRevision == NULL);
|
|
|
|
+
|
|
|
|
+ BfTypeDef* emitTypeDef = new BfTypeDef();
|
|
|
|
+ emitTypeDef->mEmitParent = typeInstance->mTypeDef;
|
|
|
|
+ mSystem->CopyTypeDef(emitTypeDef, typeInstance->mTypeDef);
|
|
|
|
+ emitTypeDef->mDefState = BfTypeDef::DefState_Emitted;
|
|
|
|
+
|
|
|
|
+ typeInstance->mTypeDef = emitTypeDef;
|
|
|
|
+
|
|
|
|
+ createdParser = true;
|
|
|
|
+ emitParser = new BfParser(mSystem, typeInstance->mTypeDef->mProject);
|
|
|
|
+ emitParser->mIsEmitted = true;
|
|
|
|
+ emitParser->mFileName = typeInstance->mTypeDef->mName->ToString();
|
|
|
|
|
|
- BfLogSys(mSystem, "CreateParser (emit): %p\n", parser);
|
|
|
|
|
|
+ BfLogSys(mSystem, "Emit typeDef for type %p created %p parser %p typeDecl %p\n", typeInstance, emitTypeDef, emitParser, emitTypeDef->mTypeDeclaration);
|
|
|
|
|
|
if (mCompiler->mIsResolveOnly)
|
|
if (mCompiler->mIsResolveOnly)
|
|
- parser->mFileName += "$EmitR$";
|
|
|
|
|
|
+ emitParser->mFileName += "$EmitR$";
|
|
else
|
|
else
|
|
- parser->mFileName += "$Emit$";
|
|
|
|
|
|
+ emitParser->mFileName += "$Emit$";
|
|
|
|
|
|
- parser->mFileName += StrFormat("%d", typeInstance->mTypeId);
|
|
|
|
- if (activeTypeDef->mPartialIdx != -1)
|
|
|
|
- parser->mFileName + StrFormat(":%d", activeTypeDef->mPartialIdx);
|
|
|
|
-
|
|
|
|
- parser->mFileName += StrFormat(".bf|%d", typeInstance->mRevision);
|
|
|
|
- activeTypeDef->mEmitParser = parser;
|
|
|
|
- parser->mRefCount++;
|
|
|
|
- parser->SetSource(src.c_str(), src.mLength);
|
|
|
|
|
|
+ emitParser->mFileName += StrFormat("%d", typeInstance->mTypeId);
|
|
|
|
+ emitParser->mFileName += StrFormat(".bf|%d", typeInstance->mRevision);
|
|
|
|
+ emitTypeDef->mSource = emitParser;
|
|
|
|
+ emitParser->mRefCount++;
|
|
|
|
+ emitParser->SetSource(src.c_str(), src.mLength);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
- {
|
|
|
|
- int idx = activeTypeDef->mEmitParser->AllocChars(src.mLength + 1);
|
|
|
|
- memcpy((uint8*)activeTypeDef->mEmitParser->mSrc + idx, src.c_str(), src.mLength + 1);
|
|
|
|
- activeTypeDef->mEmitParser->mSrcIdx = idx;
|
|
|
|
- activeTypeDef->mEmitParser->mSrcLength = idx + src.mLength;
|
|
|
|
- activeTypeDef->mEmitParser->mParserData->mSrcLength = activeTypeDef->mEmitParser->mSrcLength;
|
|
|
|
|
|
+ {
|
|
|
|
+ emitParser = typeInstance->mTypeDef->mSource->ToParser();
|
|
|
|
+
|
|
|
|
+ int idx = emitParser->AllocChars(src.mLength + 1);
|
|
|
|
+ memcpy((uint8*)emitParser->mSrc + idx, src.c_str(), src.mLength + 1);
|
|
|
|
+ emitParser->mSrcIdx = idx;
|
|
|
|
+ emitParser->mSrcLength = idx + src.mLength;
|
|
|
|
+ emitParser->mParserData->mSrcLength = emitParser->mSrcLength;
|
|
}
|
|
}
|
|
|
|
|
|
- activeTypeDef->mEmitParser->Parse(mCompiler->mPassInstance);
|
|
|
|
- activeTypeDef->mEmitParser->FinishSideNodes();
|
|
|
|
|
|
+ emitParser->Parse(mCompiler->mPassInstance);
|
|
|
|
+ emitParser->FinishSideNodes();
|
|
|
|
|
|
if (createdParser)
|
|
if (createdParser)
|
|
{
|
|
{
|
|
AutoCrit crit(mSystem->mDataLock);
|
|
AutoCrit crit(mSystem->mDataLock);
|
|
- mSystem->mParsers.Add(activeTypeDef->mEmitParser);
|
|
|
|
|
|
+ mSystem->mParsers.Add(emitParser);
|
|
}
|
|
}
|
|
|
|
|
|
return ceParseContext;
|
|
return ceParseContext;
|
|
@@ -1981,14 +2005,14 @@ void BfModule::FinishCEParseContext(BfAstNode* refNode, BfTypeInstance* typeInst
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-void BfModule::UpdateCEEmit(CeEmitContext* ceEmitContext, BfTypeInstance* typeInstance, BfTypeDef* activeTypeDef, const StringImpl& ctxString, BfAstNode* refNode)
|
|
|
|
|
|
+void BfModule::UpdateCEEmit(CeEmitContext* ceEmitContext, BfTypeInstance* typeInstance, const StringImpl& ctxString, BfAstNode* refNode)
|
|
{
|
|
{
|
|
if (ceEmitContext->mEmitData.IsEmpty())
|
|
if (ceEmitContext->mEmitData.IsEmpty())
|
|
return;
|
|
return;
|
|
|
|
|
|
String src;
|
|
String src;
|
|
-
|
|
|
|
- if (activeTypeDef->mEmitParser != NULL)
|
|
|
|
|
|
+
|
|
|
|
+ if (typeInstance->mTypeDef->mEmitParent != NULL)
|
|
src += "\n\n";
|
|
src += "\n\n";
|
|
|
|
|
|
src += "// Code emission in ";
|
|
src += "// Code emission in ";
|
|
@@ -1997,27 +2021,30 @@ void BfModule::UpdateCEEmit(CeEmitContext* ceEmitContext, BfTypeInstance* typeIn
|
|
src += ceEmitContext->mEmitData;
|
|
src += ceEmitContext->mEmitData;
|
|
ceEmitContext->mEmitData.Clear();
|
|
ceEmitContext->mEmitData.Clear();
|
|
|
|
|
|
- BfCEParseContext ceParseContext = CEEmitParse(typeInstance, activeTypeDef, src);
|
|
|
|
-
|
|
|
|
- auto typeDeclaration = activeTypeDef->mEmitParser->mAlloc->Alloc<BfTypeDeclaration>();
|
|
|
|
|
|
+ BfCEParseContext ceParseContext = CEEmitParse(typeInstance, src);
|
|
|
|
+ auto emitParser = typeInstance->mTypeDef->mSource->ToParser();
|
|
|
|
+
|
|
|
|
+ auto typeDeclaration = emitParser->mAlloc->Alloc<BfTypeDeclaration>();
|
|
|
|
|
|
BfReducer bfReducer;
|
|
BfReducer bfReducer;
|
|
- bfReducer.mSource = activeTypeDef->mEmitParser;
|
|
|
|
|
|
+ bfReducer.mSource = emitParser;
|
|
bfReducer.mPassInstance = mCompiler->mPassInstance;
|
|
bfReducer.mPassInstance = mCompiler->mPassInstance;
|
|
- bfReducer.mAlloc = activeTypeDef->mEmitParser->mAlloc;
|
|
|
|
|
|
+ bfReducer.mAlloc = emitParser->mAlloc;
|
|
bfReducer.mSystem = mSystem;
|
|
bfReducer.mSystem = mSystem;
|
|
bfReducer.mCurTypeDecl = typeDeclaration;
|
|
bfReducer.mCurTypeDecl = typeDeclaration;
|
|
- typeDeclaration->mDefineNode = activeTypeDef->mEmitParser->mRootNode;
|
|
|
|
|
|
+ typeDeclaration->mDefineNode = emitParser->mRootNode;
|
|
bfReducer.HandleTypeDeclaration(typeDeclaration, NULL);
|
|
bfReducer.HandleTypeDeclaration(typeDeclaration, NULL);
|
|
|
|
|
|
BfDefBuilder defBuilder(mSystem);
|
|
BfDefBuilder defBuilder(mSystem);
|
|
- defBuilder.mCurSource = activeTypeDef->mEmitParser;
|
|
|
|
|
|
+ defBuilder.mCurSource = emitParser;
|
|
defBuilder.mCurTypeDef = typeInstance->mTypeDef;
|
|
defBuilder.mCurTypeDef = typeInstance->mTypeDef;
|
|
defBuilder.mPassInstance = mCompiler->mPassInstance;
|
|
defBuilder.mPassInstance = mCompiler->mPassInstance;
|
|
defBuilder.mIsComptime = true;
|
|
defBuilder.mIsComptime = true;
|
|
defBuilder.DoVisitChild(typeDeclaration->mDefineNode);
|
|
defBuilder.DoVisitChild(typeDeclaration->mDefineNode);
|
|
defBuilder.FinishTypeDef(typeInstance->mTypeDef->mTypeCode == BfTypeCode_Enum);
|
|
defBuilder.FinishTypeDef(typeInstance->mTypeDef->mTypeCode == BfTypeCode_Enum);
|
|
|
|
|
|
|
|
+ typeInstance->mTypeDef->ClearOldMemberSets();
|
|
|
|
+
|
|
FinishCEParseContext(refNode, typeInstance, &ceParseContext);
|
|
FinishCEParseContext(refNode, typeInstance, &ceParseContext);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2106,7 +2133,7 @@ void BfModule::HandleCEAttributes(CeEmitContext* ceEmitContext, BfTypeInstance*
|
|
ctxStr += TypeToString(typeInstance);
|
|
ctxStr += TypeToString(typeInstance);
|
|
ctxStr += " ";
|
|
ctxStr += " ";
|
|
ctxStr += customAttribute.mRef->LocationToString();
|
|
ctxStr += customAttribute.mRef->LocationToString();
|
|
- UpdateCEEmit(ceEmitContext, typeInstance, typeInstance->mTypeDef, ctxStr, customAttribute.mRef);
|
|
|
|
|
|
+ UpdateCEEmit(ceEmitContext, typeInstance, ctxStr, customAttribute.mRef);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2118,17 +2145,17 @@ void BfModule::HandleCEAttributes(CeEmitContext* ceEmitContext, BfTypeInstance*
|
|
void BfModule::CEMixin(BfAstNode* refNode, const StringImpl& code)
|
|
void BfModule::CEMixin(BfAstNode* refNode, const StringImpl& code)
|
|
{
|
|
{
|
|
auto activeTypeDef = mCurMethodInstance->mMethodDef->mDeclaringType;
|
|
auto activeTypeDef = mCurMethodInstance->mMethodDef->mDeclaringType;
|
|
-
|
|
|
|
|
|
+ //auto emitParser = activeTypeDef->mEmitParser;
|
|
|
|
+
|
|
String src;
|
|
String src;
|
|
- if (activeTypeDef->mEmitParser != NULL)
|
|
|
|
|
|
+ if (mCurTypeInstance->mTypeDef->mEmitParent != NULL)
|
|
src += "\n\n";
|
|
src += "\n\n";
|
|
src += "// Code emission in ";
|
|
src += "// Code emission in ";
|
|
src += MethodToString(mCurMethodInstance);
|
|
src += MethodToString(mCurMethodInstance);
|
|
src += "\n";
|
|
src += "\n";
|
|
src += code;
|
|
src += code;
|
|
|
|
|
|
- BfReducer bfReducer;
|
|
|
|
- bfReducer.mSource = activeTypeDef->mEmitParser;
|
|
|
|
|
|
+ BfReducer bfReducer;
|
|
bfReducer.mPassInstance = mCompiler->mPassInstance;
|
|
bfReducer.mPassInstance = mCompiler->mPassInstance;
|
|
bfReducer.mSystem = mSystem;
|
|
bfReducer.mSystem = mSystem;
|
|
bfReducer.mCurTypeDecl = activeTypeDef->mTypeDeclaration;
|
|
bfReducer.mCurTypeDecl = activeTypeDef->mTypeDeclaration;
|
|
@@ -2140,9 +2167,11 @@ void BfModule::CEMixin(BfAstNode* refNode, const StringImpl& code)
|
|
bool wantsDIData = (mBfIRBuilder->DbgHasInfo()) && (mHasFullDebugInfo);
|
|
bool wantsDIData = (mBfIRBuilder->DbgHasInfo()) && (mHasFullDebugInfo);
|
|
mBfIRBuilder->SaveDebugLocation();
|
|
mBfIRBuilder->SaveDebugLocation();
|
|
|
|
|
|
- BfCEParseContext ceParseContext = CEEmitParse(mCurTypeInstance, activeTypeDef, src);
|
|
|
|
- bfReducer.mAlloc = activeTypeDef->mEmitParser->mAlloc;
|
|
|
|
- bfReducer.HandleBlock(activeTypeDef->mEmitParser->mRootNode, false);
|
|
|
|
|
|
+ BfCEParseContext ceParseContext = CEEmitParse(mCurTypeInstance, src);
|
|
|
|
+ auto emitParser = mCurTypeInstance->mTypeDef->mSource->ToParser();
|
|
|
|
+ bfReducer.mSource = emitParser;
|
|
|
|
+ bfReducer.mAlloc = emitParser->mAlloc;
|
|
|
|
+ bfReducer.HandleBlock(emitParser->mRootNode, false);
|
|
|
|
|
|
SetAndRestoreValue<BfIRMDNode> prevInlinedAt(mCurMethodState->mCurScope->mDIInlinedAt);
|
|
SetAndRestoreValue<BfIRMDNode> prevInlinedAt(mCurMethodState->mCurScope->mDIInlinedAt);
|
|
SetAndRestoreValue<BfIRMDNode> prevDIScope(mCurMethodState->mCurScope->mDIScope);
|
|
SetAndRestoreValue<BfIRMDNode> prevDIScope(mCurMethodState->mCurScope->mDIScope);
|
|
@@ -2161,7 +2190,7 @@ void BfModule::CEMixin(BfAstNode* refNode, const StringImpl& code)
|
|
|
|
|
|
// We used to have the "def" line be the inlining position, but the linker we de-duplicate instances of these functions without regard to their unique line
|
|
// We used to have the "def" line be the inlining position, but the linker we de-duplicate instances of these functions without regard to their unique line
|
|
// definitions, so we need to be consistent and use the actual line
|
|
// definitions, so we need to be consistent and use the actual line
|
|
- UpdateSrcPos(activeTypeDef->mEmitParser->mRootNode, BfSrcPosFlag_NoSetDebugLoc);
|
|
|
|
|
|
+ UpdateSrcPos(emitParser->mRootNode, BfSrcPosFlag_NoSetDebugLoc);
|
|
int defLine = mCurFilePosition.mCurLine;
|
|
int defLine = mCurFilePosition.mCurLine;
|
|
auto diParentType = mBfIRBuilder->DbgGetTypeInst(mCurTypeInstance);
|
|
auto diParentType = mBfIRBuilder->DbgGetTypeInst(mCurTypeInstance);
|
|
if (!mBfIRBuilder->mIgnoreWrites)
|
|
if (!mBfIRBuilder->mIgnoreWrites)
|
|
@@ -2173,11 +2202,11 @@ void BfModule::CEMixin(BfAstNode* refNode, const StringImpl& code)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- UpdateSrcPos(activeTypeDef->mEmitParser->mRootNode);
|
|
|
|
|
|
+ UpdateSrcPos(emitParser->mRootNode);
|
|
|
|
|
|
SetIllegalSrcPos();
|
|
SetIllegalSrcPos();
|
|
|
|
|
|
- Visit(activeTypeDef->mEmitParser->mRootNode);
|
|
|
|
|
|
+ Visit(emitParser->mRootNode);
|
|
|
|
|
|
mBfIRBuilder->RestoreDebugLocation();
|
|
mBfIRBuilder->RestoreDebugLocation();
|
|
mBfIRBuilder->DupDebugLocation();
|
|
mBfIRBuilder->DupDebugLocation();
|
|
@@ -2309,7 +2338,7 @@ void BfModule::ExecuteCEOnCompile(CeEmitContext* ceEmitContext, BfTypeInstance*
|
|
ctxStr += MethodToString(methodInstance);
|
|
ctxStr += MethodToString(methodInstance);
|
|
ctxStr += " ";
|
|
ctxStr += " ";
|
|
ctxStr += methodInstance->mMethodDef->GetRefNode()->LocationToString();
|
|
ctxStr += methodInstance->mMethodDef->GetRefNode()->LocationToString();
|
|
- UpdateCEEmit(ceEmitContext, typeInstance, methodInstance->mMethodDef->mDeclaringType, ctxStr, methodInstance->mMethodDef->GetRefNode());
|
|
|
|
|
|
+ UpdateCEEmit(ceEmitContext, typeInstance, ctxStr, methodInstance->mMethodDef->GetRefNode());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2318,27 +2347,24 @@ void BfModule::ExecuteCEOnCompile(CeEmitContext* ceEmitContext, BfTypeInstance*
|
|
DeferRebuildType(typeInstance);
|
|
DeferRebuildType(typeInstance);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// if ((!typeInstance->IsInstanceOf(mCompiler->mValueTypeTypeDef)) &&
|
|
|
|
+// (!typeInstance->IsInstanceOf(mCompiler->mBfObjectTypeDef)) &&
|
|
|
|
+// (!typeInstance->IsBoxed()) &&
|
|
|
|
+// (!typeInstance->IsDelegate()) &&
|
|
|
|
+// (!typeInstance->IsTuple()))
|
|
|
|
+// {
|
|
|
|
+// //zTODO: TESTING, remove!
|
|
|
|
+// CEEmitParse(typeInstance, "// Testing");
|
|
|
|
+// }
|
|
}
|
|
}
|
|
|
|
|
|
void BfModule::DoCEEmit(BfTypeInstance* typeInstance, bool& hadNewMembers)
|
|
void BfModule::DoCEEmit(BfTypeInstance* typeInstance, bool& hadNewMembers)
|
|
-{
|
|
|
|
- typeInstance->mTypeDef->ClearEmitted();
|
|
|
|
-
|
|
|
|
- int startMethodCount = typeInstance->mTypeDef->mMethods.mSize;
|
|
|
|
- int startFieldCount = typeInstance->mTypeDef->mFields.mSize;
|
|
|
|
- int startPropCount = typeInstance->mTypeDef->mProperties.mSize;
|
|
|
|
-
|
|
|
|
|
|
+{
|
|
CeEmitContext ceEmitContext;
|
|
CeEmitContext ceEmitContext;
|
|
ceEmitContext.mType = typeInstance;
|
|
ceEmitContext.mType = typeInstance;
|
|
ExecuteCEOnCompile(&ceEmitContext, typeInstance, BfCEOnCompileKind_TypeInit);
|
|
ExecuteCEOnCompile(&ceEmitContext, typeInstance, BfCEOnCompileKind_TypeInit);
|
|
-
|
|
|
|
- if ((startMethodCount != typeInstance->mTypeDef->mMethods.mSize) ||
|
|
|
|
- (startFieldCount != typeInstance->mTypeDef->mFields.mSize) ||
|
|
|
|
- (startPropCount != typeInstance->mTypeDef->mProperties.mSize))
|
|
|
|
- {
|
|
|
|
- typeInstance->mTypeDef->ClearMemberSets();
|
|
|
|
- hadNewMembers = true;
|
|
|
|
- }
|
|
|
|
|
|
+ hadNewMembers = (typeInstance->mTypeDef->mEmitParent != NULL);
|
|
}
|
|
}
|
|
|
|
|
|
void BfModule::DoCEEmit(BfMethodInstance* methodInstance)
|
|
void BfModule::DoCEEmit(BfMethodInstance* methodInstance)
|
|
@@ -2409,8 +2435,13 @@ void BfModule::DoCEEmit(BfMethodInstance* methodInstance)
|
|
src += customAttribute.mRef->LocationToString();
|
|
src += customAttribute.mRef->LocationToString();
|
|
src += "\n";
|
|
src += "\n";
|
|
|
|
|
|
|
|
+ //auto emitTypeDef = typeInstance->mCeTypeInfo->mNext->mTypeDef;
|
|
|
|
+ //auto emitParser = emitTypeDef->mSource->ToParser();
|
|
|
|
+
|
|
|
|
+ //auto emitParser = activeTypeDef->mEmitParser;
|
|
|
|
+
|
|
BfReducer bfReducer;
|
|
BfReducer bfReducer;
|
|
- bfReducer.mSource = activeTypeDef->mEmitParser;
|
|
|
|
|
|
+ //bfReducer.mSource = emitParser;
|
|
bfReducer.mPassInstance = mCompiler->mPassInstance;
|
|
bfReducer.mPassInstance = mCompiler->mPassInstance;
|
|
bfReducer.mSystem = mSystem;
|
|
bfReducer.mSystem = mSystem;
|
|
bfReducer.mCurTypeDecl = activeTypeDef->mTypeDeclaration;
|
|
bfReducer.mCurTypeDecl = activeTypeDef->mTypeDeclaration;
|
|
@@ -2421,28 +2452,32 @@ void BfModule::DoCEEmit(BfMethodInstance* methodInstance)
|
|
SetAndRestoreValue<BfAstNode*> prevCustomAttribute(mCurMethodState->mEmitRefNode, customAttribute.mRef);
|
|
SetAndRestoreValue<BfAstNode*> prevCustomAttribute(mCurMethodState->mEmitRefNode, customAttribute.mRef);
|
|
|
|
|
|
String entrySrc = src;
|
|
String entrySrc = src;
|
|
- if (activeTypeDef->mEmitParser != NULL)
|
|
|
|
|
|
+ if (mCurTypeInstance->mTypeDef->mEmitParent != NULL)
|
|
entrySrc += "\n\n";
|
|
entrySrc += "\n\n";
|
|
entrySrc += src;
|
|
entrySrc += src;
|
|
entrySrc += ceEmitContext.mEmitData;
|
|
entrySrc += ceEmitContext.mEmitData;
|
|
- BfCEParseContext ceParseContext = CEEmitParse(typeInstance, activeTypeDef, entrySrc);
|
|
|
|
- bfReducer.mAlloc = activeTypeDef->mEmitParser->mAlloc;
|
|
|
|
- bfReducer.HandleBlock(activeTypeDef->mEmitParser->mRootNode, false);
|
|
|
|
- Visit(activeTypeDef->mEmitParser->mRootNode);
|
|
|
|
|
|
+ BfCEParseContext ceParseContext = CEEmitParse(typeInstance, entrySrc);
|
|
|
|
+ auto emitParser = mCurTypeInstance->mTypeDef->mSource->ToParser();
|
|
|
|
+ bfReducer.mSource = emitParser;
|
|
|
|
+ bfReducer.mAlloc = emitParser->mAlloc;
|
|
|
|
+ bfReducer.HandleBlock(emitParser->mRootNode, false);
|
|
|
|
+ Visit(emitParser->mRootNode);
|
|
FinishCEParseContext(customAttribute.mRef, typeInstance, &ceParseContext);
|
|
FinishCEParseContext(customAttribute.mRef, typeInstance, &ceParseContext);
|
|
}
|
|
}
|
|
|
|
|
|
if (!ceEmitContext.mExitEmitData.IsEmpty())
|
|
if (!ceEmitContext.mExitEmitData.IsEmpty())
|
|
{
|
|
{
|
|
String exitSrc;
|
|
String exitSrc;
|
|
- if (activeTypeDef->mEmitParser != NULL)
|
|
|
|
|
|
+ if (mCurTypeInstance->mTypeDef->mEmitParent != NULL)
|
|
exitSrc += "\n\n";
|
|
exitSrc += "\n\n";
|
|
exitSrc += src;
|
|
exitSrc += src;
|
|
exitSrc += ceEmitContext.mExitEmitData;
|
|
exitSrc += ceEmitContext.mExitEmitData;
|
|
- BfCEParseContext ceParseContext = CEEmitParse(typeInstance, activeTypeDef, exitSrc);
|
|
|
|
- bfReducer.mAlloc = activeTypeDef->mEmitParser->mAlloc;
|
|
|
|
- bfReducer.HandleBlock(activeTypeDef->mEmitParser->mRootNode, false);
|
|
|
|
- auto deferredBlock = AddDeferredBlock(activeTypeDef->mEmitParser->mRootNode, &mCurMethodState->mHeadScope);
|
|
|
|
|
|
+ BfCEParseContext ceParseContext = CEEmitParse(typeInstance, exitSrc);
|
|
|
|
+ auto emitParser = mCurTypeInstance->mTypeDef->mSource->ToParser();
|
|
|
|
+ bfReducer.mSource = emitParser;
|
|
|
|
+ bfReducer.mAlloc = emitParser->mAlloc;
|
|
|
|
+ bfReducer.HandleBlock(emitParser->mRootNode, false);
|
|
|
|
+ auto deferredBlock = AddDeferredBlock(emitParser->mRootNode, &mCurMethodState->mHeadScope);
|
|
deferredBlock->mEmitRefNode = customAttribute.mRef;
|
|
deferredBlock->mEmitRefNode = customAttribute.mRef;
|
|
FinishCEParseContext(customAttribute.mRef, typeInstance, &ceParseContext);
|
|
FinishCEParseContext(customAttribute.mRef, typeInstance, &ceParseContext);
|
|
}
|
|
}
|
|
@@ -2617,7 +2652,7 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
|
resolvedTypeRef->mSize = typeInstance->mAlign = mSystem->mPtrSize;
|
|
resolvedTypeRef->mSize = typeInstance->mAlign = mSystem->mPtrSize;
|
|
}
|
|
}
|
|
|
|
|
|
- BF_ASSERT((typeInstance->mMethodInstanceGroups.size() == 0) || (typeInstance->mMethodInstanceGroups.size() == typeDef->mMethods.size()) || (typeInstance->mTypeDef->mHasEmitMembers));
|
|
|
|
|
|
+ BF_ASSERT((typeInstance->mMethodInstanceGroups.size() == 0) || (typeInstance->mMethodInstanceGroups.size() == typeDef->mMethods.size()) || (typeInstance->mCeTypeInfo != NULL));
|
|
typeInstance->mMethodInstanceGroups.Resize(typeDef->mMethods.size());
|
|
typeInstance->mMethodInstanceGroups.Resize(typeDef->mMethods.size());
|
|
for (int i = 0; i < (int)typeInstance->mMethodInstanceGroups.size(); i++)
|
|
for (int i = 0; i < (int)typeInstance->mMethodInstanceGroups.size(); i++)
|
|
{
|
|
{
|
|
@@ -3111,7 +3146,7 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
|
BfInterfaceDecl ifaceDecl;
|
|
BfInterfaceDecl ifaceDecl;
|
|
ifaceDecl.mIFaceTypeInst = ifaceInst;
|
|
ifaceDecl.mIFaceTypeInst = ifaceInst;
|
|
ifaceDecl.mTypeRef = checkTypeRef;
|
|
ifaceDecl.mTypeRef = checkTypeRef;
|
|
- ifaceDecl.mDeclaringType = typeDef;
|
|
|
|
|
|
+ ifaceDecl.mDeclaringType = typeDef->GetDefinition();
|
|
interfaces.push_back(ifaceDecl);
|
|
interfaces.push_back(ifaceDecl);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -3378,8 +3413,8 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
|
typeInterfaceInst.mStartInterfaceTableIdx = -1;
|
|
typeInterfaceInst.mStartInterfaceTableIdx = -1;
|
|
typeInterfaceInst.mStartVirtualIdx = -1;
|
|
typeInterfaceInst.mStartVirtualIdx = -1;
|
|
typeInterfaceInst.mIsRedeclared = false;
|
|
typeInterfaceInst.mIsRedeclared = false;
|
|
- typeInstance->mInterfaces.push_back(typeInterfaceInst);
|
|
|
|
-
|
|
|
|
|
|
+ typeInstance->mInterfaces.push_back(typeInterfaceInst);
|
|
|
|
+
|
|
AddDependency(checkInterface, typeInstance, BfDependencyMap::DependencyFlag_ImplementsInterface);
|
|
AddDependency(checkInterface, typeInstance, BfDependencyMap::DependencyFlag_ImplementsInterface);
|
|
|
|
|
|
// Interfaces can list other interfaces in their declaration, so pull those in too
|
|
// Interfaces can list other interfaces in their declaration, so pull those in too
|
|
@@ -3892,8 +3927,7 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
|
}
|
|
}
|
|
|
|
|
|
if (hadNewMembers)
|
|
if (hadNewMembers)
|
|
- {
|
|
|
|
- typeInstance->mTypeDef->mHasEmitMembers = true;
|
|
|
|
|
|
+ {
|
|
DoPopulateType(resolvedTypeRef, populateType);
|
|
DoPopulateType(resolvedTypeRef, populateType);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -5365,7 +5399,7 @@ void BfModule::DoTypeInstanceMethodProcessing(BfTypeInstance* typeInstance)
|
|
|
|
|
|
for (auto& attrAttr : attrCustomAttributes->mAttributes)
|
|
for (auto& attrAttr : attrCustomAttributes->mAttributes)
|
|
{
|
|
{
|
|
- if (attrAttr.mType->ToTypeInstance()->mTypeDef == mCompiler->mAttributeUsageAttributeTypeDef)
|
|
|
|
|
|
+ if (attrAttr.mType->ToTypeInstance()->IsInstanceOf(mCompiler->mAttributeUsageAttributeTypeDef))
|
|
{
|
|
{
|
|
// Check for Flags arg
|
|
// Check for Flags arg
|
|
if (attrAttr.mCtorArgs.size() < 2)
|
|
if (attrAttr.mCtorArgs.size() < 2)
|
|
@@ -5478,6 +5512,16 @@ void BfModule::DoTypeInstanceMethodProcessing(BfTypeInstance* typeInstance)
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
|
|
+ auto matchedMethodDef = matchedMethod->mMethodDef;
|
|
|
|
+ if (matchedMethodDef->mDeclaringType->IsEmitted())
|
|
|
|
+ {
|
|
|
|
+ Fail("Boxed interface binding error to emitted method", mCurTypeInstance->mTypeDef->GetRefNode());
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (underlyingTypeInstance->mTypeDef->IsEmitted())
|
|
|
|
+ matchedMethodDef = underlyingTypeInstance->mTypeDef->mEmitParent->mMethods[matchedMethodDef->mIdx];
|
|
|
|
+
|
|
if (!matchedMethod->mIsForeignMethodDef)
|
|
if (!matchedMethod->mIsForeignMethodDef)
|
|
{
|
|
{
|
|
BfMethodInstanceGroup* boxedMethodInstanceGroup = &typeInstance->mMethodInstanceGroups[matchedMethod->mMethodDef->mIdx];
|
|
BfMethodInstanceGroup* boxedMethodInstanceGroup = &typeInstance->mMethodInstanceGroups[matchedMethod->mMethodDef->mIdx];
|
|
@@ -5491,7 +5535,7 @@ void BfModule::DoTypeInstanceMethodProcessing(BfTypeInstance* typeInstance)
|
|
auto methodFlags = matchedMethod->mIsForeignMethodDef ? BfGetMethodInstanceFlag_ForeignMethodDef : BfGetMethodInstanceFlag_None;
|
|
auto methodFlags = matchedMethod->mIsForeignMethodDef ? BfGetMethodInstanceFlag_ForeignMethodDef : BfGetMethodInstanceFlag_None;
|
|
methodFlags = (BfGetMethodInstanceFlags)(methodFlags | BfGetMethodInstanceFlag_MethodInstanceOnly);
|
|
methodFlags = (BfGetMethodInstanceFlags)(methodFlags | BfGetMethodInstanceFlag_MethodInstanceOnly);
|
|
|
|
|
|
- auto moduleMethodInstance = GetMethodInstance(typeInstance, matchedMethod->mMethodDef, BfTypeVector(),
|
|
|
|
|
|
+ auto moduleMethodInstance = GetMethodInstance(typeInstance, matchedMethodDef, BfTypeVector(),
|
|
methodFlags,
|
|
methodFlags,
|
|
matchedMethod->GetForeignType());
|
|
matchedMethod->GetForeignType());
|
|
auto methodInstance = moduleMethodInstance.mMethodInstance;
|
|
auto methodInstance = moduleMethodInstance.mMethodInstance;
|
|
@@ -6131,7 +6175,10 @@ BfArrayType* BfModule::CreateArrayType(BfType* resolvedType, int dimensions)
|
|
arrayType->mGenericTypeInfo->mTypeGenericArguments.push_back(resolvedType);
|
|
arrayType->mGenericTypeInfo->mTypeGenericArguments.push_back(resolvedType);
|
|
auto resolvedArrayType = ResolveType(arrayType);
|
|
auto resolvedArrayType = ResolveType(arrayType);
|
|
if (resolvedArrayType != arrayType)
|
|
if (resolvedArrayType != arrayType)
|
|
|
|
+ {
|
|
|
|
+ arrayType->Dispose();
|
|
mContext->mArrayTypePool.GiveBack(arrayType);
|
|
mContext->mArrayTypePool.GiveBack(arrayType);
|
|
|
|
+ }
|
|
return (BfArrayType*)resolvedArrayType;
|
|
return (BfArrayType*)resolvedArrayType;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -6693,13 +6740,16 @@ BfBoxedType* BfModule::CreateBoxedType(BfType* resolvedTypeRef, bool allowCreate
|
|
boxedType->mContext = mContext;
|
|
boxedType->mContext = mContext;
|
|
boxedType->mElementType = resolvedTypeRef;
|
|
boxedType->mElementType = resolvedTypeRef;
|
|
if (typeInst != NULL)
|
|
if (typeInst != NULL)
|
|
- boxedType->mTypeDef = typeInst->mTypeDef;
|
|
|
|
|
|
+ boxedType->mTypeDef = typeInst->mTypeDef->GetDefinition();
|
|
else
|
|
else
|
|
boxedType->mTypeDef = mCompiler->mValueTypeTypeDef;
|
|
boxedType->mTypeDef = mCompiler->mValueTypeTypeDef;
|
|
boxedType->mBoxedFlags = isStructPtr ? BfBoxedType::BoxedFlags_StructPtr : BfBoxedType::BoxedFlags_None;
|
|
boxedType->mBoxedFlags = isStructPtr ? BfBoxedType::BoxedFlags_StructPtr : BfBoxedType::BoxedFlags_None;
|
|
auto resolvedBoxedType = ResolveType(boxedType, populateType, resolveFlags);
|
|
auto resolvedBoxedType = ResolveType(boxedType, populateType, resolveFlags);
|
|
if (resolvedBoxedType != boxedType)
|
|
if (resolvedBoxedType != boxedType)
|
|
|
|
+ {
|
|
|
|
+ boxedType->Dispose();
|
|
mContext->mBoxedTypePool.GiveBack(boxedType);
|
|
mContext->mBoxedTypePool.GiveBack(boxedType);
|
|
|
|
+ }
|
|
return (BfBoxedType*)resolvedBoxedType;
|
|
return (BfBoxedType*)resolvedBoxedType;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -6753,6 +6803,7 @@ BfTypeInstance* BfModule::CreateTupleType(const BfTypeVector& fieldTypes, const
|
|
if (resolvedTupleType != tupleType)
|
|
if (resolvedTupleType != tupleType)
|
|
{
|
|
{
|
|
BF_ASSERT(tupleType->mContext != NULL);
|
|
BF_ASSERT(tupleType->mContext != NULL);
|
|
|
|
+ tupleType->Dispose();
|
|
mContext->mTupleTypePool.GiveBack((BfTupleType*)tupleType);
|
|
mContext->mTupleTypePool.GiveBack((BfTupleType*)tupleType);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -6814,7 +6865,7 @@ BfModifiedTypeType* BfModule::CreateModifiedTypeType(BfType* resolvedTypeRef, Bf
|
|
retTypeType->mContext = mContext;
|
|
retTypeType->mContext = mContext;
|
|
retTypeType->mModifiedKind = modifiedKind;
|
|
retTypeType->mModifiedKind = modifiedKind;
|
|
retTypeType->mElementType = resolvedTypeRef;
|
|
retTypeType->mElementType = resolvedTypeRef;
|
|
- auto resolvedRetTypeType = ResolveType(retTypeType);
|
|
|
|
|
|
+ auto resolvedRetTypeType = ResolveType(retTypeType);
|
|
if (resolvedRetTypeType != retTypeType)
|
|
if (resolvedRetTypeType != retTypeType)
|
|
mContext->mModifiedTypeTypePool.GiveBack(retTypeType);
|
|
mContext->mModifiedTypeTypePool.GiveBack(retTypeType);
|
|
return (BfModifiedTypeType*)resolvedRetTypeType;
|
|
return (BfModifiedTypeType*)resolvedRetTypeType;
|
|
@@ -6841,6 +6892,8 @@ BfPointerType* BfModule::CreatePointerType(BfTypeReference* typeRef)
|
|
|
|
|
|
BfType* BfModule::ResolveTypeDef(BfTypeDef* typeDef, BfPopulateType populateType, BfResolveTypeRefFlags resolveFlags)
|
|
BfType* BfModule::ResolveTypeDef(BfTypeDef* typeDef, BfPopulateType populateType, BfResolveTypeRefFlags resolveFlags)
|
|
{
|
|
{
|
|
|
|
+ BF_ASSERT(typeDef->mDefState != BfTypeDef::DefState_Emitted);
|
|
|
|
+
|
|
if (typeDef->mTypeDeclaration == NULL)
|
|
if (typeDef->mTypeDeclaration == NULL)
|
|
{
|
|
{
|
|
BF_ASSERT(!typeDef->mIsDelegate && !typeDef->mIsFunction);
|
|
BF_ASSERT(!typeDef->mIsDelegate && !typeDef->mIsFunction);
|
|
@@ -7159,7 +7212,7 @@ bool BfModule::IsInnerType(BfTypeDef* checkInnerType, BfTypeDef* checkOuterType)
|
|
return false;
|
|
return false;
|
|
if (outerType->mIsPartial)
|
|
if (outerType->mIsPartial)
|
|
outerType = mSystem->GetCombinedPartial(outerType);
|
|
outerType = mSystem->GetCombinedPartial(outerType);
|
|
- if (outerType == checkOuterType)
|
|
|
|
|
|
+ if (outerType->GetDefinition() == checkOuterType->GetDefinition())
|
|
return true;
|
|
return true;
|
|
checkInnerType = checkInnerType->mOuterType;
|
|
checkInnerType = checkInnerType->mOuterType;
|
|
}
|
|
}
|
|
@@ -7167,6 +7220,8 @@ bool BfModule::IsInnerType(BfTypeDef* checkInnerType, BfTypeDef* checkOuterType)
|
|
|
|
|
|
BfType* BfModule::ResolveTypeDef(BfTypeDef* typeDef, const BfTypeVector& genericArgs, BfPopulateType populateType, BfResolveTypeRefFlags resolveFlags)
|
|
BfType* BfModule::ResolveTypeDef(BfTypeDef* typeDef, const BfTypeVector& genericArgs, BfPopulateType populateType, BfResolveTypeRefFlags resolveFlags)
|
|
{
|
|
{
|
|
|
|
+ BF_ASSERT(typeDef->mDefState != BfTypeDef::DefState_Emitted);
|
|
|
|
+
|
|
if (typeDef->mGenericParamDefs.size() == 0)
|
|
if (typeDef->mGenericParamDefs.size() == 0)
|
|
return ResolveTypeDef(typeDef, populateType, resolveFlags);
|
|
return ResolveTypeDef(typeDef, populateType, resolveFlags);
|
|
|
|
|
|
@@ -7206,6 +7261,7 @@ BfType* BfModule::ResolveTypeDef(BfTypeDef* typeDef, const BfTypeVector& generic
|
|
{
|
|
{
|
|
delete arrayInstType->mGenericTypeInfo;
|
|
delete arrayInstType->mGenericTypeInfo;
|
|
arrayInstType->mGenericTypeInfo = NULL;
|
|
arrayInstType->mGenericTypeInfo = NULL;
|
|
|
|
+ arrayInstType->Dispose();
|
|
mContext->mArrayTypeInstancePool.GiveBack(arrayInstType);
|
|
mContext->mArrayTypeInstancePool.GiveBack(arrayInstType);
|
|
mContext->mTypeDefTypeRefPool.GiveBack(typeRef);
|
|
mContext->mTypeDefTypeRefPool.GiveBack(typeRef);
|
|
}
|
|
}
|
|
@@ -7250,29 +7306,7 @@ BfType* BfModule::ResolveTypeDef(BfTypeDef* typeDef, const BfTypeVector& generic
|
|
BfType* resolvedType = NULL;
|
|
BfType* resolvedType = NULL;
|
|
|
|
|
|
bool failed = false;
|
|
bool failed = false;
|
|
-// if (typeDef->mTypeCode == BfTypeCode_TypeAlias)
|
|
|
|
-// {
|
|
|
|
-// auto aliasType = (BfGenericTypeAliasType*)genericInstType;
|
|
|
|
-// aliasType->mAliasToType = NULL;
|
|
|
|
-// auto typeAliasDecl = (BfTypeAliasDeclaration*)typeDef->mTypeDeclaration;
|
|
|
|
-// SetAndRestoreValue<BfTypeInstance*> prevTypeInstance(mCurTypeInstance, aliasType);
|
|
|
|
-// SetAndRestoreValue<BfMethodInstance*> prevMethodInstance(mCurMethodInstance, NULL);
|
|
|
|
-// BfTypeState typeState(mCurTypeInstance, mContext->mCurTypeState);
|
|
|
|
-// typeState.mCurTypeDef = typeDef;
|
|
|
|
-// SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
|
|
|
-// if (typeAliasDecl->mAliasToType != NULL)
|
|
|
|
-// aliasType->mAliasToType = ResolveTypeRef(typeAliasDecl->mAliasToType);
|
|
|
|
-//
|
|
|
|
-// resolvedType = ResolveType(genericInstType, BfPopulateType_IdentityNoRemapAlias);
|
|
|
|
-// if ((resolvedType != NULL) && (populateType >= BfPopulateType_Declaration))
|
|
|
|
-// PopulateType(resolvedType, populateType);
|
|
|
|
-// }
|
|
|
|
-// else
|
|
|
|
- {
|
|
|
|
- resolvedType = ResolveType(genericInstType, populateType, resolveFlags);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ resolvedType = ResolveType(genericInstType, populateType, resolveFlags);
|
|
if (resolvedType != genericInstType)
|
|
if (resolvedType != genericInstType)
|
|
{
|
|
{
|
|
BF_ASSERT(genericInstType->mGenericTypeInfo->mGenericParams.size() == 0);
|
|
BF_ASSERT(genericInstType->mGenericTypeInfo->mGenericParams.size() == 0);
|
|
@@ -7283,7 +7317,10 @@ BfType* BfModule::ResolveTypeDef(BfTypeDef* typeDef, const BfTypeVector& generic
|
|
if (typeDef->mTypeCode == BfTypeCode_TypeAlias)
|
|
if (typeDef->mTypeCode == BfTypeCode_TypeAlias)
|
|
mContext->mAliasTypePool.GiveBack((BfTypeAliasType*)genericInstType);
|
|
mContext->mAliasTypePool.GiveBack((BfTypeAliasType*)genericInstType);
|
|
else
|
|
else
|
|
|
|
+ {
|
|
|
|
+ genericInstType->Dispose();
|
|
mContext->mGenericTypeInstancePool.GiveBack(genericInstType);
|
|
mContext->mGenericTypeInstancePool.GiveBack(genericInstType);
|
|
|
|
+ }
|
|
mContext->mTypeDefTypeRefPool.GiveBack(typeRef);
|
|
mContext->mTypeDefTypeRefPool.GiveBack(typeRef);
|
|
}
|
|
}
|
|
BF_ASSERT((resolvedType == NULL) || resolvedType->IsTypeInstance() || resolvedType->IsPrimitiveType());
|
|
BF_ASSERT((resolvedType == NULL) || resolvedType->IsTypeInstance() || resolvedType->IsPrimitiveType());
|
|
@@ -7302,19 +7339,18 @@ BfTypeDef* BfModule::ResolveGenericInstanceDef(BfGenericInstanceTypeRef* generic
|
|
|
|
|
|
BfTypeDef* curTypeDef = NULL;
|
|
BfTypeDef* curTypeDef = NULL;
|
|
if (mCurTypeInstance != NULL)
|
|
if (mCurTypeInstance != NULL)
|
|
- curTypeDef = mCurTypeInstance->mTypeDef;
|
|
|
|
|
|
+ curTypeDef = mCurTypeInstance->mTypeDef->GetDefinition();
|
|
|
|
|
|
if (auto directTypeDef = BfNodeDynCast<BfDirectTypeReference>(typeRef))
|
|
if (auto directTypeDef = BfNodeDynCast<BfDirectTypeReference>(typeRef))
|
|
{
|
|
{
|
|
auto typeInst = directTypeDef->mType->ToTypeInstance();
|
|
auto typeInst = directTypeDef->mType->ToTypeInstance();
|
|
- return typeInst->mTypeDef;
|
|
|
|
|
|
+ return typeInst->mTypeDef->GetDefinition();
|
|
}
|
|
}
|
|
|
|
|
|
auto namedTypeRef = BfNodeDynCast<BfNamedTypeReference>(typeRef);
|
|
auto namedTypeRef = BfNodeDynCast<BfNamedTypeReference>(typeRef);
|
|
auto directStrTypeDef = BfNodeDynCastExact<BfDirectStrTypeReference>(typeRef);
|
|
auto directStrTypeDef = BfNodeDynCastExact<BfDirectStrTypeReference>(typeRef);
|
|
if ((namedTypeRef != NULL) || (directStrTypeDef != NULL))
|
|
if ((namedTypeRef != NULL) || (directStrTypeDef != NULL))
|
|
- {
|
|
|
|
-
|
|
|
|
|
|
+ {
|
|
BfTypeLookupError error;
|
|
BfTypeLookupError error;
|
|
error.mRefNode = typeRef;
|
|
error.mRefNode = typeRef;
|
|
BfTypeDef* typeDef = FindTypeDef(typeRef, NULL, &error, numGenericParams);
|
|
BfTypeDef* typeDef = FindTypeDef(typeRef, NULL, &error, numGenericParams);
|
|
@@ -7392,7 +7428,7 @@ BfTypeDef* BfModule::ResolveGenericInstanceDef(BfGenericInstanceTypeRef* generic
|
|
*outType = type;
|
|
*outType = type;
|
|
auto typeInst = type->ToTypeInstance();
|
|
auto typeInst = type->ToTypeInstance();
|
|
if (typeInst != NULL)
|
|
if (typeInst != NULL)
|
|
- return typeInst->mTypeDef;
|
|
|
|
|
|
+ return typeInst->mTypeDef->GetDefinition();
|
|
}
|
|
}
|
|
|
|
|
|
if ((resolveFlags & BfResolveTypeRefFlag_IgnoreLookupError) == 0)
|
|
if ((resolveFlags & BfResolveTypeRefFlag_IgnoreLookupError) == 0)
|
|
@@ -7631,6 +7667,7 @@ BfType* BfModule::ResolveGenericType(BfType* unspecializedType, BfTypeVector* ty
|
|
{
|
|
{
|
|
delete tupleType->mGenericTypeInfo;
|
|
delete tupleType->mGenericTypeInfo;
|
|
tupleType->mGenericTypeInfo = NULL;
|
|
tupleType->mGenericTypeInfo = NULL;
|
|
|
|
+ tupleType->Dispose();
|
|
mContext->mTupleTypePool.GiveBack((BfTupleType*)tupleType);
|
|
mContext->mTupleTypePool.GiveBack((BfTupleType*)tupleType);
|
|
}
|
|
}
|
|
BF_ASSERT((resolvedType == NULL) || resolvedType->IsTypeInstance() || resolvedType->IsPrimitiveType());
|
|
BF_ASSERT((resolvedType == NULL) || resolvedType->IsTypeInstance() || resolvedType->IsPrimitiveType());
|
|
@@ -7828,9 +7865,8 @@ BfType* BfModule::ResolveGenericType(BfType* unspecializedType, BfTypeVector* ty
|
|
AddDependency(paramType, delegateType, BfDependencyMap::DependencyFlag_ParamOrReturnValue);
|
|
AddDependency(paramType, delegateType, BfDependencyMap::DependencyFlag_ParamOrReturnValue);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
- {
|
|
|
|
- delete delegateType->mGenericTypeInfo;
|
|
|
|
- delegateType->mGenericTypeInfo = NULL;
|
|
|
|
|
|
+ {
|
|
|
|
+ delegateType->Dispose();
|
|
mContext->mDelegateTypePool.GiveBack((BfDelegateType*)delegateType);
|
|
mContext->mDelegateTypePool.GiveBack((BfDelegateType*)delegateType);
|
|
}
|
|
}
|
|
BF_ASSERT((resolvedType == NULL) || resolvedType->IsTypeInstance() || resolvedType->IsPrimitiveType());
|
|
BF_ASSERT((resolvedType == NULL) || resolvedType->IsTypeInstance() || resolvedType->IsPrimitiveType());
|
|
@@ -7857,7 +7893,7 @@ BfType* BfModule::ResolveGenericType(BfType* unspecializedType, BfTypeVector* ty
|
|
genericArgs.push_back(genericArg);
|
|
genericArgs.push_back(genericArg);
|
|
}
|
|
}
|
|
|
|
|
|
- auto resolvedType = ResolveTypeDef(genericTypeInst->mTypeDef, genericArgs, BfPopulateType_BaseType);
|
|
|
|
|
|
+ auto resolvedType = ResolveTypeDef(genericTypeInst->mTypeDef->GetDefinition(), genericArgs, BfPopulateType_BaseType);
|
|
BfTypeInstance* specializedType = NULL;
|
|
BfTypeInstance* specializedType = NULL;
|
|
if (resolvedType != NULL)
|
|
if (resolvedType != NULL)
|
|
specializedType = resolvedType->ToGenericTypeInstance();
|
|
specializedType = resolvedType->ToGenericTypeInstance();
|
|
@@ -8470,7 +8506,7 @@ BfTypeDef* BfModule::GetActiveTypeDef(BfTypeInstance* typeInstanceOverride, bool
|
|
if ((mContext->mCurTypeState != NULL) && (mContext->mCurTypeState->mForceActiveTypeDef != NULL))
|
|
if ((mContext->mCurTypeState != NULL) && (mContext->mCurTypeState->mForceActiveTypeDef != NULL))
|
|
return mContext->mCurTypeState->mForceActiveTypeDef;
|
|
return mContext->mCurTypeState->mForceActiveTypeDef;
|
|
if (typeInstance != NULL)
|
|
if (typeInstance != NULL)
|
|
- useTypeDef = typeInstance->mTypeDef;
|
|
|
|
|
|
+ useTypeDef = typeInstance->mTypeDef->GetDefinition();
|
|
if ((mCurMethodState != NULL) && (mCurMethodState->mMixinState != NULL) && (useMixinDecl))
|
|
if ((mCurMethodState != NULL) && (mCurMethodState->mMixinState != NULL) && (useMixinDecl))
|
|
useTypeDef = mCurMethodState->mMixinState->mMixinMethodInstance->mMethodDef->mDeclaringType;
|
|
useTypeDef = mCurMethodState->mMixinState->mMixinMethodInstance->mMethodDef->mDeclaringType;
|
|
else if ((mCurMethodInstance != NULL) && (mCurMethodInstance->mMethodDef->mDeclaringType != NULL))
|
|
else if ((mCurMethodInstance != NULL) && (mCurMethodInstance->mMethodDef->mDeclaringType != NULL))
|
|
@@ -9253,46 +9289,6 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
|
BfGenericParamDef* genericParamDef = NULL;
|
|
BfGenericParamDef* genericParamDef = NULL;
|
|
BfType* genericParamResult = NULL;
|
|
BfType* genericParamResult = NULL;
|
|
bool disallowConstExprValue = false;
|
|
bool disallowConstExprValue = false;
|
|
- if ((genericCheckTypeInstance != NULL) && (genericCheckTypeInstance->IsGenericTypeInstance()))
|
|
|
|
- {
|
|
|
|
- auto genericTypeInst = (BfTypeInstance*)genericCheckTypeInstance;
|
|
|
|
- auto* genericParams = &curTypeDef->mGenericParamDefs;
|
|
|
|
-
|
|
|
|
- if (genericTypeInst->mGenericTypeInfo->mGenericExtensionInfo != NULL)
|
|
|
|
- {
|
|
|
|
- auto activeTypeDef = GetActiveTypeDef(NULL, true);
|
|
|
|
- genericParams = &activeTypeDef->mGenericParamDefs;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for (int genericParamIdx = (int)genericParams->size() - 1; genericParamIdx >= 0; genericParamIdx--)
|
|
|
|
- {
|
|
|
|
- auto checkGenericParamDef = (*genericParams)[genericParamIdx];
|
|
|
|
- String genericName = checkGenericParamDef->mName;
|
|
|
|
- if (genericName == findName)
|
|
|
|
- {
|
|
|
|
- genericParamDef = checkGenericParamDef;
|
|
|
|
- if (((genericParamDef->mGenericParamFlags & BfGenericParamFlag_Const) != 0) &&
|
|
|
|
- ((resolveFlags & BfResolveTypeRefFlag_AllowGenericTypeParamConstValue) == 0))
|
|
|
|
- disallowConstExprValue = true;
|
|
|
|
-
|
|
|
|
- HandleTypeGenericParamRef(typeRef, curTypeDef, genericParamIdx);
|
|
|
|
-
|
|
|
|
- if ((resolveFlags & BfResolveTypeRefFlag_NoResolveGenericParam) != 0)
|
|
|
|
- return GetGenericParamType(BfGenericParamKind_Type, genericParamIdx);
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- SetAndRestoreValue<BfGetSymbolReferenceKind> prevSymbolRefKind;
|
|
|
|
- if (mCompiler->mResolvePassData != NULL) // Don't add these typeRefs, they are indirect
|
|
|
|
- prevSymbolRefKind.Init(mCompiler->mResolvePassData->mGetSymbolReferenceKind, BfGetSymbolReferenceKind_None);
|
|
|
|
- genericParamResult = genericTypeInst->mGenericTypeInfo->mTypeGenericArguments[genericParamIdx];
|
|
|
|
- if ((genericParamResult != NULL) &&
|
|
|
|
- (genericParamResult->IsConstExprValue()) &&
|
|
|
|
- ((resolveFlags & BfResolveTypeRefFlag_AllowGenericTypeParamConstValue) == 0))
|
|
|
|
- disallowConstExprValue = true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
if ((contextMethodInstance != NULL) && (genericParamResult == NULL))
|
|
if ((contextMethodInstance != NULL) && (genericParamResult == NULL))
|
|
{
|
|
{
|
|
@@ -9318,7 +9314,7 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
|
auto checkGenericParamDef = checkMethodInstance->mMethodDef->mGenericParams[genericParamIdx];
|
|
auto checkGenericParamDef = checkMethodInstance->mMethodDef->mGenericParams[genericParamIdx];
|
|
String genericName = checkGenericParamDef->mName;
|
|
String genericName = checkGenericParamDef->mName;
|
|
if (genericName == findName)
|
|
if (genericName == findName)
|
|
- {
|
|
|
|
|
|
+ {
|
|
genericParamDef = checkGenericParamDef;
|
|
genericParamDef = checkGenericParamDef;
|
|
if (((genericParamDef->mGenericParamFlags & BfGenericParamFlag_Const) != 0) &&
|
|
if (((genericParamDef->mGenericParamFlags & BfGenericParamFlag_Const) != 0) &&
|
|
((resolveFlags & BfResolveTypeRefFlag_AllowGenericMethodParamConstValue) == 0))
|
|
((resolveFlags & BfResolveTypeRefFlag_AllowGenericMethodParamConstValue) == 0))
|
|
@@ -9330,7 +9326,7 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
|
return GetGenericParamType(BfGenericParamKind_Method, genericParamIdx);
|
|
return GetGenericParamType(BfGenericParamKind_Method, genericParamIdx);
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- if ((mContext->mCurConstraintState != NULL) && (mContext->mCurConstraintState->mMethodInstance == checkMethodInstance) &&
|
|
|
|
|
|
+ if ((mContext->mCurConstraintState != NULL) && (mContext->mCurConstraintState->mMethodInstance == checkMethodInstance) &&
|
|
(mContext->mCurConstraintState->mMethodGenericArgsOverride != NULL))
|
|
(mContext->mCurConstraintState->mMethodGenericArgsOverride != NULL))
|
|
{
|
|
{
|
|
return ResolveTypeResult(typeRef, (*mContext->mCurConstraintState->mMethodGenericArgsOverride)[genericParamIdx], populateType, resolveFlags);
|
|
return ResolveTypeResult(typeRef, (*mContext->mCurConstraintState->mMethodGenericArgsOverride)[genericParamIdx], populateType, resolveFlags);
|
|
@@ -9348,6 +9344,47 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if ((genericCheckTypeInstance != NULL) && (genericCheckTypeInstance->IsGenericTypeInstance()) && (genericParamResult == NULL))
|
|
|
|
+ {
|
|
|
|
+ auto genericTypeInst = (BfTypeInstance*)genericCheckTypeInstance;
|
|
|
|
+ auto* genericParams = &curTypeDef->mGenericParamDefs;
|
|
|
|
+
|
|
|
|
+ if (genericTypeInst->mGenericTypeInfo->mGenericExtensionInfo != NULL)
|
|
|
|
+ {
|
|
|
|
+ auto activeTypeDef = GetActiveTypeDef(NULL, true);
|
|
|
|
+ genericParams = &activeTypeDef->mGenericParamDefs;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (int genericParamIdx = (int)genericParams->size() - 1; genericParamIdx >= 0; genericParamIdx--)
|
|
|
|
+ {
|
|
|
|
+ auto checkGenericParamDef = (*genericParams)[genericParamIdx];
|
|
|
|
+ String genericName = checkGenericParamDef->mName;
|
|
|
|
+ if (genericName == findName)
|
|
|
|
+ {
|
|
|
|
+ genericParamDef = checkGenericParamDef;
|
|
|
|
+ if (((genericParamDef->mGenericParamFlags & BfGenericParamFlag_Const) != 0) &&
|
|
|
|
+ ((resolveFlags & BfResolveTypeRefFlag_AllowGenericTypeParamConstValue) == 0))
|
|
|
|
+ disallowConstExprValue = true;
|
|
|
|
+
|
|
|
|
+ HandleTypeGenericParamRef(typeRef, curTypeDef, genericParamIdx);
|
|
|
|
+
|
|
|
|
+ if ((resolveFlags & BfResolveTypeRefFlag_NoResolveGenericParam) != 0)
|
|
|
|
+ return GetGenericParamType(BfGenericParamKind_Type, genericParamIdx);
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ SetAndRestoreValue<BfGetSymbolReferenceKind> prevSymbolRefKind;
|
|
|
|
+ if (mCompiler->mResolvePassData != NULL) // Don't add these typeRefs, they are indirect
|
|
|
|
+ prevSymbolRefKind.Init(mCompiler->mResolvePassData->mGetSymbolReferenceKind, BfGetSymbolReferenceKind_None);
|
|
|
|
+ genericParamResult = genericTypeInst->mGenericTypeInfo->mTypeGenericArguments[genericParamIdx];
|
|
|
|
+ if ((genericParamResult != NULL) &&
|
|
|
|
+ (genericParamResult->IsConstExprValue()) &&
|
|
|
|
+ ((resolveFlags & BfResolveTypeRefFlag_AllowGenericTypeParamConstValue) == 0))
|
|
|
|
+ disallowConstExprValue = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
if (genericParamResult != NULL)
|
|
if (genericParamResult != NULL)
|
|
{
|
|
{
|
|
@@ -9670,9 +9707,8 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
|
resolvedType = GetDelegateReturnType(genericParamInstance->mTypeConstraint);
|
|
resolvedType = GetDelegateReturnType(genericParamInstance->mTypeConstraint);
|
|
return ResolveTypeResult(typeRef, resolvedType, populateType, resolveFlags);
|
|
return ResolveTypeResult(typeRef, resolvedType, populateType, resolveFlags);
|
|
}
|
|
}
|
|
- else if ((genericParamInstance->mTypeConstraint->IsTypeInstance()) &&
|
|
|
|
- ((genericParamInstance->mTypeConstraint->ToTypeInstance()->mTypeDef == mCompiler->mDelegateTypeDef) ||
|
|
|
|
- (genericParamInstance->mTypeConstraint->ToTypeInstance()->mTypeDef == mCompiler->mFunctionTypeDef)))
|
|
|
|
|
|
+ else if ((genericParamInstance->mTypeConstraint->IsInstanceOf(mCompiler->mDelegateTypeDef)) ||
|
|
|
|
+ (genericParamInstance->mTypeConstraint->IsInstanceOf(mCompiler->mFunctionTypeDef)))
|
|
{
|
|
{
|
|
allowThrough = true;
|
|
allowThrough = true;
|
|
}
|
|
}
|
|
@@ -9796,6 +9832,13 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ static int sCallIdx = 0;
|
|
|
|
+ int callIdx = sCallIdx++;
|
|
|
|
+ if (callIdx == 0x00006CA4)
|
|
|
|
+ {
|
|
|
|
+ NOP;
|
|
|
|
+ }
|
|
|
|
+
|
|
BfResolvedTypeSet::LookupContext lookupCtx;
|
|
BfResolvedTypeSet::LookupContext lookupCtx;
|
|
lookupCtx.mResolveFlags = (BfResolveTypeRefFlags)(resolveFlags & (BfResolveTypeRefFlag_NoCreate | BfResolveTypeRefFlag_IgnoreLookupError | BfResolveTypeRefFlag_DisallowComptime | BfResolveTypeRefFlag_AllowInferredSizedArray));
|
|
lookupCtx.mResolveFlags = (BfResolveTypeRefFlags)(resolveFlags & (BfResolveTypeRefFlag_NoCreate | BfResolveTypeRefFlag_IgnoreLookupError | BfResolveTypeRefFlag_DisallowComptime | BfResolveTypeRefFlag_AllowInferredSizedArray));
|
|
lookupCtx.mRootTypeRef = typeRef;
|
|
lookupCtx.mRootTypeRef = typeRef;
|
|
@@ -10829,7 +10872,7 @@ BfTypeInstance* BfModule::GetUnspecializedTypeInstance(BfTypeInstance* typeInst)
|
|
BF_ASSERT((!typeInst->IsDelegateFromTypeRef()) && (!typeInst->IsFunctionFromTypeRef()));
|
|
BF_ASSERT((!typeInst->IsDelegateFromTypeRef()) && (!typeInst->IsFunctionFromTypeRef()));
|
|
|
|
|
|
auto genericTypeInst = (BfTypeInstance*)typeInst;
|
|
auto genericTypeInst = (BfTypeInstance*)typeInst;
|
|
- auto result = ResolveTypeDef(genericTypeInst->mTypeDef, BfPopulateType_Declaration);
|
|
|
|
|
|
+ auto result = ResolveTypeDef(genericTypeInst->mTypeDef->GetDefinition(), BfPopulateType_Declaration);
|
|
BF_ASSERT((result != NULL) && (result->IsUnspecializedType()));
|
|
BF_ASSERT((result != NULL) && (result->IsUnspecializedType()));
|
|
if (result == NULL)
|
|
if (result == NULL)
|
|
return NULL;
|
|
return NULL;
|
|
@@ -11266,7 +11309,7 @@ BfIRValue BfModule::CastToValue(BfAstNode* srcNode, BfTypedValue typedVal, BfTyp
|
|
{
|
|
{
|
|
SetAndRestoreValue<bool> prevIgnoreWrites(mBfIRBuilder->mIgnoreWrites, true);
|
|
SetAndRestoreValue<bool> prevIgnoreWrites(mBfIRBuilder->mIgnoreWrites, true);
|
|
auto constraintTypeInst = genericParamInst->mTypeConstraint->ToTypeInstance();
|
|
auto constraintTypeInst = genericParamInst->mTypeConstraint->ToTypeInstance();
|
|
- if ((constraintTypeInst != NULL) && (constraintTypeInst->mTypeDef == mCompiler->mEnumTypeDef) && (explicitCast))
|
|
|
|
|
|
+ if ((constraintTypeInst != NULL) && (constraintTypeInst->IsInstanceOf(mCompiler->mEnumTypeDef)) && (explicitCast))
|
|
{
|
|
{
|
|
// Enum->int
|
|
// Enum->int
|
|
if ((explicitCast) && (toType->IsInteger()))
|
|
if ((explicitCast) && (toType->IsInteger()))
|
|
@@ -12981,7 +13024,7 @@ bool BfModule::TypeHasParentOrEquals(BfTypeDef* checkChildTypeDef, BfTypeDef* ch
|
|
while (checkType->mNestDepth > checkParentTypeDef->mNestDepth)
|
|
while (checkType->mNestDepth > checkParentTypeDef->mNestDepth)
|
|
checkType = checkType->mOuterType;
|
|
checkType = checkType->mOuterType;
|
|
|
|
|
|
- if (checkType == checkParentTypeDef)
|
|
|
|
|
|
+ if (checkType->GetDefinition() == checkParentTypeDef->GetDefinition())
|
|
return true;
|
|
return true;
|
|
if (checkType->mNameEx != checkParentTypeDef->mNameEx)
|
|
if (checkType->mNameEx != checkParentTypeDef->mNameEx)
|
|
return false;
|
|
return false;
|
|
@@ -13000,7 +13043,7 @@ BfTypeDef* BfModule::FindCommonOuterType(BfTypeDef* type, BfTypeDef* type2)
|
|
{
|
|
{
|
|
if ((type == NULL) || (type2 == NULL))
|
|
if ((type == NULL) || (type2 == NULL))
|
|
return NULL;
|
|
return NULL;
|
|
- int curNestDepth = std::min(type->mNestDepth, type2->mNestDepth);
|
|
|
|
|
|
+ int curNestDepth = BF_MIN(type->mNestDepth, type2->mNestDepth);
|
|
while (type->mNestDepth > curNestDepth)
|
|
while (type->mNestDepth > curNestDepth)
|
|
type = type->mOuterType;
|
|
type = type->mOuterType;
|
|
while (type2->mNestDepth > curNestDepth)
|
|
while (type2->mNestDepth > curNestDepth)
|
|
@@ -13010,7 +13053,7 @@ BfTypeDef* BfModule::FindCommonOuterType(BfTypeDef* type, BfTypeDef* type2)
|
|
{
|
|
{
|
|
if ((!type->mIsPartial) && (!type2->mIsPartial))
|
|
if ((!type->mIsPartial) && (!type2->mIsPartial))
|
|
{
|
|
{
|
|
- if (type == type2)
|
|
|
|
|
|
+ if (type->GetDefinition() == type2->GetDefinition())
|
|
return type;
|
|
return type;
|
|
}
|
|
}
|
|
else
|
|
else
|