mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-21 17:28:00 +02:00
Support for non-static ++ and -- operator overloads
This commit is contained in:
parent
5924d4819b
commit
66d5f67528
3 changed files with 58 additions and 19 deletions
|
@ -17721,8 +17721,16 @@ BfTypedValue BfExprEvaluator::PerformUnaryOperation_TryOperator(const BfTypedVal
|
|||
{
|
||||
if (!methodMatcher.IsMemberAccessible(checkType, operatorDef->mDeclaringType))
|
||||
continue;
|
||||
|
||||
int prevArgSize = (int)args.mSize;
|
||||
if (!operatorDef->mIsStatic)
|
||||
{
|
||||
// Try without arg
|
||||
args.mSize = 0;
|
||||
}
|
||||
if (methodMatcher.CheckMethod(NULL, checkType, operatorDef, false))
|
||||
methodMatcher.mSelfType = entry.mSrcType;
|
||||
args.mSize = prevArgSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17786,13 +17794,26 @@ BfTypedValue BfExprEvaluator::PerformUnaryOperation_TryOperator(const BfTypedVal
|
|||
SizedArray<BfExpression*, 2> argSrcs;
|
||||
argSrcs.push_back(unaryOpExpr);
|
||||
|
||||
BfTypedValue targetVal = args[0].mTypedValue;
|
||||
BfTypedValue postOpVal;
|
||||
if (isPostOp)
|
||||
postOpVal = mModule->LoadValue(args[0].mTypedValue);
|
||||
if (isPostOp)
|
||||
postOpVal = mModule->LoadValue(targetVal);
|
||||
|
||||
BfTypedValue callTarget;
|
||||
if (!methodMatcher.mBestMethodDef->mIsStatic)
|
||||
{
|
||||
callTarget = targetVal;
|
||||
args.Clear();
|
||||
}
|
||||
|
||||
auto result = CreateCall(&methodMatcher, BfTypedValue());
|
||||
auto result = CreateCall(&methodMatcher, callTarget);
|
||||
|
||||
if ((result.mType != NULL) && (methodMatcher.mSelfType != NULL) && (result.mType->IsSelf()))
|
||||
if (!methodMatcher.mBestMethodDef->mIsStatic)
|
||||
{
|
||||
if (!isPostOp)
|
||||
result = mModule->LoadValue(targetVal);
|
||||
}
|
||||
else if ((result.mType != NULL) && (methodMatcher.mSelfType != NULL) && (result.mType->IsSelf()))
|
||||
{
|
||||
BF_ASSERT(mModule->IsInGeneric());
|
||||
result = mModule->GetDefaultTypedValue(methodMatcher.mSelfType);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue