| 3413 | } |
| 3414 | |
| 3415 | void 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 | |
| 3434 | void ResetConstantFoldError() |
| 3435 | { |
no test coverage detected