| 10612 | |
| 10613 | |
| 10614 | ResultType Line::EvaluateSwitchCase(ExprTokenType &aSwitch, SymbolType aSwitchIsNumeric, ExprTokenType &aCase, StringCaseSenseType aStringCaseSense) |
| 10615 | // Performs comparison of two tokens for Switch(). |
| 10616 | { |
| 10617 | SymbolType case_is_numeric = PURE_NOT_NUMERIC; |
| 10618 | if (aStringCaseSense == SCS_INVALID) |
| 10619 | { |
| 10620 | // Perform numeric comparison if both aSwitch and aCase are numeric and at least one |
| 10621 | // is pure numeric, not a string. This should match the behaviour of SYM_EQUALCASE. |
| 10622 | if (aSwitchIsNumeric && !(aSwitch.symbol == SYM_STRING && aCase.symbol == SYM_STRING)) |
| 10623 | case_is_numeric = TokenIsNumeric(aCase); |
| 10624 | //else no need to call TokenIsNumeric(); just leave case_is_numeric set to its default |
| 10625 | // value so that string comparison will be used. |
| 10626 | } |
| 10627 | else // Since CaseSense was specified, unconditionally use string comparison. |
| 10628 | { |
| 10629 | if (aCase.symbol == SYM_OBJECT) |
| 10630 | return ResultToken().TypeError(_T("String"), aCase); |
| 10631 | // Caller has unconditionally set aSwitchIsNumeric to PURE_NOT_NUMERIC in this case, |
| 10632 | // and has already verified aSwitch.symbol != SYM_OBJECT. |
| 10633 | } |
| 10634 | bool equal; |
| 10635 | if (aSwitch.symbol == SYM_OBJECT || aCase.symbol == SYM_OBJECT) |
| 10636 | equal = aSwitch.symbol == aCase.symbol && aSwitch.object == aCase.object; |
| 10637 | else if (!case_is_numeric) |
| 10638 | { |
| 10639 | TCHAR left_buf[MAX_NUMBER_SIZE], *left_string = TokenToString(aSwitch, left_buf); |
| 10640 | TCHAR right_buf[MAX_NUMBER_SIZE], *right_string = TokenToString(aCase, right_buf); |
| 10641 | switch (aStringCaseSense) |
| 10642 | { |
| 10643 | case SCS_INSENSITIVE: equal = !_tcsicmp(left_string, right_string); break; |
| 10644 | case SCS_INSENSITIVE_LOCALE: equal = !lstrcmpi(left_string, right_string); break; |
| 10645 | default: equal = !_tcscmp(left_string, right_string); break; |
| 10646 | } |
| 10647 | } |
| 10648 | else if (aSwitchIsNumeric == PURE_INTEGER && case_is_numeric == PURE_INTEGER) |
| 10649 | equal = TokenToInt64(aSwitch) == TokenToInt64(aCase); |
| 10650 | else |
| 10651 | equal = TokenToDouble(aSwitch) == TokenToDouble(aCase); |
| 10652 | return equal ? CONDITION_TRUE : CONDITION_FALSE; |
| 10653 | } |
| 10654 | |
| 10655 | |
| 10656 |
nothing calls this directly
no test coverage detected