mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Better support for @ name prefixes
This commit is contained in:
parent
7691c414c3
commit
aa56542fae
12 changed files with 158 additions and 40 deletions
|
@ -27,8 +27,15 @@ AutoCompleteBase::~AutoCompleteBase()
|
||||||
|
|
||||||
AutoCompleteEntry* AutoCompleteBase::AddEntry(const AutoCompleteEntry& entry, const StringImpl& filter)
|
AutoCompleteEntry* AutoCompleteBase::AddEntry(const AutoCompleteEntry& entry, const StringImpl& filter)
|
||||||
{
|
{
|
||||||
if (!DoesFilterMatch(entry.mDisplay, filter.c_str()))
|
if ((!DoesFilterMatch(entry.mDisplay, filter.c_str())) || (entry.mNamePrefixCount < 0))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
return AddEntry(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
AutoCompleteEntry* AutoCompleteBase::AddEntry(const AutoCompleteEntry& entry, const char* filter)
|
||||||
|
{
|
||||||
|
if ((!DoesFilterMatch(entry.mDisplay, filter)) || (entry.mNamePrefixCount < 0))
|
||||||
|
return NULL;
|
||||||
return AddEntry(entry);
|
return AddEntry(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,9 +51,10 @@ AutoCompleteEntry* AutoCompleteBase::AddEntry(const AutoCompleteEntry& entry)
|
||||||
{
|
{
|
||||||
insertedEntry->mEntryType = entry.mEntryType;
|
insertedEntry->mEntryType = entry.mEntryType;
|
||||||
|
|
||||||
int size = (int)strlen(entry.mDisplay) + 1;
|
const char* display = entry.mDisplay;
|
||||||
|
int size = (int)strlen(display) + 1;
|
||||||
insertedEntry->mDisplay = (char*)mAlloc.AllocBytes(size);
|
insertedEntry->mDisplay = (char*)mAlloc.AllocBytes(size);
|
||||||
memcpy((char*)insertedEntry->mDisplay, entry.mDisplay, size);
|
memcpy((char*)insertedEntry->mDisplay, display, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
return insertedEntry;
|
return insertedEntry;
|
||||||
|
@ -455,8 +463,15 @@ bool BfAutoComplete::IsAttribute(BfTypeInstance* typeInst)
|
||||||
|
|
||||||
void BfAutoComplete::AddMethod(BfTypeInstance* typeInstance, BfMethodDef* methodDef, BfMethodInstance* methodInstance, BfMethodDeclaration* methodDecl, const StringImpl& methodName, const StringImpl& filter)
|
void BfAutoComplete::AddMethod(BfTypeInstance* typeInstance, BfMethodDef* methodDef, BfMethodInstance* methodInstance, BfMethodDeclaration* methodDecl, const StringImpl& methodName, const StringImpl& filter)
|
||||||
{
|
{
|
||||||
|
int wantPrefixCount = 0;
|
||||||
|
const char* filterStr = filter.c_str();
|
||||||
|
while (filterStr[0] == '@')
|
||||||
|
{
|
||||||
|
filterStr++;
|
||||||
|
wantPrefixCount++;
|
||||||
|
}
|
||||||
String replaceName;
|
String replaceName;
|
||||||
AutoCompleteEntry entry("method", methodName);
|
AutoCompleteEntry entry("method", methodName, methodDef->mNamePrefixCount - wantPrefixCount);
|
||||||
if (methodDecl != NULL)
|
if (methodDecl != NULL)
|
||||||
{
|
{
|
||||||
if (methodDecl->mMixinSpecifier != NULL)
|
if (methodDecl->mMixinSpecifier != NULL)
|
||||||
|
@ -470,7 +485,7 @@ void BfAutoComplete::AddMethod(BfTypeInstance* typeInstance, BfMethodDef* method
|
||||||
if (methodDef->mMethodType == BfMethodType_Extension)
|
if (methodDef->mMethodType == BfMethodType_Extension)
|
||||||
entry.mEntryType = "extmethod";
|
entry.mEntryType = "extmethod";
|
||||||
|
|
||||||
if (auto entryAdded = AddEntry(entry, filter))
|
if (auto entryAdded = AddEntry(entry, filterStr))
|
||||||
{
|
{
|
||||||
if (methodDecl != NULL)
|
if (methodDecl != NULL)
|
||||||
{
|
{
|
||||||
|
@ -654,8 +669,15 @@ void BfAutoComplete::AddCurrentTypes(BfTypeInstance* typeInst, const StringImpl&
|
||||||
|
|
||||||
void BfAutoComplete::AddField(BfTypeInstance* typeInst, BfFieldDef* fieldDef, BfFieldInstance* fieldInstance, const StringImpl& filter)
|
void BfAutoComplete::AddField(BfTypeInstance* typeInst, BfFieldDef* fieldDef, BfFieldInstance* fieldInstance, const StringImpl& filter)
|
||||||
{
|
{
|
||||||
AutoCompleteEntry entry(GetTypeName(fieldInstance->mResolvedType), fieldDef->mName);
|
int wantPrefixCount = 0;
|
||||||
if (auto entryAdded = AddEntry(entry, filter))
|
const char* filterStr = filter.c_str();
|
||||||
|
while (filterStr[0] == '@')
|
||||||
|
{
|
||||||
|
filterStr++;
|
||||||
|
wantPrefixCount++;
|
||||||
|
}
|
||||||
|
AutoCompleteEntry entry(GetTypeName(fieldInstance->mResolvedType), fieldDef->mName, fieldDef->mNamePrefixCount - wantPrefixCount);
|
||||||
|
if (auto entryAdded = AddEntry(entry, filterStr))
|
||||||
{
|
{
|
||||||
auto documentation = (fieldDef->mFieldDeclaration != NULL) ? fieldDef->mFieldDeclaration->mDocumentation : NULL;
|
auto documentation = (fieldDef->mFieldDeclaration != NULL) ? fieldDef->mFieldDeclaration->mDocumentation : NULL;
|
||||||
if (CheckDocumentation(entryAdded, documentation))
|
if (CheckDocumentation(entryAdded, documentation))
|
||||||
|
@ -693,11 +715,18 @@ void BfAutoComplete::AddField(BfTypeInstance* typeInst, BfFieldDef* fieldDef, Bf
|
||||||
|
|
||||||
void BfAutoComplete::AddProp(BfTypeInstance* typeInst, BfPropertyDef* propDef, const StringImpl& filter)
|
void BfAutoComplete::AddProp(BfTypeInstance* typeInst, BfPropertyDef* propDef, const StringImpl& filter)
|
||||||
{
|
{
|
||||||
|
int wantPrefixCount = 0;
|
||||||
|
const char* filterStr = filter.c_str();
|
||||||
|
while (filterStr[0] == '@')
|
||||||
|
{
|
||||||
|
filterStr++;
|
||||||
|
wantPrefixCount++;
|
||||||
|
}
|
||||||
BfCommentNode* documentation = NULL;
|
BfCommentNode* documentation = NULL;
|
||||||
if (propDef->mFieldDeclaration != NULL)
|
if (propDef->mFieldDeclaration != NULL)
|
||||||
documentation = propDef->mFieldDeclaration->mDocumentation;
|
documentation = propDef->mFieldDeclaration->mDocumentation;
|
||||||
AutoCompleteEntry entry("property", propDef->mName);
|
AutoCompleteEntry entry("property", propDef->mName, propDef->mNamePrefixCount - wantPrefixCount);
|
||||||
if (auto entryAdded = AddEntry(entry, filter))
|
if (auto entryAdded = AddEntry(entry, filterStr))
|
||||||
{
|
{
|
||||||
if (CheckDocumentation(entryAdded, documentation))
|
if (CheckDocumentation(entryAdded, documentation))
|
||||||
{
|
{
|
||||||
|
@ -1508,9 +1537,9 @@ void BfAutoComplete::CheckIdentifier(BfAstNode* identifierNode, bool isInExpress
|
||||||
(*findIdx)++;
|
(*findIdx)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*findIdx == varSkipCount)
|
if (varSkipCount - local->mNamePrefixCount - *findIdx == 0)
|
||||||
{
|
{
|
||||||
if ((AddEntry(AutoCompleteEntry(GetTypeName(local->mResolvedType), local->mName), wantName)) && (mIsGetDefinition))
|
if ((AddEntry(AutoCompleteEntry(GetTypeName(local->mResolvedType), local->mName, varSkipCount - local->mNamePrefixCount - *findIdx), wantName)) && (mIsGetDefinition))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1628,8 +1657,16 @@ String BfAutoComplete::GetFilter(BfAstNode* node)
|
||||||
auto bfParser = node->GetSourceData()->ToParser();
|
auto bfParser = node->GetSourceData()->ToParser();
|
||||||
int cursorIdx = bfParser->mCursorIdx;
|
int cursorIdx = bfParser->mCursorIdx;
|
||||||
filter = filter.Substring(0, BF_CLAMP(cursorIdx - node->GetSrcStart(), 0, (int)filter.length()));
|
filter = filter.Substring(0, BF_CLAMP(cursorIdx - node->GetSrcStart(), 0, (int)filter.length()));
|
||||||
mInsertEndIdx = cursorIdx;
|
mInsertEndIdx = cursorIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* cPtr = filter.c_str();
|
||||||
|
while (cPtr[0] == '@')
|
||||||
|
{
|
||||||
|
mInsertStartIdx++;
|
||||||
|
cPtr++;
|
||||||
|
}
|
||||||
|
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,10 +15,12 @@ public:
|
||||||
const char* mEntryType;
|
const char* mEntryType;
|
||||||
const char* mDisplay;
|
const char* mDisplay;
|
||||||
const char* mDocumentation;
|
const char* mDocumentation;
|
||||||
|
int8 mNamePrefixCount;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AutoCompleteEntry()
|
AutoCompleteEntry()
|
||||||
{
|
{
|
||||||
|
mNamePrefixCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoCompleteEntry(const char* entryType, const char* display)
|
AutoCompleteEntry(const char* entryType, const char* display)
|
||||||
|
@ -26,6 +28,7 @@ public:
|
||||||
mEntryType = entryType;
|
mEntryType = entryType;
|
||||||
mDisplay = display;
|
mDisplay = display;
|
||||||
mDocumentation = NULL;
|
mDocumentation = NULL;
|
||||||
|
mNamePrefixCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoCompleteEntry(const char* entryType, const StringImpl& display)
|
AutoCompleteEntry(const char* entryType, const StringImpl& display)
|
||||||
|
@ -33,6 +36,15 @@ public:
|
||||||
mEntryType = entryType;
|
mEntryType = entryType;
|
||||||
mDisplay = display.c_str();
|
mDisplay = display.c_str();
|
||||||
mDocumentation = NULL;
|
mDocumentation = NULL;
|
||||||
|
mNamePrefixCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
AutoCompleteEntry(const char* entryType, const StringImpl& display, int namePrefixCount)
|
||||||
|
{
|
||||||
|
mEntryType = entryType;
|
||||||
|
mDisplay = display.c_str();
|
||||||
|
mDocumentation = NULL;
|
||||||
|
mNamePrefixCount = (int8)namePrefixCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const AutoCompleteEntry& other) const
|
bool operator==(const AutoCompleteEntry& other) const
|
||||||
|
@ -88,8 +100,9 @@ public:
|
||||||
int mInsertStartIdx;
|
int mInsertStartIdx;
|
||||||
int mInsertEndIdx;
|
int mInsertEndIdx;
|
||||||
|
|
||||||
bool DoesFilterMatch(const char* entry, const char* filter);
|
bool DoesFilterMatch(const char* entry, const char* filter);
|
||||||
AutoCompleteEntry* AddEntry(const AutoCompleteEntry& entry, const StringImpl& filter);
|
AutoCompleteEntry* AddEntry(const AutoCompleteEntry& entry, const StringImpl& filter);
|
||||||
|
AutoCompleteEntry* AddEntry(const AutoCompleteEntry& entry, const char* filter);
|
||||||
AutoCompleteEntry* AddEntry(const AutoCompleteEntry& entry);
|
AutoCompleteEntry* AddEntry(const AutoCompleteEntry& entry);
|
||||||
|
|
||||||
AutoCompleteBase();
|
AutoCompleteBase();
|
||||||
|
|
|
@ -7959,10 +7959,13 @@ void BfCompiler::GenerateAutocompleteInfo()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
methodText += bfModule->TypeToString(type, BfTypeNameFlag_ResolveGenericParamNames, genericMethodNameOverridesPtr);
|
methodText += bfModule->TypeToString(type, BfTypeNameFlag_ResolveGenericParamNames, genericMethodNameOverridesPtr);
|
||||||
methodInstance->GetParamName(paramIdx, paramName);
|
int namePrefixCount = 0;
|
||||||
|
methodInstance->GetParamName(paramIdx, paramName, namePrefixCount);
|
||||||
if (!paramName.IsEmpty())
|
if (!paramName.IsEmpty())
|
||||||
{
|
{
|
||||||
methodText += " ";
|
methodText += " ";
|
||||||
|
for (int i = 0; i < namePrefixCount; i++)
|
||||||
|
methodText += "@";
|
||||||
methodText += paramName;
|
methodText += paramName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8013,16 +8016,18 @@ void BfCompiler::GenerateAutocompleteInfo()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
autoCompleteResultString += String(entry->mEntryType);
|
autoCompleteResultString += String(entry->mEntryType);
|
||||||
autoCompleteResultString += "\t";
|
autoCompleteResultString += '\t';
|
||||||
|
for (int i = 0; i < entry->mNamePrefixCount; i++)
|
||||||
|
autoCompleteResultString += '@';
|
||||||
autoCompleteResultString += String(entry->mDisplay);
|
autoCompleteResultString += String(entry->mDisplay);
|
||||||
|
|
||||||
if (entry->mDocumentation != NULL)
|
if (entry->mDocumentation != NULL)
|
||||||
{
|
{
|
||||||
autoCompleteResultString += '\x03';
|
autoCompleteResultString += '\x03';
|
||||||
autoCompleteResultString += entry->mDocumentation;
|
autoCompleteResultString += entry->mDocumentation;
|
||||||
}
|
}
|
||||||
|
|
||||||
autoCompleteResultString += "\n";
|
autoCompleteResultString += '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8043,9 +8048,9 @@ String BfCompiler::GetTypeDefList()
|
||||||
if (projectIds.TryAdd(curProject, NULL, &projectIdPtr))
|
if (projectIds.TryAdd(curProject, NULL, &projectIdPtr))
|
||||||
{
|
{
|
||||||
*projectIdPtr = (int)projectIds.size() - 1;
|
*projectIdPtr = (int)projectIds.size() - 1;
|
||||||
result += "+";
|
result += '+';
|
||||||
result += curProject->mName;
|
result += curProject->mName;
|
||||||
result += "\n";
|
result += '\n';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -8059,21 +8064,21 @@ String BfCompiler::GetTypeDefList()
|
||||||
{
|
{
|
||||||
if (typeDef->IsGlobalsContainer())
|
if (typeDef->IsGlobalsContainer())
|
||||||
{
|
{
|
||||||
result += "g";
|
result += 'g';
|
||||||
if (!typeDef->mNamespace.IsEmpty())
|
if (!typeDef->mNamespace.IsEmpty())
|
||||||
{
|
{
|
||||||
typeDef->mNamespace.ToString(result);
|
typeDef->mNamespace.ToString(result);
|
||||||
result += ".";
|
result += '.';
|
||||||
}
|
}
|
||||||
result += ":static\n";
|
result += ":static\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (typeDef->mTypeCode == BfTypeCode_Interface)
|
else if (typeDef->mTypeCode == BfTypeCode_Interface)
|
||||||
result += "i";
|
result += 'i';
|
||||||
else if (typeDef->mTypeCode == BfTypeCode_Object)
|
else if (typeDef->mTypeCode == BfTypeCode_Object)
|
||||||
result += "c";
|
result += 'c';
|
||||||
else
|
else
|
||||||
result += "v";
|
result += 'v';
|
||||||
result += BfTypeUtils::TypeToString(typeDef, BfTypeNameFlag_InternalName) + "\n";
|
result += BfTypeUtils::TypeToString(typeDef, BfTypeNameFlag_InternalName) + "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -566,13 +566,13 @@ BfMethodDef* BfDefBuilder::CreateMethodDef(BfMethodDeclaration* methodDeclaratio
|
||||||
else if (methodDeclaration->mMixinSpecifier != NULL)
|
else if (methodDeclaration->mMixinSpecifier != NULL)
|
||||||
{
|
{
|
||||||
if (methodDeclaration->mNameNode != NULL)
|
if (methodDeclaration->mNameNode != NULL)
|
||||||
methodDef->mName = methodDeclaration->mNameNode->ToString();
|
methodDef->SetName(methodDeclaration->mNameNode);
|
||||||
methodDef->mMethodType = BfMethodType_Mixin;
|
methodDef->mMethodType = BfMethodType_Mixin;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (methodDeclaration->mNameNode != NULL)
|
if (methodDeclaration->mNameNode != NULL)
|
||||||
methodDef->mName = methodDeclaration->mNameNode->ToString();
|
methodDef->SetName(methodDeclaration->mNameNode);
|
||||||
methodDef->mMethodType = BfMethodType_Normal;
|
methodDef->mMethodType = BfMethodType_Normal;
|
||||||
|
|
||||||
if ((methodDeclaration->mThisToken != NULL) && (!methodDeclaration->mParams.IsEmpty()))
|
if ((methodDeclaration->mThisToken != NULL) && (!methodDeclaration->mParams.IsEmpty()))
|
||||||
|
@ -622,7 +622,7 @@ BfMethodDef* BfDefBuilder::CreateMethodDef(BfMethodDeclaration* methodDeclaratio
|
||||||
auto paramDef = new BfParameterDef();
|
auto paramDef = new BfParameterDef();
|
||||||
paramDef->mParamDeclaration = paramDecl;
|
paramDef->mParamDeclaration = paramDecl;
|
||||||
if (paramDecl->mNameNode != NULL)
|
if (paramDecl->mNameNode != NULL)
|
||||||
paramDef->mName = paramDecl->mNameNode->ToString();
|
paramDef->SetName(paramDecl->mNameNode);
|
||||||
paramDef->mTypeRef = paramDecl->mTypeRef;
|
paramDef->mTypeRef = paramDecl->mTypeRef;
|
||||||
paramDef->mMethodGenericParamIdx = mSystem->GetGenericParamIdx(methodDef->mGenericParams, paramDef->mTypeRef);
|
paramDef->mMethodGenericParamIdx = mSystem->GetGenericParamIdx(methodDef->mGenericParams, paramDef->mTypeRef);
|
||||||
if (paramDecl->mModToken == NULL)
|
if (paramDecl->mModToken == NULL)
|
||||||
|
@ -703,6 +703,11 @@ BfMethodDef* BfDefBuilder::CreateMethodDef(BfMethodDeclaration* methodDeclaratio
|
||||||
{
|
{
|
||||||
auto fieldDef = new BfFieldDef();
|
auto fieldDef = new BfFieldDef();
|
||||||
fieldDef->mName = paramDef->mName;
|
fieldDef->mName = paramDef->mName;
|
||||||
|
while (fieldDef->mName.StartsWith("@"))
|
||||||
|
{
|
||||||
|
fieldDef->mNamePrefixCount++;
|
||||||
|
fieldDef->mName.Remove(0);
|
||||||
|
}
|
||||||
fieldDef->mTypeRef = paramDef->mTypeRef;
|
fieldDef->mTypeRef = paramDef->mTypeRef;
|
||||||
fieldDef->mProtection = BfProtection_Public;
|
fieldDef->mProtection = BfProtection_Public;
|
||||||
BF_ASSERT(mCurDeclaringTypeDef != NULL);
|
BF_ASSERT(mCurDeclaringTypeDef != NULL);
|
||||||
|
@ -918,7 +923,7 @@ void BfDefBuilder::Visit(BfPropertyDeclaration* propertyDeclaration)
|
||||||
propertyDef->mIsStatic = propertyDeclaration->mStaticSpecifier != NULL;
|
propertyDef->mIsStatic = propertyDeclaration->mStaticSpecifier != NULL;
|
||||||
propertyDef->mIsReadOnly = propertyDeclaration->mReadOnlySpecifier != NULL;
|
propertyDef->mIsReadOnly = propertyDeclaration->mReadOnlySpecifier != NULL;
|
||||||
if (propertyDeclaration->mNameNode != NULL)
|
if (propertyDeclaration->mNameNode != NULL)
|
||||||
propertyDef->mName = propertyDeclaration->mNameNode->ToString();
|
propertyDef->SetName(propertyDeclaration->mNameNode);
|
||||||
else if (propertyDeclaration->IsA<BfIndexerDeclaration>())
|
else if (propertyDeclaration->IsA<BfIndexerDeclaration>())
|
||||||
{
|
{
|
||||||
propertyDef->mName = "[]";
|
propertyDef->mName = "[]";
|
||||||
|
@ -965,7 +970,7 @@ void BfDefBuilder::Visit(BfPropertyDeclaration* propertyDeclaration)
|
||||||
fieldDef->mInitializer = propertyDeclaration->mInitializer;
|
fieldDef->mInitializer = propertyDeclaration->mInitializer;
|
||||||
mCurTypeDef->mFields.push_back(fieldDef);
|
mCurTypeDef->mFields.push_back(fieldDef);
|
||||||
|
|
||||||
mCurTypeDef->mSignatureHash = HashString(fieldDef->mName, mCurTypeDef->mSignatureHash);
|
mCurTypeDef->mSignatureHash = HashString(fieldDef->mName, mCurTypeDef->mSignatureHash + fieldDef->mNamePrefixCount);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1046,7 +1051,7 @@ void BfDefBuilder::Visit(BfPropertyDeclaration* propertyDeclaration)
|
||||||
auto paramDef = new BfParameterDef();
|
auto paramDef = new BfParameterDef();
|
||||||
BfParameterDeclaration* paramDecl = indexerDeclaration->mParams[paramIdx];
|
BfParameterDeclaration* paramDecl = indexerDeclaration->mParams[paramIdx];
|
||||||
paramDef->mParamDeclaration = paramDecl;
|
paramDef->mParamDeclaration = paramDecl;
|
||||||
paramDef->mName = paramDecl->mNameNode->ToString();
|
paramDef->SetName(paramDecl->mNameNode);
|
||||||
paramDef->mTypeRef = paramDecl->mTypeRef;
|
paramDef->mTypeRef = paramDecl->mTypeRef;
|
||||||
paramDef->mMethodGenericParamIdx = mSystem->GetGenericParamIdx(methodDef->mGenericParams, paramDef->mTypeRef);
|
paramDef->mMethodGenericParamIdx = mSystem->GetGenericParamIdx(methodDef->mGenericParams, paramDef->mTypeRef);
|
||||||
if (paramDecl->mModToken == NULL)
|
if (paramDecl->mModToken == NULL)
|
||||||
|
@ -1133,7 +1138,7 @@ void BfDefBuilder::Visit(BfFieldDeclaration* fieldDeclaration)
|
||||||
BF_ASSERT(mCurDeclaringTypeDef != NULL);
|
BF_ASSERT(mCurDeclaringTypeDef != NULL);
|
||||||
fieldDef->mDeclaringType = mCurDeclaringTypeDef;
|
fieldDef->mDeclaringType = mCurDeclaringTypeDef;
|
||||||
if (fieldDeclaration->mNameNode != NULL)
|
if (fieldDeclaration->mNameNode != NULL)
|
||||||
fieldDef->mName = fieldDeclaration->mNameNode->ToString();
|
fieldDef->SetName(fieldDeclaration->mNameNode);
|
||||||
fieldDef->mProtection = GetProtection(fieldDeclaration->mProtectionSpecifier);
|
fieldDef->mProtection = GetProtection(fieldDeclaration->mProtectionSpecifier);
|
||||||
if (isEnumEntryDecl)
|
if (isEnumEntryDecl)
|
||||||
fieldDef->mProtection = BfProtection_Public;
|
fieldDef->mProtection = BfProtection_Public;
|
||||||
|
@ -2012,6 +2017,7 @@ void BfDefBuilder::FinishTypeDef(bool wantsToString)
|
||||||
{
|
{
|
||||||
BfParameterDef* newParam = new BfParameterDef();
|
BfParameterDef* newParam = new BfParameterDef();
|
||||||
newParam->mName = param->mName;
|
newParam->mName = param->mName;
|
||||||
|
newParam->mNamePrefixCount = param->mNamePrefixCount;
|
||||||
newParam->mTypeRef = param->mTypeRef;
|
newParam->mTypeRef = param->mTypeRef;
|
||||||
newParam->mMethodGenericParamIdx = param->mMethodGenericParamIdx;
|
newParam->mMethodGenericParamIdx = param->mMethodGenericParamIdx;
|
||||||
methodDef->mParams.push_back(newParam);
|
methodDef->mParams.push_back(newParam);
|
||||||
|
|
|
@ -3852,6 +3852,9 @@ BfTypedValue BfExprEvaluator::LookupIdentifier(BfAstNode* refNode, const StringI
|
||||||
{
|
{
|
||||||
auto varDecl = entry->mLocalVar;
|
auto varDecl = entry->mLocalVar;
|
||||||
|
|
||||||
|
if (varDecl != NULL)
|
||||||
|
varSkipCount -= varDecl->mNamePrefixCount;
|
||||||
|
|
||||||
while ((varSkipCount > 0) && (varDecl != NULL))
|
while ((varSkipCount > 0) && (varDecl != NULL))
|
||||||
{
|
{
|
||||||
varDecl = varDecl->mShadowedLocal;
|
varDecl = varDecl->mShadowedLocal;
|
||||||
|
@ -4347,9 +4350,13 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
|
||||||
if (curCheckType->mTypeDef->mFieldSet.TryGetWith(findName, &entry))
|
if (curCheckType->mTypeDef->mFieldSet.TryGetWith(findName, &entry))
|
||||||
nextField = (BfFieldDef*)entry->mMemberDef;
|
nextField = (BfFieldDef*)entry->mMemberDef;
|
||||||
|
|
||||||
|
if (nextField != NULL)
|
||||||
|
varSkipCount -= nextField->mNamePrefixCount;
|
||||||
|
|
||||||
while ((varSkipCount > 0) && (nextField != NULL))
|
while ((varSkipCount > 0) && (nextField != NULL))
|
||||||
{
|
{
|
||||||
nextField = nextField->mNextWithSameName;
|
nextField = nextField->mNextWithSameName;
|
||||||
|
varSkipCount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
BfProtectionCheckFlags protectionCheckFlags = BfProtectionCheckFlag_None;
|
BfProtectionCheckFlags protectionCheckFlags = BfProtectionCheckFlag_None;
|
||||||
|
|
|
@ -17695,7 +17695,9 @@ void BfModule::ProcessMethod_SetupParams(BfMethodInstance* methodInstance, BfTyp
|
||||||
prevIgnoreErrors.Restore();
|
prevIgnoreErrors.Restore();
|
||||||
PopulateType(resolvedType, BfPopulateType_Declaration);
|
PopulateType(resolvedType, BfPopulateType_Declaration);
|
||||||
paramVar->mResolvedType = resolvedType;
|
paramVar->mResolvedType = resolvedType;
|
||||||
paramVar->mName = methodInstance->GetParamName(paramIdx);
|
int namePrefixCount = 0;
|
||||||
|
paramVar->mName = methodInstance->GetParamName(paramIdx, namePrefixCount);
|
||||||
|
paramVar->mNamePrefixCount = (uint8)namePrefixCount;
|
||||||
paramVar->mNameNode = methodInstance->GetParamNameNode(paramIdx);
|
paramVar->mNameNode = methodInstance->GetParamNameNode(paramIdx);
|
||||||
if (!isParamSkipped)
|
if (!isParamSkipped)
|
||||||
{
|
{
|
||||||
|
@ -17818,6 +17820,7 @@ void BfModule::ProcessMethod_SetupParams(BfMethodInstance* methodInstance, BfTyp
|
||||||
auto paramInst = &methodInstance->mParams[paramIdx];
|
auto paramInst = &methodInstance->mParams[paramIdx];
|
||||||
auto paramDef = methodDef->mParams[paramInst->mParamDefIdx];
|
auto paramDef = methodDef->mParams[paramInst->mParamDefIdx];
|
||||||
localVar->mName = paramDef->mName;
|
localVar->mName = paramDef->mName;
|
||||||
|
localVar->mNamePrefixCount = paramDef->mNamePrefixCount;
|
||||||
localVar->mResolvedType = ResolveTypeRef(paramDef->mTypeRef, BfPopulateType_Declaration, BfResolveTypeRefFlag_NoResolveGenericParam);
|
localVar->mResolvedType = ResolveTypeRef(paramDef->mTypeRef, BfPopulateType_Declaration, BfResolveTypeRefFlag_NoResolveGenericParam);
|
||||||
localVar->mCompositeCount = 0;
|
localVar->mCompositeCount = 0;
|
||||||
DoAddLocalVariable(localVar);
|
DoAddLocalVariable(localVar);
|
||||||
|
|
|
@ -161,6 +161,7 @@ public:
|
||||||
int mWrittenToId;
|
int mWrittenToId;
|
||||||
int mReadFromId;
|
int mReadFromId;
|
||||||
int mParamIdx;
|
int mParamIdx;
|
||||||
|
uint8 mNamePrefixCount;
|
||||||
bool mIsThis;
|
bool mIsThis;
|
||||||
bool mHasLocalStructBacking;
|
bool mHasLocalStructBacking;
|
||||||
bool mIsStruct;
|
bool mIsStruct;
|
||||||
|
@ -187,6 +188,7 @@ public:
|
||||||
mLocalVarId = -1;
|
mLocalVarId = -1;
|
||||||
mCompositeCount = -1;
|
mCompositeCount = -1;
|
||||||
mParamIdx = -2;
|
mParamIdx = -2;
|
||||||
|
mNamePrefixCount = 0;
|
||||||
mIsThis = false;
|
mIsThis = false;
|
||||||
mHasLocalStructBacking = false;
|
mHasLocalStructBacking = false;
|
||||||
mIsStruct = false;
|
mIsStruct = false;
|
||||||
|
|
|
@ -13058,8 +13058,10 @@ BfTypedValue BfModule::Cast(BfAstNode* srcNode, const BfTypedValue& typedVal, Bf
|
||||||
|
|
||||||
if (!explicitCast)
|
if (!explicitCast)
|
||||||
{
|
{
|
||||||
fromMethodInst->GetParamName(paramIdx, fromParamName);
|
int fromNamePrefixCount = 0;
|
||||||
toMethodInst->GetParamName(paramIdx, toParamName);
|
int toNamePrefixCount = 0;
|
||||||
|
fromMethodInst->GetParamName(paramIdx, fromParamName, fromNamePrefixCount);
|
||||||
|
toMethodInst->GetParamName(paramIdx, toParamName, toNamePrefixCount);
|
||||||
if ((!fromParamName.IsEmpty()) && (!toParamName.IsEmpty()))
|
if ((!fromParamName.IsEmpty()) && (!toParamName.IsEmpty()))
|
||||||
nameMatches = fromParamName == toParamName;
|
nameMatches = fromParamName == toParamName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -946,7 +946,7 @@ int BfMethodInstance::GetImplicitParamCount()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BfMethodInstance::GetParamName(int paramIdx, StringImpl& name)
|
void BfMethodInstance::GetParamName(int paramIdx, StringImpl& name, int& namePrefixCount)
|
||||||
{
|
{
|
||||||
if (paramIdx == -1)
|
if (paramIdx == -1)
|
||||||
{
|
{
|
||||||
|
@ -972,16 +972,25 @@ void BfMethodInstance::GetParamName(int paramIdx, StringImpl& name)
|
||||||
if (methodParam->mDelegateParamNameCombine)
|
if (methodParam->mDelegateParamNameCombine)
|
||||||
name = paramDef->mName + "__" + invokeMethodInstance->GetParamName(methodParam->mDelegateParamIdx);
|
name = paramDef->mName + "__" + invokeMethodInstance->GetParamName(methodParam->mDelegateParamIdx);
|
||||||
else
|
else
|
||||||
invokeMethodInstance->GetParamName(methodParam->mDelegateParamIdx, name);
|
invokeMethodInstance->GetParamName(methodParam->mDelegateParamIdx, name, namePrefixCount);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
name = paramDef->mName;
|
name = paramDef->mName;
|
||||||
|
namePrefixCount = paramDef->mNamePrefixCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
String BfMethodInstance::GetParamName(int paramIdx)
|
String BfMethodInstance::GetParamName(int paramIdx)
|
||||||
|
{
|
||||||
|
String paramName;
|
||||||
|
int namePrefixCount = 0;
|
||||||
|
GetParamName(paramIdx, paramName, namePrefixCount);
|
||||||
|
return paramName;
|
||||||
|
}
|
||||||
|
|
||||||
|
String BfMethodInstance::GetParamName(int paramIdx, int& namePrefixCount)
|
||||||
{
|
{
|
||||||
String paramName;
|
String paramName;
|
||||||
GetParamName(paramIdx, paramName);
|
GetParamName(paramIdx, paramName, namePrefixCount);
|
||||||
return paramName;
|
return paramName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -946,8 +946,9 @@ public:
|
||||||
bool AllowsSplatting(int paramIdx);
|
bool AllowsSplatting(int paramIdx);
|
||||||
int GetParamCount();
|
int GetParamCount();
|
||||||
int GetImplicitParamCount();
|
int GetImplicitParamCount();
|
||||||
void GetParamName(int paramIdx, StringImpl& name);
|
void GetParamName(int paramIdx, StringImpl& name, int& namePrefixCount);
|
||||||
String GetParamName(int paramIdx);
|
String GetParamName(int paramIdx);
|
||||||
|
String GetParamName(int paramIdx, int& namePrefixCount);
|
||||||
BfType* GetParamType(int paramIdx, bool returnUnderlyingParamsType = false);
|
BfType* GetParamType(int paramIdx, bool returnUnderlyingParamsType = false);
|
||||||
bool GetParamIsSplat(int paramIdx);
|
bool GetParamIsSplat(int paramIdx);
|
||||||
BfParamKind GetParamKind(int paramIdx);
|
BfParamKind GetParamKind(int paramIdx);
|
||||||
|
|
|
@ -383,6 +383,30 @@ BfSizedAtomComposite::~BfSizedAtomComposite()
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void BfMemberDef::SetName(BfAstNode* nameNode)
|
||||||
|
{
|
||||||
|
StringView sv = nameNode->ToStringView();
|
||||||
|
while ((!sv.IsEmpty()) && (sv[0] == '@'))
|
||||||
|
{
|
||||||
|
sv.RemoveFromStart(1);
|
||||||
|
mNamePrefixCount++;
|
||||||
|
}
|
||||||
|
mName = sv;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BfParameterDef::SetName(BfAstNode* nameNode)
|
||||||
|
{
|
||||||
|
StringView sv = nameNode->ToStringView();
|
||||||
|
while ((!sv.IsEmpty()) && (sv[0] == '@'))
|
||||||
|
{
|
||||||
|
sv.RemoveFromStart(1);
|
||||||
|
mNamePrefixCount++;
|
||||||
|
}
|
||||||
|
mName = sv;
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool BfPropertyDef::IsVirtual()
|
bool BfPropertyDef::IsVirtual()
|
||||||
{
|
{
|
||||||
if (((BfPropertyDeclaration*)mFieldDeclaration)->mVirtualSpecifier)
|
if (((BfPropertyDeclaration*)mFieldDeclaration)->mVirtualSpecifier)
|
||||||
|
@ -4484,3 +4508,5 @@ BF_EXPORT void BF_CALLTYPE BfSystem_Log(BfSystem* bfSystem, char* str)
|
||||||
BfLogSys(bfSystem, str);
|
BfLogSys(bfSystem, str);
|
||||||
BfLogSys(bfSystem, "\n");
|
BfLogSys(bfSystem, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -507,6 +507,7 @@ public:
|
||||||
BfParameterDeclaration* mParamDeclaration;
|
BfParameterDeclaration* mParamDeclaration;
|
||||||
int mMethodGenericParamIdx;
|
int mMethodGenericParamIdx;
|
||||||
BfParamKind mParamKind;
|
BfParamKind mParamKind;
|
||||||
|
uint8 mNamePrefixCount; // Number of @'s
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BfParameterDef()
|
BfParameterDef()
|
||||||
|
@ -515,7 +516,9 @@ public:
|
||||||
mMethodGenericParamIdx = -1;
|
mMethodGenericParamIdx = -1;
|
||||||
mParamKind = BfParamKind_Normal;
|
mParamKind = BfParamKind_Normal;
|
||||||
mParamDeclaration = NULL;
|
mParamDeclaration = NULL;
|
||||||
|
mNamePrefixCount = 0;
|
||||||
}
|
}
|
||||||
|
void SetName(BfAstNode* nameNode);
|
||||||
};
|
};
|
||||||
|
|
||||||
class BfMemberDef
|
class BfMemberDef
|
||||||
|
@ -528,6 +531,7 @@ public:
|
||||||
#endif
|
#endif
|
||||||
BfTypeDef* mDeclaringType;
|
BfTypeDef* mDeclaringType;
|
||||||
BfProtection mProtection;
|
BfProtection mProtection;
|
||||||
|
uint8 mNamePrefixCount; // Number of @'s
|
||||||
bool mIsStatic;
|
bool mIsStatic;
|
||||||
bool mIsNoShow;
|
bool mIsNoShow;
|
||||||
bool mIsReadOnly;
|
bool mIsReadOnly;
|
||||||
|
@ -538,6 +542,7 @@ public:
|
||||||
{
|
{
|
||||||
mDeclaringType = NULL;
|
mDeclaringType = NULL;
|
||||||
mProtection = BfProtection_Public;
|
mProtection = BfProtection_Public;
|
||||||
|
mNamePrefixCount = 0;
|
||||||
mIsStatic = false;
|
mIsStatic = false;
|
||||||
mIsNoShow = false;
|
mIsNoShow = false;
|
||||||
mIsReadOnly = false;
|
mIsReadOnly = false;
|
||||||
|
@ -547,6 +552,8 @@ public:
|
||||||
virtual ~BfMemberDef()
|
virtual ~BfMemberDef()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetName(BfAstNode* nameNode);
|
||||||
};
|
};
|
||||||
|
|
||||||
class BfFieldDef : public BfMemberDef
|
class BfFieldDef : public BfMemberDef
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue