mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Improved deferred type name generation
This commit is contained in:
parent
fc063a65c1
commit
aafefecfa2
5 changed files with 77 additions and 56 deletions
|
@ -2723,6 +2723,11 @@ void BfCompiler::UpdateRevisedTypes()
|
|||
continue;
|
||||
}
|
||||
|
||||
if ((!typeDef->IsGlobalsContainer()) && (mSystem->ContainsNamespace(typeDef->mFullName, typeDef->mProject)))
|
||||
{
|
||||
mPassInstance->Fail(StrFormat("The name '%s' is already defined to be a namespace name", typeDef->mFullName.ToString().c_str()), typeDef->mTypeDeclaration->mNameNode);
|
||||
}
|
||||
|
||||
bool removedElement = false;
|
||||
auto nextTypeDefItr = typeDefItr;
|
||||
nextTypeDefItr.MoveToNextHashMatch();
|
||||
|
@ -7082,7 +7087,7 @@ String BfCompiler::GetTypeDefList()
|
|||
result += "c";
|
||||
else
|
||||
result += "v";
|
||||
result += BfTypeUtils::TypeToString(typeDef) + "\n";
|
||||
result += BfTypeUtils::TypeToString(typeDef, BfTypeNameFlag_InternalName) + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7381,7 +7386,7 @@ String BfCompiler::GetTypeDefMatches(const StringImpl& searchStr)
|
|||
if (matchHelper.CheckMemberMatch(typeDef, fieldDef->mName))
|
||||
{
|
||||
result += "F";
|
||||
if (BfTypeUtils::TypeToString(result, typeDef, BfTypeNameFlag_HideGlobalName))
|
||||
if (BfTypeUtils::TypeToString(result, typeDef, (BfTypeNameFlags)(BfTypeNameFlag_HideGlobalName | BfTypeNameFlag_InternalName)))
|
||||
result += ".";
|
||||
result += fieldDef->mName;
|
||||
matchHelper.AddFieldDef(fieldDef);
|
||||
|
@ -7397,7 +7402,7 @@ String BfCompiler::GetTypeDefMatches(const StringImpl& searchStr)
|
|||
if (matchHelper.CheckMemberMatch(typeDef, propDef->mName))
|
||||
{
|
||||
result += "P";
|
||||
if (BfTypeUtils::TypeToString(result, typeDef, BfTypeNameFlag_HideGlobalName))
|
||||
if (BfTypeUtils::TypeToString(result, typeDef, (BfTypeNameFlags)(BfTypeNameFlag_HideGlobalName | BfTypeNameFlag_InternalName)))
|
||||
result += ".";
|
||||
matchHelper.AddPropertyDef(typeDef, propDef);
|
||||
}
|
||||
|
@ -7418,7 +7423,7 @@ String BfCompiler::GetTypeDefMatches(const StringImpl& searchStr)
|
|||
if (matchHelper.CheckMemberMatch(typeDef, methodDef->mName))
|
||||
{
|
||||
result += "M";
|
||||
if (BfTypeUtils::TypeToString(result, typeDef, BfTypeNameFlag_HideGlobalName))
|
||||
if (BfTypeUtils::TypeToString(result, typeDef, (BfTypeNameFlags)(BfTypeNameFlag_HideGlobalName | BfTypeNameFlag_InternalName)))
|
||||
result += ".";
|
||||
matchHelper.AddMethodDef(methodDef);
|
||||
}
|
||||
|
@ -7448,10 +7453,6 @@ String BfCompiler::GetTypeDefMatches(const StringImpl& searchStr)
|
|||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//foundComposite.Set(typeDef->mFullName.mParts, matchIdx + 1, NULL, 0);
|
||||
|
||||
//foundComposite = typeDef->mFullName;
|
||||
}
|
||||
|
||||
if (typeDef->mProject != curProject)
|
||||
|
@ -7473,7 +7474,7 @@ String BfCompiler::GetTypeDefMatches(const StringImpl& searchStr)
|
|||
}
|
||||
}
|
||||
|
||||
typeName = BfTypeUtils::TypeToString(typeDef);
|
||||
typeName = BfTypeUtils::TypeToString(typeDef, BfTypeNameFlag_InternalName);
|
||||
|
||||
if (matchIdx != -1)
|
||||
{
|
||||
|
@ -7588,6 +7589,10 @@ String BfCompiler::GetTypeDefInfo(const StringImpl& inTypeName)
|
|||
isGlobals = true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (int)typeName.length(); i++)
|
||||
if (typeName[i] == '+')
|
||||
typeName[i] = '.';
|
||||
|
||||
String result;
|
||||
TypeDefMatchHelper matchHelper(result);
|
||||
|
||||
|
|
|
@ -6343,6 +6343,11 @@ BfAstNode* BfReducer::ReadTypeMember(BfAstNode* node, int depth)
|
|||
doExplicitInterface = true; // Qualified property
|
||||
}
|
||||
}
|
||||
|
||||
// Experimental 'more permissive' explicit interface check
|
||||
if (endNodeIdx != -1)
|
||||
doExplicitInterface = true;
|
||||
|
||||
if (doExplicitInterface)
|
||||
{
|
||||
auto prevEndNode = mVisitorPos.Get(endNodeIdx - 1);
|
||||
|
|
|
@ -409,19 +409,6 @@ BfFieldInstance::~BfFieldInstance()
|
|||
BfType* BfFieldInstance::GetResolvedType()
|
||||
{
|
||||
return mResolvedType;
|
||||
/*if (mType == NULL)
|
||||
return NULL;
|
||||
if (!mType->IsGenericParam())
|
||||
return mType;
|
||||
if (!mOwner->IsGenericTypeInstance())
|
||||
return mType;
|
||||
auto genericParamType = (BfGenericParamType*)mType;
|
||||
auto genericTypeInst = (BfGenericTypeInstance*)mOwner;
|
||||
if (genericTypeInst->mIsUnspecialized)
|
||||
return mType;
|
||||
if (genericParamType->mGenericParamKind == BfGenericParamKind_Type)
|
||||
return genericTypeInst->mTypeGenericArguments[genericParamType->mGenericParamIdx];
|
||||
return mType;*/
|
||||
}
|
||||
|
||||
void BfFieldInstance::SetResolvedType(BfType* type)
|
||||
|
@ -429,6 +416,36 @@ void BfFieldInstance::SetResolvedType(BfType* type)
|
|||
mResolvedType = type;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int64 BfDeferredMethodCallData::GenerateMethodId(BfModule* module, int64 methodId)
|
||||
{
|
||||
// The mMethodId MUST be unique within a given deferred method processor. We are even more conservative, making it
|
||||
// unique per module
|
||||
if (module->mDeferredMethodIds.Add(methodId))
|
||||
{
|
||||
return methodId;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ideally the passed in methodId just works, otherwise --
|
||||
// We hope to create a hash that will hopefully be globally unique. If it isn't then it just means we will end up with two
|
||||
// conflicting debug info definitions for the same name, which is not an error but may cause a debugger to show the
|
||||
// wrong one to the user. Does not affect runtime correctness.
|
||||
int64 checkId = Hash64(module->mModuleName.c_str(), (int)module->mModuleName.length(), module->mDeferredMethodIds.size());
|
||||
while (true)
|
||||
{
|
||||
if (!module->mDeferredMethodIds.Contains(checkId))
|
||||
break;
|
||||
checkId += 0x100;
|
||||
}
|
||||
module->mDeferredMethodIds.Add(checkId);
|
||||
return checkId;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
BfMethodCustomAttributes::~BfMethodCustomAttributes()
|
||||
{
|
||||
delete mCustomAttributes;
|
||||
|
@ -3720,13 +3737,16 @@ String BfTypeUtils::TypeToString(BfTypeDef* typeDef, BfTypeNameFlags typeNameFla
|
|||
bool BfTypeUtils::TypeToString(StringImpl& str, BfTypeDef* typeDef, BfTypeNameFlags typeNameFlags)
|
||||
{
|
||||
auto checkTypeDef = typeDef;
|
||||
bool needsDot = false;
|
||||
char needsSep = 0;
|
||||
|
||||
if (checkTypeDef->mOuterType != NULL)
|
||||
{
|
||||
if (TypeToString(str, checkTypeDef->mOuterType, typeNameFlags))
|
||||
{
|
||||
needsDot = true;
|
||||
if ((typeNameFlags & BfTypeNameFlag_InternalName) != 0)
|
||||
needsSep = '+';
|
||||
else
|
||||
needsSep = '.';
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -3734,15 +3754,16 @@ bool BfTypeUtils::TypeToString(StringImpl& str, BfTypeDef* typeDef, BfTypeNameFl
|
|||
if (((typeNameFlags & BfTypeNameFlag_OmitNamespace) == 0) && (!typeDef->mNamespace.IsEmpty()))
|
||||
{
|
||||
typeDef->mNamespace.ToString(str);
|
||||
needsDot = true;
|
||||
needsSep = '.';
|
||||
}
|
||||
}
|
||||
|
||||
if (needsSep != 0)
|
||||
str += needsSep;
|
||||
|
||||
if (((typeNameFlags & BfTypeNameFlag_HideGlobalName) != 0) && (typeDef->IsGlobalsContainer()))
|
||||
return false;
|
||||
|
||||
if (needsDot)
|
||||
str += ".";
|
||||
typeDef->mName->ToString(str);
|
||||
|
||||
if (typeDef->mGenericParamDefs.size() != 0)
|
||||
|
|
|
@ -576,6 +576,8 @@ public:
|
|||
mSize = 0;
|
||||
mMethodId = 0;
|
||||
}
|
||||
|
||||
static int64 GenerateMethodId(BfModule* module, int64 methodId);
|
||||
};
|
||||
|
||||
class BfMethodCustomAttributes
|
||||
|
|
|
@ -178,7 +178,14 @@ bool BfModule::AddDeferredCallEntry(BfDeferredCallEntry* deferredCallEntry, BfSc
|
|||
|
||||
if (deferredCallEntry->mDeferredBlock != NULL)
|
||||
{
|
||||
int blockId = -deferredCallEntry->mDeferredBlock->GetSrcStart();
|
||||
HashContext hashCtx;
|
||||
hashCtx.Mixin(deferredCallEntry->mDeferredBlock->GetSrcStart());
|
||||
|
||||
auto parserData = deferredCallEntry->mDeferredBlock->GetParserData();
|
||||
if (parserData != NULL)
|
||||
hashCtx.MixinStr(parserData->mFileName);
|
||||
|
||||
int64 blockId = BfDeferredMethodCallData::GenerateMethodId(this, hashCtx.Finish64());
|
||||
|
||||
auto deferType = deferredCallEntryType;
|
||||
|
||||
|
@ -286,26 +293,7 @@ bool BfModule::AddDeferredCallEntry(BfDeferredCallEntry* deferredCallEntry, BfSc
|
|||
{
|
||||
deferredMethodCallData = new BfDeferredMethodCallData();
|
||||
mDeferredMethodCallData[methodInstance] = deferredMethodCallData;
|
||||
|
||||
if (mDeferredMethodIds.Add(methodInstance->mIdHash))
|
||||
{
|
||||
deferredMethodCallData->mMethodId = methodInstance->mIdHash;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Try to create a hash that will hopefully be globally unique. If it isn't then it just means we will end up with two
|
||||
// conflicting debug info definitions for the same name, which is not an error but may cause a debugger to show the
|
||||
// wrong one to the user. Does not affect runtime correctness.
|
||||
int64 checkId = Hash64(mModuleName.c_str(), (int)mModuleName.length(), mDeferredMethodIds.size());
|
||||
while (true)
|
||||
{
|
||||
if (!mDeferredMethodIds.Contains(checkId))
|
||||
break;
|
||||
checkId += 0x100;
|
||||
}
|
||||
mDeferredMethodIds.Add(checkId);
|
||||
deferredMethodCallData->mMethodId = checkId;
|
||||
}
|
||||
deferredMethodCallData->mMethodId = BfDeferredMethodCallData::GenerateMethodId(this, methodInstance->mIdHash);
|
||||
|
||||
auto int64Type = GetPrimitiveType(BfTypeCode_Int64);
|
||||
auto methodDef = moduleMethodInstance.mMethodInstance->mMethodDef;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue