mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Fixed 'using static'
This commit is contained in:
parent
41629b49d1
commit
c1a2bd79e1
7 changed files with 74 additions and 36 deletions
|
@ -1233,40 +1233,17 @@ void BfAutoComplete::CheckIdentifier(BfAstNode* identifierNode, bool isInExpress
|
||||||
AddTypeMembers(globalContainer.mTypeInst, true, false, filter, globalContainer.mTypeInst, true, true);
|
AddTypeMembers(globalContainer.mTypeInst, true, false, filter, globalContainer.mTypeInst, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
BfStaticSearch* staticSearch = mModule->GetStaticSearch();
|
||||||
|
if (staticSearch != NULL)
|
||||||
{
|
{
|
||||||
auto activeTypeDef = mModule->GetActiveTypeDef();
|
for (auto typeInst : staticSearch->mStaticTypes)
|
||||||
|
|
||||||
BfStaticSearch* staticSearch;
|
|
||||||
if ((mModule->mCurTypeInstance != NULL) && (mModule->mCurTypeInstance->mStaticSearchMap.TryGetValue(activeTypeDef, &staticSearch)))
|
|
||||||
{
|
{
|
||||||
for (auto typeInst : staticSearch->mStaticTypes)
|
AddTypeMembers(typeInst, true, false, filter, typeInst, true, true);
|
||||||
{
|
AddInnerTypes(typeInst, filter, false, false);
|
||||||
AddTypeMembers(typeInst, true, false, filter, typeInst, true, true);
|
|
||||||
AddInnerTypes(typeInst, filter, false, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ((activeTypeDef != NULL) && (!activeTypeDef->mStaticSearch.IsEmpty()))
|
|
||||||
{
|
|
||||||
BF_ASSERT(mModule->mCompiler->IsAutocomplete());
|
|
||||||
for (auto typeRef : activeTypeDef->mStaticSearch)
|
|
||||||
{
|
|
||||||
auto type = mModule->ResolveTypeRef(typeRef, NULL, BfPopulateType_Declaration);
|
|
||||||
if (type != NULL)
|
|
||||||
{
|
|
||||||
auto typeInst = type->ToTypeInstance();
|
|
||||||
if (typeInst != NULL)
|
|
||||||
{
|
|
||||||
AddTypeMembers(typeInst, true, false, filter, typeInst, true, true);
|
|
||||||
AddInnerTypes(typeInst, filter, false, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
BfMethodInstance* curMethodInstance = mModule->mCurMethodInstance;
|
BfMethodInstance* curMethodInstance = mModule->mCurMethodInstance;
|
||||||
|
|
|
@ -3692,7 +3692,7 @@ void BfCompiler::ProcessAutocompleteTempType()
|
||||||
mContext->HandleChangedTypeDef(tempTypeDef, true);
|
mContext->HandleChangedTypeDef(tempTypeDef, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tempTypeDef == NULL)
|
if (tempTypeDef == NULL)
|
||||||
{
|
{
|
||||||
GenerateAutocompleteInfo();
|
GenerateAutocompleteInfo();
|
||||||
|
@ -3705,13 +3705,28 @@ void BfCompiler::ProcessAutocompleteTempType()
|
||||||
BfLogSysM("ProcessAutocompleteTempType - project disabled\n");
|
BfLogSysM("ProcessAutocompleteTempType - project disabled\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetAndRestoreValue<BfMethodState*> prevMethodState(module->mCurMethodState, NULL);
|
SetAndRestoreValue<BfMethodState*> prevMethodState(module->mCurMethodState, NULL);
|
||||||
|
|
||||||
BfTypeState typeState;
|
BfTypeState typeState;
|
||||||
typeState.mCurTypeDef = tempTypeDef;
|
typeState.mCurTypeDef = tempTypeDef;
|
||||||
SetAndRestoreValue<BfTypeState*> prevTypeState(module->mContext->mCurTypeState, &typeState);
|
SetAndRestoreValue<BfTypeState*> prevTypeState(module->mContext->mCurTypeState, &typeState);
|
||||||
|
|
||||||
|
BfStaticSearch* staticSearch = NULL;
|
||||||
|
if (mResolvePassData->mStaticSearchMap.TryAdd(tempTypeDef, NULL, &staticSearch))
|
||||||
|
{
|
||||||
|
for (auto typeRef : tempTypeDef->mStaticSearch)
|
||||||
|
{
|
||||||
|
auto type = module->ResolveTypeRef(typeRef, NULL, BfPopulateType_Declaration);
|
||||||
|
if (type != NULL)
|
||||||
|
{
|
||||||
|
auto typeInst = type->ToTypeInstance();
|
||||||
|
if (typeInst != NULL)
|
||||||
|
staticSearch->mStaticTypes.Add(typeInst);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto _FindAcutalTypeDef = [&](BfTypeDef* tempTypeDef)
|
auto _FindAcutalTypeDef = [&](BfTypeDef* tempTypeDef)
|
||||||
{
|
{
|
||||||
auto typeName = tempTypeDef->mFullName;
|
auto typeName = tempTypeDef->mFullName;
|
||||||
|
|
|
@ -1680,12 +1680,14 @@ NoMatch:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hadMatch)
|
if (hadMatch)
|
||||||
{
|
{
|
||||||
mBestMethodTypeInstance = typeInstance;
|
mBestMethodTypeInstance = typeInstance;
|
||||||
if (genericArgumentsSubstitute != &mBestMethodGenericArguments)
|
if (genericArgumentsSubstitute != &mBestMethodGenericArguments)
|
||||||
{
|
{
|
||||||
if (genericArgumentsSubstitute != NULL)
|
if (genericArgumentsSubstitute != NULL)
|
||||||
{
|
{
|
||||||
|
for (auto& genericArg : *genericArgumentsSubstitute)
|
||||||
|
genericArg = mModule->FixIntUnknown(genericArg);
|
||||||
mBestMethodGenericArguments = *genericArgumentsSubstitute;
|
mBestMethodGenericArguments = *genericArgumentsSubstitute;
|
||||||
// #ifdef _DEBUG
|
// #ifdef _DEBUG
|
||||||
// for (auto arg : mBestMethodGenericArguments)
|
// for (auto arg : mBestMethodGenericArguments)
|
||||||
|
@ -3272,9 +3274,19 @@ BfTypedValue BfExprEvaluator::LookupIdentifier(BfAstNode* refNode, const StringI
|
||||||
result = LookupField(identifierNode, thisValue, findName);
|
result = LookupField(identifierNode, thisValue, findName);
|
||||||
if ((result) || (mPropDef != NULL))
|
if ((result) || (mPropDef != NULL))
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//TODO: Try static search
|
auto staticSearch = mModule->GetStaticSearch();
|
||||||
|
if (staticSearch != NULL)
|
||||||
|
{
|
||||||
|
for (auto typeInst : staticSearch->mStaticTypes)
|
||||||
|
{
|
||||||
|
thisValue = BfTypedValue(typeInst);
|
||||||
|
result = LookupField(identifierNode, thisValue, findName);
|
||||||
|
if ((result) || (mPropDef != NULL))
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7062,6 +7074,25 @@ BfTypedValue BfExprEvaluator::MatchMethod(BfAstNode* targetSrc, BfMethodBoundExp
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (methodDef == NULL)
|
||||||
|
{
|
||||||
|
BfStaticSearch* staticSearch = mModule->GetStaticSearch();
|
||||||
|
if (staticSearch != NULL)
|
||||||
|
{
|
||||||
|
for (auto typeInst : staticSearch->mStaticTypes)
|
||||||
|
{
|
||||||
|
methodMatcher.CheckType(typeInst, BfTypedValue(), false);
|
||||||
|
if (methodMatcher.mBestMethodDef != NULL)
|
||||||
|
{
|
||||||
|
isFailurePass = false;
|
||||||
|
curTypeInst = methodMatcher.mBestMethodTypeInstance;
|
||||||
|
methodDef = methodMatcher.mBestMethodDef;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (methodDef == NULL)
|
if (methodDef == NULL)
|
||||||
|
|
|
@ -3205,6 +3205,17 @@ void BfModule::PopulateGlobalContainersList(const BfGlobalLookup& globalLookup)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BfStaticSearch* BfModule::GetStaticSearch()
|
||||||
|
{
|
||||||
|
auto activeTypeDef = GetActiveTypeDef();
|
||||||
|
BfStaticSearch* staticSearch = NULL;
|
||||||
|
if ((mCurTypeInstance != NULL) && (mCurTypeInstance->mStaticSearchMap.TryGetValue(activeTypeDef, &staticSearch)))
|
||||||
|
return staticSearch;
|
||||||
|
if ((mCompiler->mResolvePassData != NULL) && (mCompiler->mResolvePassData->mStaticSearchMap.TryGetValue(activeTypeDef, &staticSearch)))
|
||||||
|
return staticSearch;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void PrintUsers(llvm::MDNode* md);
|
void PrintUsers(llvm::MDNode* md);
|
||||||
|
|
||||||
BfModuleOptions BfModule::GetModuleOptions()
|
BfModuleOptions BfModule::GetModuleOptions()
|
||||||
|
|
|
@ -1609,6 +1609,7 @@ public:
|
||||||
void TypeFailed(BfTypeInstance* typeInstance);
|
void TypeFailed(BfTypeInstance* typeInstance);
|
||||||
bool IsAttribute(BfTypeInstance* typeInst);
|
bool IsAttribute(BfTypeInstance* typeInst);
|
||||||
void PopulateGlobalContainersList(const BfGlobalLookup& globalLookup);
|
void PopulateGlobalContainersList(const BfGlobalLookup& globalLookup);
|
||||||
|
BfStaticSearch* GetStaticSearch();
|
||||||
void AddFailType(BfTypeInstance* typeInstance);
|
void AddFailType(BfTypeInstance* typeInstance);
|
||||||
void MarkDerivedDirty(BfTypeInstance* typeInst);
|
void MarkDerivedDirty(BfTypeInstance* typeInst);
|
||||||
void CheckAddFailType();
|
void CheckAddFailType();
|
||||||
|
|
|
@ -1770,9 +1770,10 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
staticSearch->mStaticTypes.Add(staticTypeInst);
|
||||||
AddDependency(staticTypeInst, typeInstance, BfDependencyMap::DependencyFlag_StaticValue);
|
AddDependency(staticTypeInst, typeInstance, BfDependencyMap::DependencyFlag_StaticValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "BfSystem.h"
|
#include "BfSystem.h"
|
||||||
|
#include "BfResolvedTypeUtils.h"
|
||||||
|
|
||||||
NS_BF_BEGIN
|
NS_BF_BEGIN
|
||||||
|
|
||||||
|
@ -46,6 +47,7 @@ public:
|
||||||
BfParser* mParser;
|
BfParser* mParser;
|
||||||
BfAutoComplete* mAutoComplete;
|
BfAutoComplete* mAutoComplete;
|
||||||
Array<BfTypeDef*> mAutoCompleteTempTypes; // Contains multiple values when we have nested types
|
Array<BfTypeDef*> mAutoCompleteTempTypes; // Contains multiple values when we have nested types
|
||||||
|
Dictionary<BfTypeDef*, BfStaticSearch> mStaticSearchMap;
|
||||||
BfSourceClassifier* mSourceClassifier;
|
BfSourceClassifier* mSourceClassifier;
|
||||||
Array<BfAstNode*> mExteriorAutocompleteCheckNodes;
|
Array<BfAstNode*> mExteriorAutocompleteCheckNodes;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue