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

Method FinishTypeDef

IDEHelper/Compiler/BfDefBuilder.cpp:2048–2569  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2046}
2047
2048void BfDefBuilder::FinishTypeDef(bool wantsToString)
2049{
2050 auto bfSource = mCurTypeDef->mSource;
2051 bool isAlias = mCurTypeDef->mTypeCode == BfTypeCode_TypeAlias;
2052 bool hasCtor = false;
2053 bool needsDefaultCtor = (mCurTypeDef->mTypeCode != BfTypeCode_Interface) && (!mCurTypeDef->mIsStatic) && (!isAlias);
2054 bool hasDefaultCtor = false;
2055 BfMethodDef* ctorClear = NULL;
2056 BfMethodDef* staticCtor = NULL;
2057 BfMethodDef* dtor = NULL;
2058 BfMethodDef* staticDtor = NULL;
2059 BfMethodDef* markMethod = NULL;
2060 BfMethodDef* staticMarkMethod = NULL;
2061 BfMethodDef* dynamicCastMethod = NULL;
2062 BfMethodDef* toStringMethod = NULL;
2063 BfMethodDef* getUnderlyingMethod = NULL;
2064 bool needsEqualsMethod = ((mCurTypeDef->mTypeCode == BfTypeCode_Struct) || (mCurTypeDef->mTypeCode == BfTypeCode_Enum)) && (!mCurTypeDef->mIsStatic);
2065 BfMethodDef* equalsOpMethod = NULL;
2066 BfMethodDef* equalsMethod = NULL;
2067 BfMethodDef* strictEqualsMethod = NULL;
2068
2069 bool needsStaticInit = false;
2070 if (mCurTypeDef->IsExtension())
2071 needsDefaultCtor = false;
2072
2073 bool needsDtor = false;
2074 bool needsStaticDtor = false;
2075 bool hasStaticField = false;
2076 bool hasNonStaticField = false;
2077 bool hasThreadStatics = false;
2078
2079 for (int methodIdx = 0; methodIdx < (int)mCurTypeDef->mMethods.size(); methodIdx++)
2080 {
2081 auto method = mCurTypeDef->mMethods[methodIdx];
2082
2083 auto _SetMethod = [&](BfMethodDef*& setMethodDef, BfMethodDef* methodDef)
2084 {
2085 if ((setMethodDef != NULL) && (setMethodDef->mMethodDeclaration == NULL))
2086 setMethodDef->mProtection = BfProtection_Hidden;
2087 setMethodDef = methodDef;
2088 };
2089
2090 if (method->mMethodType == BfMethodType_Ctor)
2091 {
2092 if (method->HasAppend())
2093 needsDtor = true;
2094
2095 if (method->mIsStatic)
2096 {
2097 if ((staticCtor != NULL) && (staticCtor->mMethodDeclaration != NULL))
2098 {
2099 Fail("Only one static constructor is allowed", method->mMethodDeclaration);
2100 method->mIsStatic = false;
2101 }
2102
2103 if (method->mParams.size() != 0)
2104 {
2105 Fail("Static constructor cannot declare parameters", method->mMethodDeclaration);

Callers 2

UpdateCEEmitMethod · 0.80
FinishMethod · 0.80

Calls 15

FailFunction · 0.85
HashStringFunction · 0.85
IsExtensionMethod · 0.80
HasAppendMethod · 0.80
GetMethodDeclarationMethod · 0.80
GetFieldDeclarationMethod · 0.80
GetInitializerMethod · 0.80
MixinStrMethod · 0.80
Finish128Method · 0.80
sizeMethod · 0.45
IsEmptyMethod · 0.45

Tested by

no test coverage detected