| 4898 | } |
| 4899 | |
| 4900 | void TypeAddConstant(const char* pos, const char* constName) |
| 4901 | { |
| 4902 | if(CodeInfo::nodeList.back()->nodeType != typeNodeNumber) |
| 4903 | ThrowError(pos, "ERROR: expression didn't evaluate to a constant number"); |
| 4904 | |
| 4905 | unsigned size = newType->size; |
| 4906 | unsigned memberCount = newType->memberCount; |
| 4907 | bool hasPointers = newType->hasPointers; |
| 4908 | |
| 4909 | if(currType) |
| 4910 | ((NodeNumber*)CodeInfo::nodeList.back())->ConvertTo(currType); |
| 4911 | newType->AddMemberVariable(constName, currType ? currType : CodeInfo::nodeList.back()->typeInfo); |
| 4912 | newType->lastVariable->defaultValue = CodeInfo::nodeList.back(); |
| 4913 | CodeInfo::nodeList.pop_back(); |
| 4914 | |
| 4915 | newType->size = size; |
| 4916 | newType->memberCount = memberCount; |
| 4917 | newType->hasPointers = hasPointers; |
| 4918 | |
| 4919 | for(TypeInfo::MemberVariable *curr = newType->firstVariable; curr && curr != newType->lastVariable; curr = curr->next) |
| 4920 | { |
| 4921 | if(curr->nameHash == newType->lastVariable->nameHash) |
| 4922 | ThrowError(pos, "ERROR: name '%s' is already taken for a variable in current scope", constName); |
| 4923 | } |
| 4924 | VariableInfo *varInfo = (VariableInfo*)AddVariable(pos, InplaceStr(constName, (int)strlen(constName))); |
| 4925 | varInfo->isGlobal = true; |
| 4926 | varInfo->parentType = newType; |
| 4927 | } |
| 4928 | |
| 4929 | void TypePrototypeFinish() |
| 4930 | { |
no test coverage detected