| 942 | } |
| 943 | |
| 944 | bool ParseFunctionVariables(Lexeme** str, unsigned nodeOffset) |
| 945 | { |
| 946 | bool genericArg = false; |
| 947 | if(!ParseSelectType(str, true, true)) |
| 948 | return true; |
| 949 | |
| 950 | genericArg = GetSelectedType() ? GetSelectedType()->dependsOnGeneric : false; |
| 951 | if(genericArg) |
| 952 | FunctionGeneric(true); |
| 953 | |
| 954 | unsigned argID = 0; |
| 955 | if(genericArg && nodeOffset) |
| 956 | { |
| 957 | TypeInfo *curr = GetSelectedType(); |
| 958 | SelectTypeForGeneric(nodeOffset - 1 + argID); |
| 959 | if(curr->refLevel && !GetSelectedType()->refLevel) |
| 960 | SelectTypeByPointer(CodeInfo::GetReferenceType(GetSelectedType())); |
| 961 | } |
| 962 | |
| 963 | if((*str)->type != lex_string) |
| 964 | ThrowError((*str)->pos, "ERROR: variable name not found after type in function variable list"); |
| 965 | |
| 966 | if((*str)->length >= NULLC_MAX_VARIABLE_NAME_LENGTH) |
| 967 | ThrowError((*str)->pos, "ERROR: parameter name length is limited to 2048 symbols"); |
| 968 | FunctionParameter((*str)->pos, InplaceStr((*str)->pos, (*str)->length)); |
| 969 | (*str)++; |
| 970 | |
| 971 | if(ParseLexem(str, lex_set)) |
| 972 | { |
| 973 | FunctionPrepareDefault(); |
| 974 | if(!ParseTernaryExpr(str)) |
| 975 | ThrowError((*str)->pos, "ERROR: default parameter value not found after '='"); |
| 976 | FunctionParameterDefault((*str)->pos); |
| 977 | } |
| 978 | |
| 979 | while(ParseLexem(str, lex_comma)) |
| 980 | { |
| 981 | argID++; |
| 982 | bool lastGeneric = genericArg; |
| 983 | genericArg = false; |
| 984 | if(!ParseSelectType(str, true, true)) |
| 985 | genericArg = lastGeneric; // if there is no type and no generic, then this parameter is as generic as the last one |
| 986 | genericArg |= GetSelectedType() ? GetSelectedType()->dependsOnGeneric : false; |
| 987 | if(genericArg) |
| 988 | FunctionGeneric(true); |
| 989 | if(genericArg && nodeOffset) |
| 990 | { |
| 991 | TypeInfo *curr = GetSelectedType(); |
| 992 | SelectTypeForGeneric(nodeOffset - 1 + argID); |
| 993 | if(curr->refLevel && !GetSelectedType()->refLevel) |
| 994 | SelectTypeByPointer(CodeInfo::GetReferenceType(GetSelectedType())); |
| 995 | } |
| 996 | |
| 997 | if((*str)->type != lex_string) |
| 998 | ThrowError((*str)->pos, "ERROR: variable name not found after type in function variable list"); |
| 999 | if((*str)->length >= NULLC_MAX_VARIABLE_NAME_LENGTH) |
| 1000 | ThrowError((*str)->pos, "ERROR: parameter name length is limited to 2048 symbols"); |
| 1001 | FunctionParameter((*str)->pos, InplaceStr((*str)->pos, (*str)->length)); |
no test coverage detected