End of type definition
| 4937 | |
| 4938 | // End of type definition |
| 4939 | void TypeFinish() |
| 4940 | { |
| 4941 | // Class members changed variable top, here we restore it to original position |
| 4942 | varTop -= newType->size; |
| 4943 | // In NULLC, all classes have sizes multiple of 4, so add padding if necessary |
| 4944 | if(newType->size % 4 != 0) |
| 4945 | { |
| 4946 | newType->paddingBytes = 4 - (newType->size % 4); |
| 4947 | newType->size += 4 - (newType->size % 4); |
| 4948 | } |
| 4949 | |
| 4950 | // Wrap all member function definitions into one expression list |
| 4951 | CodeInfo::nodeList.push_back(new NodeZeroOP()); |
| 4952 | AddOneExpressionNode(); |
| 4953 | for(unsigned int i = 0; i < methodCount; i++) |
| 4954 | AddTwoExpressionNode(); |
| 4955 | newType->definitionList = CodeInfo::nodeList.back(); |
| 4956 | |
| 4957 | // Shift new types generated inside up, so that declaration will be in the correct order in C translation |
| 4958 | for(unsigned int i = newType->originalIndex + 1; i < CodeInfo::typeInfo.size(); i++) |
| 4959 | CodeInfo::typeInfo[i]->originalIndex--; |
| 4960 | newType->originalIndex = CodeInfo::typeInfo.size() - 1; |
| 4961 | |
| 4962 | // Remove all aliases defined inside class definition |
| 4963 | AliasInfo *info = newType->childAlias; |
| 4964 | while(info) |
| 4965 | { |
| 4966 | CodeInfo::classMap.remove(info->nameHash, info->type); |
| 4967 | info = info->next; |
| 4968 | } |
| 4969 | newType->hasFinished = true; |
| 4970 | |
| 4971 | // Check if custom default assignment operator is required |
| 4972 | bool customConstructor = false; |
| 4973 | TypeInfo::MemberVariable *curr = newType->firstVariable; |
| 4974 | for(; curr; curr = curr->next) |
| 4975 | { |
| 4976 | TypeInfo *base = curr->type; |
| 4977 | while(base && base->arrLevel && base->arrSize != TypeInfo::UNSIZED_ARRAY) // Unsized arrays are not initialized |
| 4978 | base = base->subType; |
| 4979 | if(HasConstructor(base, 0)) |
| 4980 | customConstructor = true; |
| 4981 | } |
| 4982 | |
| 4983 | if(customConstructor) |
| 4984 | { |
| 4985 | currType = typeVoid; |
| 4986 | const char *constructorName = FindConstructorName(newType); |
| 4987 | unsigned length = (unsigned)strlen(constructorName); |
| 4988 | char *name = AllocateString(length + 2); |
| 4989 | SafeSprintf(name, length + 2, "%s$", constructorName); |
| 4990 | FunctionAdd(CodeInfo::lastKnownStartPos, name); |
| 4991 | currDefinedFunc.back()->typeConstructor = true; |
| 4992 | FunctionStart(CodeInfo::lastKnownStartPos); |
| 4993 | AddVoidNode(); |
| 4994 | FunctionEnd(CodeInfo::lastKnownStartPos); |
| 4995 | AddTwoExpressionNode(); |
| 4996 | } |
no test coverage detected