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

Method CallBaseCtorCalc

IDEHelper/Compiler/BfModule.cpp:17707–17829  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17705}
17706
17707BfTypedValue BfModule::CallBaseCtorCalc(bool constOnly)
17708{
17709 // Any errors should only be shown in the actual CTOR call
17710 SetAndRestoreValue<bool> prevIgnoreWrites(mIgnoreErrors, true);
17711
17712 auto methodDef = mCurMethodInstance->mMethodDef;
17713 BF_ASSERT((methodDef->mMethodType == BfMethodType_Ctor) || (methodDef->mMethodType == BfMethodType_CtorCalcAppend));
17714 auto ctorDeclaration = (BfConstructorDeclaration*)methodDef->mMethodDeclaration;
17715
17716 BfAllowAppendKind allowAppendKind = GetBaseAllowAppend(mCurMethodInstance);
17717
17718 BfCustomAttributes* customAttributes = NULL;
17719 defer(delete customAttributes);
17720 BfInvocationExpression* ctorInvocation = NULL;
17721 if (ctorDeclaration != NULL)
17722 {
17723 ctorInvocation = BfNodeDynCast<BfInvocationExpression>(ctorDeclaration->mInitializer);
17724 if (auto attributedExpr = BfNodeDynCast<BfAttributedExpression>(ctorDeclaration->mInitializer))
17725 {
17726 ctorInvocation = BfNodeDynCast<BfInvocationExpression>(attributedExpr->mExpression);
17727 customAttributes = GetCustomAttributes(attributedExpr->mAttributes, BfAttributeTargets_MemberAccess);
17728 }
17729 }
17730
17731 BfTypeInstance* targetType = NULL;
17732 if (ctorInvocation != NULL)
17733 {
17734 auto targetToken = BfNodeDynCast<BfTokenNode>(ctorInvocation->mTarget);
17735 targetType = (targetToken->GetToken() == BfToken_This) ? mCurTypeInstance : mCurTypeInstance->mBaseType;
17736 }
17737 else
17738 targetType = mCurTypeInstance->mBaseType;
17739 if ((targetType == NULL) || (targetType == mContext->mBfObjectType))
17740 return NULL;
17741
17742 auto targetRefNode = methodDef->GetRefNode();
17743
17744 BfType* targetThisType = targetType;
17745 BfTypedValue target(mBfIRBuilder->GetFakeVal(), targetThisType);
17746
17747 BfExprEvaluator exprEvaluator(this);
17748 BfResolvedArgs argValues;
17749 if ((ctorDeclaration != NULL) && (ctorInvocation != NULL))
17750 {
17751 argValues.Init(&ctorInvocation->mArguments);
17752 }
17753
17754 //
17755 {
17756 }
17757 BfFunctionBindResult bindResult;
17758 bindResult.mSkipThis = true;
17759 bindResult.mWantsArgs = true;
17760 {
17761 SetAndRestoreValue<bool> prevIgnoreWrites(mBfIRBuilder->mIgnoreWrites, true);
17762 exprEvaluator.ResolveArgValues(argValues, BfResolveArgsFlag_DeferParamEval);
17763 SetAndRestoreValue<BfFunctionBindResult*> prevBindResult(exprEvaluator.mFunctionBindResult, &bindResult);
17764 exprEvaluator.MatchConstructor(targetRefNode, NULL, target, targetType, argValues, true, BfMethodGenericArguments(), allowAppendKind, NULL);

Callers

nothing calls this directly

Calls 13

BfTypedValueClass · 0.85
GetTokenMethod · 0.80
GetFakeValMethod · 0.80
MatchConstructorMethod · 0.80
HasAppendMethod · 0.80
GetRefNodeMethod · 0.45
InitMethod · 0.45
ResolveArgValuesMethod · 0.45
IsFakeMethod · 0.45
RemoveAtMethod · 0.45
GetOwnerMethod · 0.45

Tested by

no test coverage detected