| 2947 | } |
| 2948 | |
| 2949 | void FunctionParameter(const char* pos, InplaceStr paramName) |
| 2950 | { |
| 2951 | if(currType == typeVoid) |
| 2952 | ThrowError(pos, "ERROR: function parameter cannot be a void type"); |
| 2953 | unsigned int hash = GetStringHash(paramName.begin, paramName.end); |
| 2954 | FunctionInfo &lastFunc = *currDefinedFunc.back(); |
| 2955 | |
| 2956 | if(lastFunc.lastParam && !lastFunc.lastParam->varType && !lastFunc.generic) |
| 2957 | ThrowError(pos, "ERROR: function parameter cannot be an auto type"); |
| 2958 | |
| 2959 | for(VariableInfo *info = lastFunc.firstParam; info; info = info->next) |
| 2960 | { |
| 2961 | if(info->nameHash == hash) |
| 2962 | ThrowError(pos, "ERROR: parameter with name '%.*s' is already defined", int(info->name.end - info->name.begin), info->name.begin); |
| 2963 | } |
| 2964 | |
| 2965 | #if defined(__CELLOS_LV2__) |
| 2966 | unsigned bigEndianShift = currType == typeChar ? 3 : (currType == typeShort ? 2 : 0); |
| 2967 | #else |
| 2968 | unsigned bigEndianShift = 0; |
| 2969 | #endif |
| 2970 | lastFunc.AddParameter(new VariableInfo(&lastFunc, paramName, hash, lastFunc.allParamSize + bigEndianShift, currType, false)); |
| 2971 | if(currType) |
| 2972 | lastFunc.allParamSize += currType->size < 4 ? 4 : currType->size; |
| 2973 | |
| 2974 | // Insert variable to a list so that a typeof can be taken from it |
| 2975 | varMap.insert(lastFunc.lastParam->nameHash, lastFunc.lastParam); |
| 2976 | } |
| 2977 | |
| 2978 | void FunctionPrepareDefault() |
| 2979 | { |
no test coverage detected