| 20943 | } |
| 20944 | |
| 20945 | BfTypedValue BfExprEvaluator::PerformAssignment_CheckOp(BfAssignmentExpression* assignExpr, bool deferBinop, BfTypedValue& leftValue, BfTypedValue& rightValue, bool& evaluatedRight) |
| 20946 | { |
| 20947 | BfResolvedArgs argValues; |
| 20948 | auto checkTypeInst = leftValue.mType->ToTypeInstance(); |
| 20949 | while (checkTypeInst != NULL) |
| 20950 | { |
| 20951 | for (auto operatorDef : checkTypeInst->mTypeDef->mOperators) |
| 20952 | { |
| 20953 | if (operatorDef->mOperatorDeclaration->mAssignOp != assignExpr->mOp) |
| 20954 | continue; |
| 20955 | |
| 20956 | auto methodInst = mModule->GetRawMethodInstanceAtIdx(checkTypeInst, operatorDef->mIdx); |
| 20957 | if (methodInst == NULL) |
| 20958 | continue; |
| 20959 | if (methodInst->GetParamCount() != 1) |
| 20960 | continue; |
| 20961 | |
| 20962 | auto paramType = methodInst->GetParamType(0); |
| 20963 | if (deferBinop) |
| 20964 | { |
| 20965 | if (argValues.mArguments == NULL) |
| 20966 | { |
| 20967 | SizedArray<BfExpression*, 2> argExprs; |
| 20968 | argExprs.push_back(assignExpr->mRight); |
| 20969 | BfSizedArray<BfExpression*> sizedArgExprs(argExprs); |
| 20970 | argValues.Init(&sizedArgExprs); |
| 20971 | ResolveArgValues(argValues, BfResolveArgsFlag_DeferParamEval); |
| 20972 | } |
| 20973 | |
| 20974 | evaluatedRight = true; |
| 20975 | rightValue = ResolveArgValue(argValues.mResolvedArgs[0], paramType); |
| 20976 | if (!rightValue) |
| 20977 | continue; |
| 20978 | } |
| 20979 | else |
| 20980 | { |
| 20981 | if (!mModule->CanCast(rightValue, paramType)) |
| 20982 | continue; |
| 20983 | |
| 20984 | rightValue = mModule->Cast(assignExpr->mLeft, rightValue, paramType); |
| 20985 | BF_ASSERT(rightValue); |
| 20986 | } |
| 20987 | |
| 20988 | mModule->SetElementType(assignExpr->mOpToken, BfSourceElementType_Method); |
| 20989 | auto autoComplete = GetAutoComplete(); |
| 20990 | if ((autoComplete != NULL) && (autoComplete->IsAutocompleteNode(assignExpr->mOpToken))) |
| 20991 | { |
| 20992 | if (operatorDef->mOperatorDeclaration != NULL) |
| 20993 | autoComplete->SetDefinitionLocation(operatorDef->mOperatorDeclaration->mOpTypeToken); |
| 20994 | } |
| 20995 | |
| 20996 | auto moduleMethodInstance = mModule->GetMethodInstance(checkTypeInst, operatorDef, BfTypeVector()); |
| 20997 | |
| 20998 | BfExprEvaluator exprEvaluator(mModule); |
| 20999 | SizedArray<BfIRValue, 1> args; |
| 21000 | exprEvaluator.PushThis(assignExpr->mLeft, leftValue, moduleMethodInstance.mMethodInstance, args); |
| 21001 | exprEvaluator.PushArg(rightValue, args); |
| 21002 | exprEvaluator.CreateCall(assignExpr, moduleMethodInstance.mMethodInstance, moduleMethodInstance.mFunc, false, args); |
nothing calls this directly
no test coverage detected