mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
@this delegate reference in lambda bodies
This commit is contained in:
parent
9872ce989b
commit
e83d9f5bae
2 changed files with 18 additions and 2 deletions
|
@ -4322,6 +4322,20 @@ BfTypedValue BfExprEvaluator::LookupIdentifier(BfAstNode* refNode, const StringI
|
||||||
mModule->FixValueActualization(result);
|
mModule->FixValueActualization(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((mModule->mCurMethodState != NULL) && (mModule->mCurMethodState->mClosureState != NULL) && (findName == "@this"))
|
||||||
|
{
|
||||||
|
if (mModule->mCurMethodState->mClosureState->mCapturing)
|
||||||
|
{
|
||||||
|
mModule->mCurMethodState->mClosureState->mCapturedDelegateSelf = true;
|
||||||
|
return mModule->GetDefaultTypedValue(mModule->ResolveTypeDef(mModule->mCompiler->mDelegateTypeDef));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto thisLocal = mModule->mCurMethodState->mLocals[0];
|
||||||
|
return BfTypedValue(mModule->mBfIRBuilder->CreateLoad(thisLocal->mAddr), thisLocal->mResolvedType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13606,7 +13620,7 @@ BfLambdaInstance* BfExprEvaluator::GetLambdaInstance(BfLambdaBindExpression* lam
|
||||||
|
|
||||||
// If we are allowing hot swapping, we need to always mangle the name to non-static because if we add a capture
|
// 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
|
// later then we need to have the mangled names match
|
||||||
methodDef->mIsStatic = (closureTypeInst == NULL) && (!mModule->mCompiler->mOptions.mAllowHotSwapping);
|
methodDef->mIsStatic = (closureTypeInst == NULL) && (!mModule->mCompiler->mOptions.mAllowHotSwapping) && (!closureState.mCapturedDelegateSelf);
|
||||||
|
|
||||||
SizedArray<BfIRType, 8> origParamTypes;
|
SizedArray<BfIRType, 8> origParamTypes;
|
||||||
BfIRType origReturnType;
|
BfIRType origReturnType;
|
||||||
|
|
|
@ -689,7 +689,8 @@ public:
|
||||||
int mCaptureStartAccessId;
|
int mCaptureStartAccessId;
|
||||||
// When we need to look into another local method to determine captures, but we don't want to process local variable declarations or cause infinite recursion
|
// When we need to look into another local method to determine captures, but we don't want to process local variable declarations or cause infinite recursion
|
||||||
bool mBlindCapturing;
|
bool mBlindCapturing;
|
||||||
bool mDeclaringMethodIsMutating;
|
bool mDeclaringMethodIsMutating;
|
||||||
|
bool mCapturedDelegateSelf;
|
||||||
BfReturnTypeInferState mReturnTypeInferState;
|
BfReturnTypeInferState mReturnTypeInferState;
|
||||||
BfLocalMethod* mLocalMethod;
|
BfLocalMethod* mLocalMethod;
|
||||||
BfClosureInstanceInfo* mClosureInstanceInfo;
|
BfClosureInstanceInfo* mClosureInstanceInfo;
|
||||||
|
@ -714,6 +715,7 @@ public:
|
||||||
mCaptureStartAccessId = -1;
|
mCaptureStartAccessId = -1;
|
||||||
mBlindCapturing = false;
|
mBlindCapturing = false;
|
||||||
mDeclaringMethodIsMutating = false;
|
mDeclaringMethodIsMutating = false;
|
||||||
|
mCapturedDelegateSelf = false;
|
||||||
mReturnTypeInferState = BfReturnTypeInferState_None;
|
mReturnTypeInferState = BfReturnTypeInferState_None;
|
||||||
mActiveDeferredLocalMethod = NULL;
|
mActiveDeferredLocalMethod = NULL;
|
||||||
mReturnType = NULL;
|
mReturnType = NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue