1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-23 10:08:00 +02:00

Beefy::String changes, lambda hotswap fixes

Changed some string internals related to StringViewsma
Added an "incompatible capture" error for lambdas when the captures change
This commit is contained in:
Brian Fiete 2019-09-03 11:17:13 -07:00
parent 767a3fafd9
commit 2f01cc14dd
25 changed files with 544 additions and 180 deletions

View file

@ -9553,7 +9553,9 @@ BfLambdaInstance* BfExprEvaluator::GetLambdaInstance(BfLambdaBindExpression* lam
mModule->mBfIRBuilder->PopulateType(useTypeInstance);
mModule->PopulateType(useTypeInstance);
methodDef->mIsStatic = closureTypeInst == NULL;
// If we are allowing hot swapping, we need to always mangle the name to non-static because if we add a capture
// later then we need to have the mangled names match
methodDef->mIsStatic = (closureTypeInst == NULL) && (!mModule->mCompiler->mOptions.mAllowHotSwapping);
SizedArray<BfIRType, 3> newTypes;
SizedArray<BfIRType, 8> origParamTypes;
@ -9598,12 +9600,12 @@ BfLambdaInstance* BfExprEvaluator::GetLambdaInstance(BfLambdaBindExpression* lam
methodDef->mName.RemoveToEnd(prevSepPos);
}
if (closureTypeInst != NULL)
{
StringT<128> typeInstName;
BfMangler::Mangle(typeInstName,mModule->mCompiler->GetMangleKind(), closureTypeInst);
closureHashCtx.MixinStr(typeInstName);
}
// if (closureTypeInst != NULL)
// {
// StringT<128> typeInstName;
// BfMangler::Mangle(typeInstName,mModule->mCompiler->GetMangleKind(), closureTypeInst);
// closureHashCtx.MixinStr(typeInstName);
// }
auto checkMethodState = mModule->mCurMethodState;
while (checkMethodState != NULL)

View file

@ -778,11 +778,7 @@ BfModule* gLastCreatedModule = NULL;
BfModule::BfModule(BfContext* context, const StringImpl& moduleName)
{
BfLogSys(context->mSystem, "BfModule::BFModule %p %s\n", this, moduleName.c_str());
if (moduleName.Contains("_Comparison_"))
{
NOP;
}
gLastCreatedModule = this;
mContext = context;
@ -14930,7 +14926,10 @@ void BfModule::ProcessMethod_ProcessDeferredLocals(int startIdx)
mCurMethodState->mClosureState = &closureState;
//closureState.mConstLocals = deferredLocalMethod->mConstLocals;
closureState.mReturnType = lambdaInstance->mMethodInstance->mReturnType;
closureState.mClosureType = lambdaInstance->mClosureTypeInstance;
if (lambdaInstance->mClosureTypeInstance != NULL)
closureState.mClosureType = lambdaInstance->mClosureTypeInstance;
else
closureState.mClosureType = lambdaInstance->mDelegateTypeInstance;
closureState.mClosureInstanceInfo = lambdaInstance->mMethodInstance->mMethodInfoEx->mClosureInstanceInfo;
mCurMethodState->mMixinState = lambdaInstance->mDeclMixinState;

View file

@ -1773,7 +1773,7 @@ public:
HashSet<int> mDefinedStrings;
public:
BfVDataModule(BfContext* context) : BfModule(context, "vdata")
BfVDataModule(BfContext* context) : BfModule(context, StringImpl::MakeRef("vdata"))
{
}
};

View file

@ -59,10 +59,10 @@ void MemReporter::Report(int depth, Entry* entry)
}
}
void MemReporter::BeginSection(const StringImpl& name)
void MemReporter::BeginSection(const StringView& name)
{
Entry** entryPtr;
if (!mCurEntry->mChildren.TryAdd(name, NULL, &entryPtr))
if (!mCurEntry->mChildren.TryAdd(StringImpl::MakeRef(name), NULL, &entryPtr))
{
mCurEntry = *entryPtr;
mCurEntry->mCount++;
@ -82,7 +82,7 @@ void MemReporter::Add(int size)
mCurEntry->mSize += size;
}
void MemReporter::Add(const StringImpl& name, int size)
void MemReporter::Add(const StringView& name, int size)
{
BeginSection(name);
Add(size);

View file

@ -44,9 +44,9 @@ public:
MemReporter();
~MemReporter();
void BeginSection(const StringImpl& name);
void BeginSection(const StringView& name);
void Add(int size);
void Add(const StringImpl& name, int size);
void Add(const StringView& name, int size);
template <typename T>
void AddVec(const T& vec, bool addContainerSize = true)
@ -55,7 +55,7 @@ public:
}
template <typename T>
void AddVec(const StringImpl& name, const T& vec, bool addContainerSize = true)
void AddVec(const StringView& name, const T& vec, bool addContainerSize = true)
{
BeginSection(name);
Add((addContainerSize ? sizeof(T) : 0) + (int)vec.mAllocSize * sizeof(typename T::value_type));
@ -79,7 +79,7 @@ public:
}
template <typename T>
void AddVecPtr(const StringImpl& name, const Array<T>& vec, bool addContainerSize = true)
void AddVecPtr(const StringView& name, const Array<T>& vec, bool addContainerSize = true)
{
Add(name, (addContainerSize ? sizeof(T) : 0) +
(int)vec.mAllocSize * sizeof(T) +
@ -87,7 +87,7 @@ public:
}
template <typename T>
void AddMap(const StringImpl& name, const T& map, bool addContainerSize = true)
void AddMap(const StringView& name, const T& map, bool addContainerSize = true)
{
Add(name, (addContainerSize ? sizeof(T) : 0) + map.mAllocSize * (sizeof(typename T::EntryPair) + sizeof(typename T::int_cosize)));
}
@ -99,7 +99,7 @@ public:
}
template <typename T>
void AddHashSet(const StringImpl& name, const T& map, bool addContainerSize = true)
void AddHashSet(const StringView& name, const T& map, bool addContainerSize = true)
{
Add(name, (addContainerSize ? sizeof(T) : 0) + map.mAllocSize * (sizeof(typename T::Entry) + sizeof(typename T::int_cosize)));
}
@ -115,7 +115,7 @@ public:
Add((addContainerSize ? sizeof(StringImpl) : 0) + (int)str.GetAllocSize());
}
void AddStr(const StringImpl& name, const StringImpl& str, bool addContainerSize = true)
void AddStr(const StringView& name, const StringImpl& str, bool addContainerSize = true)
{
Add(name, (addContainerSize ? sizeof(StringImpl) : 0) + (int)str.GetAllocSize());
}
@ -125,7 +125,7 @@ public:
template <typename T>
void AddBumpAlloc(const StringImpl& name, const T& alloc)
void AddBumpAlloc(const StringView& name, const T& alloc)
{
BeginSection(name);