MCPcopy Create free account
hub / github.com/WheretIB/nullc / FunctionParameter

Function FunctionParameter

NULLC/Callbacks.cpp:2949–2976  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2947}
2948
2949void 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
2978void FunctionPrepareDefault()
2979{

Callers 7

EndBlockFunction · 0.85
TypeFinishFunction · 0.85
AddListGeneratorFunction · 0.85
ParseClassBodyFunction · 0.85
ParseEnumFunction · 0.85
ParseFunctionVariablesFunction · 0.85

Calls 4

ThrowErrorFunction · 0.85
AddParameterMethod · 0.80
insertMethod · 0.80
GetStringHashFunction · 0.70

Tested by

no test coverage detected