MCPcopy Create free account
hub / github.com/beefytech/Beef / ResolveArgTypedValue

Method ResolveArgTypedValue

IDEHelper/Compiler/BfExprEvaluator.cpp:1302–1535  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1300}
1301
1302BfTypedValue BfMethodMatcher::ResolveArgTypedValue(BfResolvedArg& resolvedArg, BfType* checkType, BfTypeVector* genericArgumentsSubstitute, BfType *origCheckType, BfResolveArgFlags flags)
1303{
1304 BfTypedValue argTypedValue = resolvedArg.mTypedValue;
1305 if ((resolvedArg.mArgFlags & BfArgFlag_DelegateBindAttempt) != 0)
1306 {
1307 BfExprEvaluator exprEvaluator(mModule);
1308 exprEvaluator.mExpectingType = checkType;
1309 BF_ASSERT(resolvedArg.mExpression->IsA<BfDelegateBindExpression>());
1310 auto delegateBindExpr = BfNodeDynCast<BfDelegateBindExpression>(resolvedArg.mExpression);
1311 BfMethodInstance* boundMethodInstance = NULL;
1312
1313 auto bindType = checkType;
1314 if ((bindType == NULL) && (origCheckType != NULL) && (!origCheckType->IsUnspecializedTypeVariation()))
1315 bindType = checkType;
1316 if (exprEvaluator.CanBindDelegate(delegateBindExpr, &boundMethodInstance, bindType, genericArgumentsSubstitute))
1317 {
1318 if (delegateBindExpr->mNewToken == NULL)
1319 {
1320 if (boundMethodInstance->GetOwner()->IsFunction())
1321 {
1322 return BfTypedValue(mModule->mBfIRBuilder->GetFakeVal(), boundMethodInstance->GetOwner());
1323 }
1324 else if ((boundMethodInstance->mDisallowCalling) || ((flags & BfResolveArgFlag_FromGeneric) == 0))
1325 {
1326 argTypedValue = BfTypedValue(mModule->mBfIRBuilder->GetFakeVal(), checkType);
1327 }
1328 else
1329 {
1330 resolvedArg.mExpectedType = checkType;
1331 auto methodRefType = mModule->CreateMethodRefType(boundMethodInstance);
1332 mModule->AddDependency(methodRefType, mModule->mCurTypeInstance, BfDependencyMap::DependencyFlag_Calls);
1333 mModule->AddCallDependency(boundMethodInstance);
1334 argTypedValue = BfTypedValue(mModule->mBfIRBuilder->GetFakeVal(), methodRefType);
1335 }
1336 }
1337 else
1338 argTypedValue = BfTypedValue(BfTypedValueKind_UntypedValue);
1339 }
1340 }
1341 else if ((resolvedArg.mArgFlags & BfArgFlag_LambdaBindAttempt) != 0)
1342 {
1343 if ((argTypedValue) && (argTypedValue.mType->IsMethodRef()) &&
1344 ((checkType == NULL) || (!checkType->IsMethodRef())))
1345 {
1346 // This may be from a previous checkMethod, clear it out
1347 argTypedValue = BfTypedValue();
1348 }
1349
1350 BfExprEvaluator exprEvaluator(mModule);
1351 exprEvaluator.mExpectingType = checkType;
1352 BF_ASSERT(resolvedArg.mExpression->IsA<BfLambdaBindExpression>());
1353 auto lambdaBindExpr = (BfLambdaBindExpression*)resolvedArg.mExpression;
1354
1355 if ((checkType != NULL) && (checkType->IsDelegate()))
1356 {
1357 BfMethodInstance* methodInstance = mModule->GetRawMethodInstanceAtIdx(checkType->ToTypeInstance(), 0, "Invoke");
1358 if (methodInstance != NULL)
1359 {

Callers

nothing calls this directly

Calls 15

BfTypedValueClass · 0.85
CanBindDelegateMethod · 0.80
GetFakeValMethod · 0.80
CreateMethodRefTypeMethod · 0.80
AddDependencyMethod · 0.80
AddCallDependencyMethod · 0.80
IsFunctionMethod · 0.45
GetOwnerMethod · 0.45
IsMethodRefMethod · 0.45
IsDelegateMethod · 0.45

Tested by

no test coverage detected