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

Function FunctionToOperator

NULLC/Callbacks.cpp:3415–3432  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3413}
3414
3415void FunctionToOperator(const char* pos)
3416{
3417 static unsigned int hashAdd = GetStringHash("+");
3418 static unsigned int hashSub = GetStringHash("-");
3419 static unsigned int hashBitNot = GetStringHash("~");
3420 static unsigned int hashLogNot = GetStringHash("!");
3421 static unsigned int hashIndex = GetStringHash("[]");
3422 static unsigned int hashFunc = GetStringHash("()");
3423 static unsigned int hashLogAnd = GetStringHash("&&");
3424 static unsigned int hashLogOr = GetStringHash("||");
3425
3426 FunctionInfo &lastFunc = *currDefinedFunc.back();
3427 if(lastFunc.nameHash != hashFunc && lastFunc.nameHash != hashIndex && lastFunc.paramCount != 2 && !(lastFunc.paramCount == 1 && (lastFunc.nameHash == hashAdd || lastFunc.nameHash == hashSub || lastFunc.nameHash == hashBitNot || lastFunc.nameHash == hashLogNot)))
3428 ThrowError(pos, "ERROR: binary operator definition or overload must accept exactly two arguments");
3429 if((lastFunc.nameHash == hashLogAnd || lastFunc.nameHash == hashLogOr) && !lastFunc.lastParam->varType->funcType)
3430 ThrowError(pos, "ERROR: && or || operator definition or overload must accept a function returning desired type as the second argument (try %s)", CodeInfo::GetFunctionType(lastFunc.lastParam->varType, lastFunc.lastParam->next, 0)->GetFullTypeName());
3431 lastFunc.visible = true;
3432}
3433
3434void ResetConstantFoldError()
3435{

Callers 1

ParseFunctionDefinitionFunction · 0.85

Calls 4

ThrowErrorFunction · 0.85
GetFunctionTypeFunction · 0.85
GetFullTypeNameMethod · 0.80
GetStringHashFunction · 0.70

Tested by

no test coverage detected