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

Method TryGetAppendedObjectInfo

IDEHelper/Compiler/BfModule.cpp:4796–4887  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4794}
4795
4796bool BfModule::TryGetAppendedObjectInfo(BfFieldInstance* fieldInstance, int& dataSize, int& alignSize)
4797{
4798 auto resolvedFieldType = fieldInstance->GetResolvedType();
4799 auto fieldDef = fieldInstance->GetFieldDef();
4800
4801 BfAstNode* nameRefNode = NULL;
4802 if (auto fieldDecl = fieldDef->GetFieldDeclaration())
4803 nameRefNode = fieldDecl->mNameNode;
4804 else if (auto paramDecl = fieldDef->GetParamDeclaration())
4805 nameRefNode = paramDecl->mNameNode;
4806 if (nameRefNode == NULL)
4807 nameRefNode = fieldDef->mTypeRef;
4808
4809 dataSize = resolvedFieldType->mSize;
4810 alignSize = resolvedFieldType->mAlign;
4811
4812 SetAndRestoreValue<BfFieldDef*> prevTypeRef(mContext->mCurTypeState->mCurFieldDef, fieldDef);
4813 SetAndRestoreValue<BfTypeState::ResolveKind> prevResolveKind(mContext->mCurTypeState->mResolveKind, BfTypeState::ResolveKind_FieldType);
4814
4815 PopulateType(resolvedFieldType, BfPopulateType_Data);
4816
4817 auto fieldTypeInst = resolvedFieldType->ToTypeInstance();
4818 dataSize = BF_MAX(fieldTypeInst->mInstSize, 0);
4819 alignSize = BF_MAX(fieldTypeInst->mInstAlign, 1);
4820
4821 if (fieldTypeInst->mTypeFailed)
4822 {
4823 TypeFailed(fieldTypeInst);
4824 fieldInstance->mResolvedType = GetPrimitiveType(BfTypeCode_Var);
4825 return false;
4826 }
4827
4828 if ((fieldTypeInst != NULL) && (fieldTypeInst->mTypeDef->mIsAbstract))
4829 {
4830 Fail("Cannot create an instance of an abstract class", nameRefNode);
4831 }
4832
4833 SetAndRestoreValue<bool> prevIgnoreWrites(mBfIRBuilder->mIgnoreWrites, true);
4834 BfMethodState methodState;
4835 SetAndRestoreValue<BfMethodState*> prevMethodState(mCurMethodState, &methodState);
4836 methodState.mTempKind = BfMethodState::TempKind_NonStatic;
4837
4838 BfTypedValue appendIndexValue;
4839 BfExprEvaluator exprEvaluator(this);
4840
4841 BfResolvedArgs resolvedArgs;
4842
4843 auto fieldDecl = fieldDef->GetFieldDeclaration();
4844 if (auto invocationExpr = BfNodeDynCast<BfInvocationExpression>(fieldDecl->mInitializer))
4845 {
4846 resolvedArgs.Init(invocationExpr->mOpenParen, &invocationExpr->mArguments, &invocationExpr->mCommas, invocationExpr->mCloseParen);
4847 exprEvaluator.ResolveArgValues(resolvedArgs, BfResolveArgsFlag_DeferParamEval);
4848 }
4849
4850 BfFunctionBindResult bindResult;
4851 bindResult.mSkipThis = true;
4852 bindResult.mWantsArgs = true;
4853 SetAndRestoreValue<BfFunctionBindResult*> prevBindResult(exprEvaluator.mFunctionBindResult, &bindResult);

Callers

nothing calls this directly

Calls 15

FailFunction · 0.85
GetResolvedTypeMethod · 0.80
GetFieldDefMethod · 0.80
GetFieldDeclarationMethod · 0.80
GetParamDeclarationMethod · 0.80
GetFakeValMethod · 0.80
MatchConstructorMethod · 0.80
HasAppendMethod · 0.80
ToTypeInstanceMethod · 0.45
InitMethod · 0.45
ResolveArgValuesMethod · 0.45

Tested by

no test coverage detected