| 2046 | } |
| 2047 | |
| 2048 | void 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); |
no test coverage detected